Project

Profile

Help

Bug #3225

Adaptive and JSON output methods using JAXP interfaces

Added by Radu Coravu over 2 years ago. Updated over 2 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
JAXP Java API
Sprint/Milestone:
-
Start date:
2017-05-18
Due date:
% Done:

100%

Legacy ID:
Applies to branch:
9.7
Fix Committed on Branch:
9.7, trunk
Fixed in Maintenance Release:

Description

Two kind of related problems.

1) Using this XSLT:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    exclude-result-prefixes="xs"
    version="3.0">
    <xsl:output method="json" media-type="application/json"></xsl:output>
    <xsl:template name="main">
        <xsl:sequence select="json-doc('http://ip.jsontest.com')"></xsl:sequence>
    </xsl:template>
</xsl:stylesheet>

and transforming using the JAXP interfaces gets us:

> ; SystemID: file:/C:/Users/radu_coravu/Desktop/test.xsl; Line#: 8; Column#: 9
> net.sf.saxon.trans.XPathException: Cannot write a function item to an XML tree
>   at net.sf.saxon.event.SequenceWriter.append(SequenceWriter.java:387)
>   at net.sf.saxon.event.ProxyReceiver.append(ProxyReceiver.java:233)
>   at net.sf.saxon.event.ProxyReceiver.append(ProxyReceiver.java:233)
>   at net.sf.saxon.event.SequenceReceiver.append(SequenceReceiver.java:124)
>   at net.sf.saxon.event.ComplexContentOutputter.append(ComplexContentOutputter.java:622)
>   at net.sf.saxon.expr.Expression.process(Expression.java:911)
>   at net.sf.saxon.expr.instruct.NamedTemplate.expand(NamedTemplate.java:259)
>   at net.sf.saxon.Controller.transformDocument(Controller.java:2434)
>   at net.sf.saxon.Controller.transform(Controller.java:1985)
>   at net.sf.saxon.s9api.XsltTransformer.transform(XsltTransformer.java:590)
>   at net.sf.saxon.jaxp.TransformerImpl.transform(TransformerImpl.java:185)

2) Using this XSLT:

<xsl:stylesheet 
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    version="3.0">
    <xsl:output method="adaptive"/>

    <xsl:template name="main">
        <xsl:sequence select="[1, 2, 3]"/>
    </xsl:template>
</xsl:stylesheet>

and transforming using JAXP obtains the result "1 2 3" instead of "[1,2,3]"

History

#1 Updated by Michael Kay over 2 years ago

  • Category set to JAXP Java API
  • Status changed from New to Resolved
  • Assignee set to Michael Kay
  • Applies to branch 9.7, 9.8 added
  • Fix Committed on Branch 9.7, 9.8 added

I have patched XsltTransformer.transform() so that if the requested output method (either in the stylesheet or in the JAXP Transformer API) requests output method json or adaptive, then Controller.setBuildTree(false) is called, which suppresses the "sequence normalization" phase of serialization, and thus prevents this error.

JUnit test cases added to jaxptest/TestTransform

#2 Updated by Radu Coravu over 2 years ago

Thanks Michael, I tested the patch and it seems to fix both problems.

#3 Updated by O'Neil Delpratt over 2 years ago

  • Fix Committed on Branch trunk added
  • Fix Committed on Branch deleted (9.8)

#4 Updated by O'Neil Delpratt over 2 years ago

  • Applies to branch deleted (9.8)

#5 Updated by O'Neil Delpratt over 2 years ago

  • Status changed from Resolved to Closed
  • % Done changed from 0 to 100
  • Fixed in Maintenance Release 9.7.0.19 added

Bug fix applied in the 9.7.0.19 maintenance release.

Please register to edit this issue

Also available in: Atom PDF