Now I'm not sure what I want : )
Your logic, as you have explained makes real good sense. Now looking at this:
<xsl:template match="row">
<Field flg="{name(@*[.=1])}"/>
</xsl:template>
The context would be row, and then are you proposing to create a new
element Field?
I'm feeling stuck but usually there is a way to get this done... let
me explain this another way:
In a single source of XML I have a FIELDS/FIELD lookup, where there
are many FIELD elements which may or may not have a flg attribute
who's value maps to an attribute of the same name in a row element.
The value of this attribute determines whether or not to include the
FIELD element in the result.
So, I'll expand a little with my XML:
<root>
<fields>
<field name="Name" flg="flgName"/>
<field name="HomeTown" flg="flgHomeTown"/>
<field name="Country" flg="flgCountry"/>
</fields>
<result>
<row flgHomeTown="1" flgCountry="0" flgName="0"/>
<row flgHomeTown="1" flgCountry="0" flgName="1"/>
</result>
</root>
The context would be row, and for each row, I need the corresponding
field elements in a variable $drvr.
<xsl:template match="row">
<xsl:variable name="drvr" select="
... return field elements for each attribute of row which maps
to the field collection and is = 1 (this probably just confuses the
objective, but i think you know what i mean) ...
</xsl:template>
On 1/7/07, David Carlisle <davidc(_at_)nag(_dot_)co(_dot_)uk> wrote:
> <xsl:copy-of select="$field[(_at_)flg=$drvr/@*[.=name()]]"/>
.=name() is true if the value of the node is the same as its name, so
something like id="id" would test true.
so
$drvr/@*[.=name()]
selects all attributes of the elements in $drvr that have the same name
as their value.
so
@flg=$drvr/@*[.=name()]
is true if there is a flg attribute on the current element that has the
same value as the attribute in $drvr that has the same name as its
value.
It seems like you want something like
<xsl:template match="row">
<Field flg="{name(@*[.=1])}"/>
</xsl:template>
David
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--