[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Can I predict the build order of nodes?
At 2010-02-14 10:50 -0800, Kevin Brown wrote:
I noticed an interesting build order/selection issue between Saxon and Microsoft XSL transforms ... in my style sheet I have: The above assigns the text value of the first stylemasterfile element child of winelist in document order to the variable $stylemasterfile. It is a bit wasteful to build a result tree fragment for this ... you could have: <xsl:param name="stylemasterfile" select="/winelist/stylemasterfile"/> <xsl:param name="stylemasterset" select="document($stylemasterfile)/styles | /winelist/styles"/> There is no prescribed document order between two different trees. For any given processor the nodes of one tree are persistently in the same document order before the nodes of another tree, but another processor can just as well have a different persistent order between two trees. The XML may have: Both! What do you think is the proper result of this: Precisely. Would something like this help? <xsl:variable name="in" select="/"/> <xsl:param name="stylemasterfile" select="/winelist/stylemasterfile"/> <xsl:variable select="document($stylemasterfile)/ styles[not($in/winelist/styles)][last()] | $in/winelist/styles[last()]" name="stylemaster"/> ... which is to say "use the last of the external document only if there are no internal styles, in union with the last of the internal styles If the styles element isn't repeating and you are only using last to distinguish between the two, then it is simply: <xsl:variable select="document($stylemasterfile)/ styles[not($in/winelist/styles)] | $in/winelist/styles" name="stylemaster"/> In XSLT 2 (which I'm guessing is out of bounds for you because you cite Microsoft) it would be accomplished with a sequence: ( /winelist/styles , document($stylemasterfile)/styles ) [1] I hope this helps. . . . . . . . . . . . . . Ken -- XSLT/XQuery/XPath training after http://XMLPrague.cz 2010-03-15/19 XSLT/XQuery/XPath training: San Carlos, California 2010-04-26/30 Vote for your XML training: http://www.CraneSoftwrights.com/s/i/ Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ Training tools: Comprehensive interactive XSLT/XPath 1.0/2.0 video Video lesson: http://www.youtube.com/watch?v=PrNjJCh7Ppg&fmt=18 Video overview: http://www.youtube.com/watch?v=VTiodiij6gE&fmt=18 G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Male Cancer Awareness Nov'07 http://www.CraneSoftwrights.com/s/bc Legal business disclaimers: http://www.CraneSoftwrights.com/legal
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|