Project

Profile

Help

Revision a3c08363

Added by Michael Kay about 9 years ago

Fix bug #1509: Serialization error SEPM0004 not reported

View differences:

latest9.4/hej/net/sf/saxon/serialize/XMLEmitter.java
221 221
                }
222 222
            }
223 223

  
224
            String systemId = outputProperties.getProperty(OutputKeys.DOCTYPE_SYSTEM);
225
            if (systemId != null && !"".equals(systemId)) {
226
                requireWellFormed = true;
227
            }
228

  
224 229
            if (omitXMLDeclaration.equals("no")) {
225 230
                writer.write("<?xml version=\"" + version + "\" " + "encoding=\"" + encoding + '\"' +
226 231
                        (standalone != null ? " standalone=\"" + standalone + '\"' : "") + "?>");
......
294 299
    {
295 300
        if (!started) {
296 301
            openDocument();
297
        } else if (requireWellFormed && elementStack.isEmpty()) {
298
            if (startedElement) {
299
                XPathException err = new XPathException("When 'standalone' or 'doctype-system' is specified, " +
300
                        "the document must be well-formed; but this document contains more than one top-level element");
301
                err.setErrorCode("SEPM0004");
302
                throw err;
303
            } else {
304
                startedElement = true;
305
            }
302
        } else if (requireWellFormed && elementStack.isEmpty() && startedElement) {
303
            XPathException err = new XPathException("When 'standalone' or 'doctype-system' is specified, " +
304
                    "the document must be well-formed; but this document contains more than one top-level element");
305
            err.setErrorCode("SEPM0004");
306
            throw err;
306 307
        }
308
        startedElement = true;
307 309

  
308 310
        String displayName = elemName.getDisplayName();
309 311
        if (!allCharactersEncodable) {

Also available in: Unified diff