Bug #5830
open
Stylesheets with entity references do not compile
0%
Description
See the attached test.xsl file. When I try to compile it using the latest release:
xslt3 -xsl:test.xsl -export:test.sef.json
I get the following output:
Error FODC0002:
Failed parsing XML in file://path/to/test.xsl: Reference to unknown entity &REUSABLE_PATTERN; at line 8 column 41
Failed to compile stylesheet
I did notice feature #4597 ("Recognize entity declarations in DTDs"). However, I believe this should be considered a bug report rather than a feature request, as I believe a conforming XML processor will always be able to recognize entity declarations in the internal DTD subset. This is actually the first time I've ever seen them not recognized in an XML processing context.
I sometimes use them for repeated long XSLT patterns. My temporary workaround is to expand them all (repeating them throughout the stylesheet).
Files
Updated by Michael Kay 8 months ago
Hi, Evan, if you know of an XML parser in the node.js world that supports DTDs and entity references, please let us know. It's a while since we searched, but last time we did, we couldn't find one. It's probably because everyone is scared stiff of XXE attacks and the like.
Updated by Martynas Jusevicius 8 months ago
This is how I pre-process the stylesheets by canonicalizing them in order to inline entities:
find ./target/ROOT/static/com/atomgraph -type f -name "*.xsl" -exec sh -c 'xmlstarlet c14n "$1" > "$1".c14n && mv "$1".c14n "$1"' x {} \;
Can also be done using net.sf.saxon.Query
instead of xmlstarlet
.
Updated by Evan Lenz 8 months ago
Thanks, Martynas. However, will that use of net.sf.saxon.Query work on NodeJS? Doesn’t it still depend on an XML parser being available that will recognize the internal DTD subset in order to properly canonicalize the XML? Or are you just suggesting the style sheets be pre-processed outside of NodeJS?
Updated by Norm Tovey-Walsh 8 months ago
I think Martynas is suggesting that you pre-process them with a tool that processes internal subsets before passing them to Node.js. Kind of a kludge, but it should work.
Please register to edit this issue
Also available in: Atom PDF Tracking page