Hi Wolfhart,
Thanks! Worked wonderfully!
Mark
-----Original Message-----
From: Wolfhart Totschnig
Sent: Thursday, July 21, 2011 10:56 PM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: Re: [xsl] Selecting an attribute vale from an external file
Hi,
The following should work:
<xsl:variable name="CatalogNumber" select=".">
<StampName>
<xsl:value-of
select="document('numbers.xml')/PATH/number[@number=$CatalogNumber]/@name"/>
</StampName>
For "PATH" insert the path to the <number> elements in numbers.xml
Wolfhart
Mark wrote:
I have two files. In the main file is an element
<CatalogNumber>14</CatalogNumber>
The second file contains an unordered sequence of elements like
<Number number="14" name="ceský krumlov"></Number>
I want to add an element to the main file
<StampName>ceský krumlov</StampName
by selecting the name attribute associated with the number attribute of
the <Number> element in the second file that matches the current value of
<CatalogNumber> in the main file.
I tried the below template in my stylesheet but it gives me a set of all
the number attributes in the second file in the variable ‘matching-number’.
I have no clue how to proceed. I thought about putting the second file in
order, then selecting the name attributes into my variable, then indexing
to, in this instance, the 14th name attribute in the returned set, but
that seems a bit like brute force.
Clearly I have two problems:
(1) I do not know how to select the matching Number element;
(2) I do not know how select its name attribute
Help or hints would be greatly appreciated.
Mark
My current template:
<xsl:variable name="names"
select="document('numbers.xml')"></xsl:variable>
<xsl:template match="CatalogNumber">
<xsl:copy-of select="."></xsl:copy-of>
<xsl:variable name="matching-number"
select="$names/List/Number/@number[.]"></xsl:variable>
<xsl:element name="StampName">
<!--<xsl:value-of select=""></xsl:value-of>—>
</xsl:element>
</xsl:template>
--~------------------------------------------------------------------
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>
--~--
--~------------------------------------------------------------------
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>
--~--