[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

[xsl] Selecting an attribute vale from an external file


Subject: [xsl] Selecting an attribute vale from an external file
From: "Mark" <mark@xxxxxxxxxxxx>
Date: Thu, 21 Jul 2011 22:22:27 -0700

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="ceskC= krumlov"></Number>

I want to add an element to the main file
<StampName>ceskC= 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 bmatching-numberb. 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>b>
</xsl:element>
</xsl:template>



Current Thread