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

Re: Correlation between two xml trees

Subject: Re: Correlation between two xml trees
From: Joerg Heinicke <joerg.heinicke@xxxxxx>
Date: Thu, 06 Jun 2002 18:37:17 +0200
correlation between two stores
Hello John,

it's not so difficult:

$data stores the z:row, you are currently processing. So with $data you can easily access this z:row. With the for-each you switch the context away from the z:row to $outputdef. The columns in $outputdef have an attribute @dbcolumn, which is normally accessed via <xsl:value-of select="@dbcolumn"/>.

Now from the z:row in $data you want to get the value of either @col1, @col2 or @col3. The attribute you want to access is stored in @dbcolumn. So you want to have the value of this attribute, whose name is the same as the value stored in @dbcolumn.

$data/@* means "all attributes of the z:row stored in $data".

The predicate [] restricts the selection of this expression. Everything in the predicate refers to the node/attribute/etc. directly before the predicate. So @*[name()] means the name() of the attribute.

With current() we switch the context away from these attributes to the context element, which is at the moment a column from $outputdef/root/cloumn (see for-each).

So

$data/@*[name()=current()/@dbcolumn]

means

return the value of all the attributes, whose name() is the same as the value of the @dbcolumn of the currently processed element. Of course this is only one. (<xsl:value-of/> also selects always only the value of the first node/attribute in a nodeset.)

I hope, this explanation was not to much,to less or to buggy ;-)

Regards,

Joerg


John Sands wrote:
Hi Joerg,

Thank you very much. It works, but I'd like to understand it.


<xsl:template match="z:row">
  <data>
    <xsl:variable name="data" select="."/>
    <xsl:for-each select="$outputdef/root/column">
      <xsl:element name="{@tagname}">
        <xsl:value-of select="$data/@*[name()=current()/@dbcolumn]"/>
      </xsl:element>
    </xsl:for-each>
  </data>
</xsl:template>


I understand the use of the xsl:variable, but the rest of the expression
is still baffling to me:

select="$data/@*[name()=current()/@dbcolumn]"

Can you explain what it does, please?

Thanks,
John Sands



--

System Development
VIRBUS AG
Fon  +49(0)341-979-7419
Fax  +49(0)341-979-7409
joerg.heinicke@xxxxxxxxx
www.virbus.de


XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list



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.