I'm using com.saxonica.ptree.StylesheetPackager with PE version 9.6.0.10, to create a zip file for distribution. Is there a fix for this that doesn't require a different license?

I could work around the zero return code problem if the output zip file weren't created but when it fails, it leaves a small zip file. I feel dirty writing code that recognizes failure if the zip file is "too" small. As it stands, there's a problem with the code failing only during the Windows build; the macOS build does not fail for certain characters. When it fails to fail the build (gradle), I don't detect the error soon enough. The error below shows the bad UTF-8 character that I used. For some odd reason, not all invalid UTF-8 characters trigger the throw. And, I should mention that it happens also for invalid multi-byte UTF-8 characters. I know not everyone loves vim but this might help in reproducing my problem.

Here's an MCV example.

$ cat test.xsl
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xsl:transform [
   <!ENTITY % entities SYSTEM "entities.dtd">
   %entities;
]>
<xsl:stylesheet version="2.0"
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>
   <xsl:template match=".*">
      <html lang="en">
         <body>
            kHello, world
         </body>
      </html>
   </xsl:template>
</xsl:stylesheet>

$ cat test.sh
java -classpath saxon9pe.jar 
com.saxonica.ptree.StylesheetPackager test.xsl test.zip
echo return code is $?

$ sh test.sh
Error on line 12 column 13 of test.xsl:
  SXXP0003: Error reported by XML parser: An invalid XML character (Unicode: 0xf) was found
  in the element content of the document.
net.sf.saxon.trans.XPathException: org.xml.sax.SAXParseException; systemId: file:/Users/jholt/test/test.xsl; lineNumber: 12; columnNumber: 13; An invalid XML character (Unicode: 0xf) was found in the element content of the document.
...
org.xml.sax.SAXParseException; systemId: file:/Users/jholt/test/test.xsl; lineNumber: 12; columnNumber: 13; An invalid XML character (Unicode: 0xf) was found in the element content of the document.
...
    at net.sf.saxon.Configuration.buildDocument(Configuration.java:3441)
    at com.saxonica.ptree.StylesheetPackager.archive(StylesheetPackager.java:65)
    at com.saxonica.ptree.StylesheetPackager.main(StylesheetPackager.java:152)
return code is 0
0

There are 0 best solutions below