0

I want to generate a pdf from an xsl template and xml parameters,

the beginning of the template is the next one:

< ?xml version="1.0" encoding="UTF-8"?> < xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:fo="http://www.w3.org/1999/XSL/Format" >
< xsl:output method="xml" version="1.0" omit-xml-declaration="no" indent="yes" encoding="UTF-8" />**

and the bebinning of the xml file:

< ?xml version="1.0" encoding="UTF-8" ?>
< GenerationReport >
< ValidationResult >
< Result >...

the error that is coming out:

Caused by: org.xml.sax.SAXParseException; lineNumber: 2; columnNumber: 1; Content is not allowed in prolog. at org.apache.xerces.parsers.DOMParser.parse(DOMParser.java:244) at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:285) at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:121) at es.gob.signaturereport.tools.XMLUtils.getDocumentImpl(XMLUtils.java:371) at es.gob.signaturereport.tools.XMLUtils.getDocument(XMLUtils.java:233) ... 53 more

1
  • there should be no space between "<" and "?" in the prolog Commented Apr 20, 2018 at 7:42

1 Answer 1

1

@joel-m-lamsen is correct that you don't want a space in <?.

However, you also don't want a space between < and the element name. Your samples should be (with line-breaks added to avoid scroll bars):

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
xmlns:fo="http://www.w3.org/1999/XSL/Format" >
  <xsl:output method="xml" version="1.0" omit-xml-declaration="no" indent="yes"
    encoding="UTF-8" />

and:

<?xml version="1.0" encoding="UTF-8" ?>
<GenerationReport >
  <ValidationResult >
    <Result >...

The space before the >, />, or ?> isn't a problem. (Just don't start adding spaces in /> or ?>.)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.