Project

Profile

Help

Support #4496

closed

Unexpected order of data stored for a variable.

Added by Ken Holman over 4 years ago. Updated over 4 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
-
Sprint/Milestone:
-
Start date:
2020-03-23
Due date:
% Done:

0%

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

Description

Below is the transcript of some unexpected results, boiled down to a simple example. I spent hours assuming that in the following declaration my copied variable content would be found in order in advance of the entity content:

<xsl:variable name="builtinPhrases" as="element(phrases)+"> <xsl:copy-of select="$additionalPhrases"/> &builtinPhrases; </xsl:variable>

Why would the variable content be stored in the variable after the entity content (as indicated by the output)? Is it related to how the stylesheet tree is constructed from the input source? Certainly it seems un-intuitive that the variable comes after the entity.

I've attached the sample file.

Thank you for your thoughts on this!

. . . . . . Ken

~/t $ cat unexpectedVariableResults.xsl

Hello world '> ]> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xsd="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xsd" version="2.0">

<xsl:variable name="additionalPhrases" as="element(phrases)"> Don't worry, be happy </xsl:variable>

<xsl:variable name="builtinPhrases" as="element(phrases)+"> <xsl:copy-of select="$additionalPhrases"/> &builtinPhrases; </xsl:variable>

<xsl:output method="text"/>

<xsl:template match="/"> <xsl:value-of select="system-property('xsl:product-name'), system-property('xsl:product-version')"/> xsl:text </xsl:text> <xsl:value-of select="$builtinPhrases/@source"/> xsl:text </xsl:text> </xsl:template>

</xsl:stylesheet>~/t $ xslt2 unexpectedVariableResults.xsl unexpectedVariableResults.xsl SAXON HE 9.8.0.15 doctype variable ~/t $


Files

unexpectedVariableResults.xsl (988 Bytes) unexpectedVariableResults.xsl Ken Holman, 2020-03-23 21:14

Please register to edit this issue

Also available in: Atom PDF