Project

Profile

Help

Bug #2084

closed

Failed to execute an XSLT 3.0 stylesheet that uses the 'parse-xml-fragment' function

Added by Radu Pisoi over 10 years ago. Updated over 10 years ago.

Status:
Closed
Priority:
Low
Category:
Internals
Sprint/Milestone:
-
Start date:
2014-06-02
Due date:
% Done:

100%

Estimated time:
Legacy ID:
Applies to branch:
Fix Committed on Branch:
Fixed in Maintenance Release:
Platforms:

Description

The transformation of an XSLT 3.0 stylesheet that uses the parse-xml-fragment function fails if an external XML parser is provided. The custom XML parser should have an EntityResolver set.

To reproduce the problem you can execute from command line the following transformation:

d:\workspace\eXml>java -Xmx180m -Xss4096k -Xms48m -cp d:\workspace\eXml\lib\saxon9ee.jar;d:\workspace\eXml\lib\custom_parser.jar net.sf.saxon.
Transform -xsl:samples/test.xsl -s:samples/personal.xml -x:ro.sync.exml.test.XMLReaderWrapper
Error
  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:/d:/workspace/eXml/samples/test.xsl: Connection timed out: connect
Transformation failed: Run-time errors were reported

test.xsl


<xsl:stylesheet version="3.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:template match="/">
        <xsl:sequence 
            select="parse-xml-fragment('&lt;testFragment&gt;test&lt;/testFragment&gt;')"/>
    </xsl:template>
</xsl:stylesheet> 

The custom XML reader, XMLReaderWrapper, could be found as attachment. It is a simple implementation that wraps an XMLReader obtained using SAXParserFactory. The entity resolver has the following implementation:

  private EntityResolver entityResolver = new EntityResolver() {    
    @Override
    public InputSource resolveEntity(String publicId, String systemId) throws SAXException,
        IOException {
      return null;
    }
  };

Files

custom_parser.jar (2.43 KB) custom_parser.jar Radu Pisoi, 2014-06-02 16:13
XMLReaderWrapper.java (6.4 KB) XMLReaderWrapper.java Radu Pisoi, 2014-06-02 16:14
Actions #1

Updated by Radu Pisoi over 10 years ago

I found the problem using the Saxon 9.5.1.5.

Actions #2

Updated by O'Neil Delpratt over 10 years ago

Please may you send me the files test.xsl and personal.xml so that I can try to reproduce the problem reported.

Thanks

Actions #3

Updated by O'Neil Delpratt over 10 years ago

Please ignore the request for files. I see them given

Actions #4

Updated by O'Neil Delpratt over 10 years ago

  • Category set to Internals
  • Status changed from New to In Progress
  • Assignee set to O'Neil Delpratt
  • Found in version set to 9.5
Actions #5

Updated by Michael Kay over 10 years ago

Just to record what we discovered so far: parse-xml-fragment() attempts to set an EntityResolver to allow it to parse the supplied string as an external general parsed entity. The attempt to set an EntityResolver is ignored by the Sender class if the parser in use already has an EntityResolver set. So we know what the problem is, and we are thinking about how best to solve it.

Actions #6

Updated by O'Neil Delpratt over 10 years ago

  • Status changed from In Progress to Resolved

This bug issue has now been fixed and will be available in the next maintenance release.

The problem: An XML fragment requires an document in which to parse. We give it a dummy document, but if the supplied parser does not know about the document's system ID then it reports the error detailed in the initial bug issue.

The fix was applied in the ParseXmlFragment class. We force the parser to use our defined Entity Resolver if it does not have one. In the case where it does have a entity resolver, we replace the parser with our own.

Actions #7

Updated by O'Neil Delpratt over 10 years ago

  • Status changed from Resolved to Closed
  • % Done changed from 0 to 100
  • Fixed in version set to 9.5.1.6

Bug fix applied in Saxon maintenance release 9.5.1.6

Please register to edit this issue

Also available in: Atom PDF