0
votes

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 prologJoel M. Lamsen

1 Answers

1
votes

@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 ?>.)