[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: document nodes.

Subject: Re: document nodes.
From: "Michael Kay michaelkay90@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 13 Dec 2024 08:37:32 -0000
Re:  document nodes.
The spec, unfortunately, is clear:

If the xsl:message instruction contains a sequence constructor, then the
sequence obtained by evaluating this sequence constructor is used to construct
the content of the new document node, as described in 5.7.1 Constructing
Complex Content.

and 5.7.1 says that it's an error to attach an attribute node to a document
node.

It then goes on to say:

Any dynamic error that occurs while evaluating the select expression or the
contained sequence constructor, and any serialization error that occurs while
processing the result, does not cause the transformation to fail; at worst, it
means that no message is output, or that the only message that is output is
one that relates to the error that occurred.

I guess we could try and be smarter about the error recovery, specifically, by
putting a filter in front of the complex content constructor to modify invalid
content (like attribute nodes) before they get in there and trigger the
error.

I think that in Saxon 9.9 we bypassed the tree construction and sent the
events straight to a serializer. This caused havoc in multi-threaded
environments where multiple transformations were sending messages to the same
destination; the messages would be interleaved in a completely arbitrary way.
So we fixed one problem and caused another.

Michael Kay
Saxonica



> On 13 Dec 2024, at 01:00, Imsieke, Gerrit, le-tex gerrit.imsieke@xxxxxxxxx
<xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:
>
> Hi Andr\xE9,
>
> This is due to a change in how Saxon implements xsl:message. The change has
been introduced in Saxon 10.
>
> Before, xsl:message has output (I believe) the string value or some other
serialization of attributes.
>
> Now the items that xsl:message outputs are wrapped in a document node. It
works fine for all kinds of nodes but not for attributes.
>
> So you need to use the string value of the attribute explicitly, as you
already discovered.
>
> We needed to change a lot of our debugging messages when we upgraded to
Saxon 10.
>
> Gerrit
>
> On 13.12.2024 01:44, Andre Cusson akhu01@xxxxxxxxx wrote:
>> Hi,
>> There is some Saxon/Oxygen behavior that I do not seem to grasp.
>> I made a simplified use case to present it.
>> I have\xA0an xml document (thingtest.xml) that looks somewhat like this:
>> <?xml version="1.0" encoding="UTF-8"?>
>> <thing id="main" title="something">
>> \xA0 \xA0 <thing id="group1">...</thing>
>> \xA0 \xA0 <thing id="group2">...</thing>
>> \xA0 \xA0 <thing id="group3">...</thing>
>> </thing>
>> and I have a stylesheet\xA0(thingtest.xslt) that reads this file and tries
to "message" the value of the title attribute on the main (root) element,
like:
>> <?xml version="1.0" encoding="UTF-8"?>
>> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform
<http://www.w3.org/1999/XSL/Transform>"
>> \xA0 \xA0 xmlns:xs="http://www.w3.org/2001/XMLSchema
<http://www.w3.org/2001/XMLSchema>"
>> \xA0 \xA0 xmlns:math="http://www.w3.org/2005/xpath-functions/math
<http://www.w3.org/2005/xpath-functions/math>"
>> \xA0 \xA0 exclude-result-prefixes="xs math"
>> \xA0 \xA0 version="3.0">
>> \xA0 \xA0 <xsl:template match="/">
>> \xA0 \xA0 \xA0 \xA0 <xsl:variable name="struct"
select="doc('thingtest.xml')/*"/>
>> \xA0 \xA0 \xA0 \xA0 <xsl:message select="$struct/@title"/>
>> \xA0 \xA0 </xsl:template>
>> </xsl:stylesheet>
>> Now running this produces this error
>> [Saxon-PE] Error XTDE0420 while evaluating xsl:message at line 10 of
file:servercfg/thingtest.xslt: Cannot create an attribute node (title) whose
parent is a document node.
>> Mind you, $struct should not be a document mode as it is the child of a
document node.
>> Where it gets a little exotic for me is when I replace the message
instruction by either :
>> \xA0<xsl:message select="'' || $struct/@title"/>
>> or
>> \xA0<xsl:message select="string-join(($struct/@title))"/>
>> Then, it works fine.
>> I do not mind adding a null string if I have to, but better
understanding\xA0why may better contribute to my happiness.
>> What am I doing wrong this time ... ;)
>> Thank you,
>> Regards.

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.