Project

Profile

Help

parse-xml-fragment() and -catalog

Added by T Hata about 5 years ago

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet exclude-result-prefixes="#all" version="3.0"
	xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:template name="xsl:initial-template">
		<xsl:variable as="xs:string" name="s"><![CDATA[He was <i>so</i> kind]]></xsl:variable>
		<xsl:sequence select="parse-xml-fragment($s)" />
	</xsl:template>
</xsl:stylesheet>

This doesn't work with -catalog (resolver.jar is Apache resolver):

C:\test>java -cp "saxon9ee.jar;resolver.jar" net.sf.saxon.Transform -it -t -xsl:test.xsl -catalog:catalog.xml
Loading catalog: file:/C:/test/catalog.xml
Saxon-EE 9.9.1.1J from Saxonica
Java version 1.8.0_201
...
Processing  (no source document) initial template = xsl:initial-template
Using parser org.apache.xml.resolver.tools.ResolvingXMLReader
Building tree for file:/C:/test/test.xsl using class net.sf.saxon.tree.tiny.TinyBuilder
Error in xsl:sequence/@select on line 6 column 51 of test.xsl:
  FODC0006: First argument to parse-xml-fragment() is not a well-formed and
  namespace-well-formed XML fragment. XML parser reported: I/O error reported by XML parser
  processing file:/C:/test/test.xsl: http://www.saxonica.com/parse-xml-fragment/actual.xml
at template xsl:initial-template on line 4 of test.xsl:
First argument to parse-xml-fragment() is not a well-formed and namespace-well-formed XML fragment. XML parser reported: I/O error reported by XML parser processing file:/C:/test/test.xsl: http://www.saxonica.com/parse-xml-fragment/actual.xml

Is this by design when using -catalog?


Replies (2)

RE: parse-xml-fragment() and -catalog - Added by Michael Kay about 5 years ago

No, this isn't by design - thanks for reporting it.

There's a little quarrel going on about who owns the EntityResolver. We inject an EntityResolver into the parser and ask it to parse a dummy document containing an external entity reference, which our EntityResolver interprets as pointing to the parse-xml-fragment input, but the CatalogResolver then splats our EntityResolver with its own. We need to be more careful about the way we instantiate the XML parser.

    (1-2/2)

    Please register to reply