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

Re: Question about variable definition and types

Subject: Re: Question about variable definition and types
From: Michael Müller-Hillebrand <mmh@xxxxxxxxxxxxx>
Date: Fri, 7 Mar 2008 16:02:55 +0100
Re:  Question about variable definition and types
Andrew and David,

Thanks a lot -- even on Friday afternoon one can learn some
interesting XSL!

Am 07.03.2008 um 11:43 schrieb David Carlisle:

If you go

<xsl:variable name="a2" as="element()*">
  <xsl:sequence select="a"/>
</xsl:variable>

Then in both cases the a element nodes are siblings, but

in $a2 they are the original a nodes in the source document (so
necessarily siblings as they are selected by the xpath "a" so all
children of the current node at that point. In this case $a2 holds
these
nodes, and they are (still) siblings, but they may have other siblings
not contained in the variable, and their parent node is similarly not
cotained in the variable.

If I process the content of $a2 I would assume that preceding/ following-sibling axis only "sees" the siblings in the variable. Your explanation makes me thinking (and a quick test with Kernow's sandbox ensures that) this is not true.

If I have

<root>
  <a/>
  <b/>
  <a/>
  <a/>
  <c/>
</root>

<xsl:template match="root">
  <xsl:variable name="a2" as="element()*">
    <xsl:sequence select="a"/>
  </xsl:variable>
  <xsl:copy>
    <xsl:for-each select="$a2">
      <xsl:copy>
        <xsl:attribute name="pos" select="position()"/>
        <xsl:attribute name="pre" select="name(preceding-sibling::*
[1])"/>
      </xsl:copy>
    </xsl:for-each>
  </xsl:copy>
</xsl:template>

I get

<root>
   <a pos="1" pre=""/>
   <a pos="2" pre="b"/>
   <a pos="3" pre="a"/>
</root>

How would I access the preceding/following siblings from "inside" the
variable with the as attribute?

- Michael

--
_______________________________________________________________
Michael M|ller-Hillebrand: Dokumentations-Technologie
Adobe Certified Expert, FrameMaker
Lvsungen und Training, FrameScript, XML/XSL, Unicode
<http://cap-studio.de/> -- Tel. +49 (9131) 28747

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-2011 All Rights Reserved.