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