Cannot write a function item to an XML tree

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Cannot write a function item to an XML tree

Radu Coravu
Hi,

Transforming this XSLT stylesheet:

> <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>

using Saxon 9.7 and the JAXP API yields:

> ; 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)

Our end user reports that this works from the command line. Is there any
way we could use the API to transform which would work in this case?

Regards,
Radu

Radu Coravu
<oXygen/>  XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Reply | Threaded
Open this post in threaded view
|

Re: Cannot write a function item to an XML tree

Michael Kay
Using JAXP for transformations that involve use of XSLT 3.0 features, especially stylesheet invocation and serialization features, is becoming quite tricky, and I think the real answer is to move to s9api, in particular, the Xslt30Transformer. It works from the command line because that uses s9api. The problem here is the "build-tree" option, also known as "sequence normalization" in the serialization spec, whereby the result of evaluating the initial template is automatically wrapped in a document node. I'll take a look to see if there is some way we can change the XsltTransformer (and hence JAXP) so this doesn't happen when the serialization method is JSON.

Micahel Kay
Saxonica

> On 17 May 2017, at 14:44, Radu Coravu <[hidden email]> wrote:
>
> Hi,
>
> Transforming this XSLT stylesheet:
>
>> <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>
>
> using Saxon 9.7 and the JAXP API yields:
>
>> ; 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)
>
> Our end user reports that this works from the command line. Is there any
> way we could use the API to transform which would work in this case?
>
> Regards,
> Radu
>
> Radu Coravu
> <oXygen/>  XML Editor, Schema Editor and XSLT Editor/Debugger
> http://www.oxygenxml.com
>
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> saxon-help mailing list archived at http://saxon.markmail.org/
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/saxon-help 


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Reply | Threaded
Open this post in threaded view
|

Re: Cannot write a function item to an XML tree

Dave Pawson-2
Image of Mike, trapped between rock and a hard place?
Pareto comes to mind!

regards

On 17 May 2017 at 15:18, Michael Kay <[hidden email]> wrote:

> Using JAXP for transformations that involve use of XSLT 3.0 features, especially stylesheet invocation and serialization features, is becoming quite tricky, and I think the real answer is to move to s9api, in particular, the Xslt30Transformer. It works from the command line because that uses s9api. The problem here is the "build-tree" option, also known as "sequence normalization" in the serialization spec, whereby the result of evaluating the initial template is automatically wrapped in a document node. I'll take a look to see if there is some way we can change the XsltTransformer (and hence JAXP) so this doesn't happen when the serialization method is JSON.
>
> Micahel Kay
> Saxonica
>
>> On 17 May 2017, at 14:44, Radu Coravu <[hidden email]> wrote:
>>
>> Hi,
>>
>> Transforming this XSLT stylesheet:
>>
>>> <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>
>>
>> using Saxon 9.7 and the JAXP API yields:
>>
>>> ; 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)
>>
>> Our end user reports that this works from the command line. Is there any
>> way we could use the API to transform which would work in this case?
>>
>> Regards,
>> Radu
>>
>> Radu Coravu
>> <oXygen/>  XML Editor, Schema Editor and XSLT Editor/Debugger
>> http://www.oxygenxml.com
>>
>> ------------------------------------------------------------------------------
>> Check out the vibrant tech community on one of the world's most
>> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
>> _______________________________________________
>> saxon-help mailing list archived at http://saxon.markmail.org/
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/saxon-help
>
>
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> saxon-help mailing list archived at http://saxon.markmail.org/
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/saxon-help



--
Dave Pawson
XSLT XSL-FO FAQ.
Docbook FAQ.
http://www.dpawson.co.uk

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Reply | Threaded
Open this post in threaded view
|

Re: Cannot write a function item to an XML tree

Radu Coravu
In reply to this post by Michael Kay
Thanks Michael,

I added an issue just to keep track and to have a place where to discuss
further:

https://saxonica.plan.io/issues/3225

We have a similar problem with the "adaptive" method so I added both
problems on the same issue.

Regards,
Radu

Radu Coravu
<oXygen/>  XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com

On 5/17/2017 5:18 PM, Michael Kay wrote:

> Using JAXP for transformations that involve use of XSLT 3.0 features, especially stylesheet invocation and serialization features, is becoming quite tricky, and I think the real answer is to move to s9api, in particular, the Xslt30Transformer. It works from the command line because that uses s9api. The problem here is the "build-tree" option, also known as "sequence normalization" in the serialization spec, whereby the result of evaluating the initial template is automatically wrapped in a document node. I'll take a look to see if there is some way we can change the XsltTransformer (and hence JAXP) so this doesn't happen when the serialization method is JSON.
>
> Micahel Kay
> Saxonica
>
>> On 17 May 2017, at 14:44, Radu Coravu <[hidden email]> wrote:
>>
>> Hi,
>>
>> Transforming this XSLT stylesheet:
>>
>>> <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>
>>
>> using Saxon 9.7 and the JAXP API yields:
>>
>>> ; 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)
>>
>> Our end user reports that this works from the command line. Is there any
>> way we could use the API to transform which would work in this case?
>>
>> Regards,
>> Radu
>>
>> Radu Coravu
>> <oXygen/>  XML Editor, Schema Editor and XSLT Editor/Debugger
>> http://www.oxygenxml.com
>>
>> ------------------------------------------------------------------------------
>> Check out the vibrant tech community on one of the world's most
>> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
>> _______________________________________________
>> saxon-help mailing list archived at http://saxon.markmail.org/
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/saxon-help
>
>
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> saxon-help mailing list archived at http://saxon.markmail.org/
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/saxon-help
>




------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help