Project

Profile

Help

Stylesheet does not work with 9.2

Added by Anonymous over 14 years ago

Legacy ID: #7968213 Legacy Poster: Vladimir Nesterovsky (vnesterovsky)

Hello Mr. Kay! Today I've tried to migrate to Saxon 9.2 and found that many of my stylesheets do not work (they worked with 9.1). Here is an example: ------------- <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:t="this" exclude-result-prefixes="xs t"> <xsl:template match="/"> <xsl:variable name="p" as="element()">

</xsl:variable> <xsl:sequence select="'.'"/> <xsl:sequence select="$p/t:d(.)"/> </xsl:template> <xsl:function name="t:d" as="item()"> <xsl:param name="p" as="element()"/> <xsl:apply-templates mode="d" select="$p/"/> </xsl:function> <xsl:template match="d" mode="d"> <xsl:variable name="l" as="xs:integer" select="@l"/> <xsl:sequence select=" if ($l lt 10) then concat('0', $l) else xs:string($l)"/> </xsl:template> <xsl:template match="node()" mode="d"/> </xsl:stylesheet> ------------- The error is like this: ------------- Error on line 18 of saxon-test.xslt: XPTY0018: Cannot mix nodes and atomic values in the result of a path expression ------------- I'm suspecting "concat('0', $l)". Thanks -- Vladimir Nesterovsky

Replies (8)

Please register to reply

RE: Stylesheet does not work with 9.2 - Added by Anonymous over 14 years ago

Legacy ID: #7968229 Legacy Poster: Vladimir Nesterovsky (vnesterovsky)

I would like to believe you can see an example, as I don't see it propertly. Here I'm trying to repeat it. <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:t="this" exclude-result-prefixes="xs t"> <xsl:template match="/"> <xsl:variable name="p" as="element()">

</xsl:variable> <xsl:sequence select="'.'"/> <xsl:sequence select="$p/t:d(.)"/> </xsl:template> <xsl:function name="t:d" as="item()"> <xsl:param name="p" as="element()"/> <xsl:apply-templates mode="d" select="$p/"/> </xsl:function> <xsl:template match="d" mode="d"> <xsl:variable name="l" as="xs:integer" select="@l"/> <xsl:sequence select=" if ($l lt 10) then concat('0', $l) else xs:string($l)"/> </xsl:template> <xsl:template match="node()" mode="d"/> </xsl:stylesheet>

RE: Stylesheet does not work with 9.2 - Added by Anonymous over 14 years ago

Legacy ID: #7968299 Legacy Poster: Vladimir Nesterovsky (vnesterovsky)

also, just to make an intention clear. In no way I expect to get nodes from xsl:template match="d" mode="d", and concat('0', $l) is expected to return xs:string.

RE: Stylesheet does not work with 9.2 - Added by Anonymous over 14 years ago

Legacy ID: #7968470 Legacy Poster: Michael Kay (mhkay)

I can't see anything obviously wrong here. Can you supply a source document so that I can try it out?

RE: Stylesheet does not work with 9.2 - Added by Anonymous over 14 years ago

Legacy ID: #7968489 Legacy Poster: Michael Kay (mhkay)

Never mind - I see it doesn't depend on the contents of the source document. I'll look into it.

RE: Stylesheet does not work with 9.2 - Added by Anonymous over 14 years ago

Legacy ID: #7972104 Legacy Poster: Michael Kay (mhkay)

You're quite right, the problem is an inappropriate optimization to concat(), described here: [https://sourceforge.net/tracker/?func=detail&aid=2924869&group_id=29872&atid=397617][1] A patch is in subversion, and will appear in the next maintenance release. [1]: https://sourceforge.net/tracker/?func=detail&aid=2924869&group_id=29872&atid=397617

RE: Stylesheet does not work with 9.2 - Added by Anonymous over 14 years ago

Legacy ID: #7972215 Legacy Poster: Vladimir Nesterovsky (vnesterovsky)

I've thought, lately, that it might be more attractive to implement this optimization differently. As concat() returns a StringValue encapsulating a CharSequence, so you can create an implementation of CharSequence that keeps a list of items. This implementation will materialize a string on demand, but on the other hand will provide access to a list for those who want to optimize.

RE: Stylesheet does not work with 9.2 - Added by Anonymous over 14 years ago

Legacy ID: #7972315 Legacy Poster: Michael Kay (mhkay)

Yes, that's an interesting suggestion. However, it's not quite as strong an optimization: it still requires the list to be held in memory, rather than the items being sent to the serializer one at a time.

RE: Stylesheet does not work with 9.2 - Added by Anonymous over 14 years ago

Legacy ID: #7975742 Legacy Poster: Vladimir Nesterovsky (vnesterovsky)

Other thought. Here I'm stepping into a guess territory. I think that such an optimization can be done for more specific case of <xsl:value-of select="concat(...)"> I don't think that xsl:sequence is used for creation of text nodes too often.

    (1-8/8)

    Please register to reply