[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
[Recent Entries]
[Reply To This Message]
Re: Selecting an attribute vale from an external file
Subject: Re: Selecting an attribute vale from an external file
From: "Mark" <mark@xxxxxxxxxxxx>
Date: Thu, 21 Jul 2011 23:31:23 -0700
|
Hi Wolfhart,
Thanks! Worked wonderfully!
Mark
-----Original Message-----
From: Wolfhart Totschnig
Sent: Thursday, July 21, 2011 10:56 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re: 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="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>
|
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format
RSS 2.0 |
|
Atom 0.3 |
|
|