Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - Re: Need to get previous node >Thread Next - Re: Need to get previous node Re: Need to get previous nodeTo: NULL Date: 8/5/2009 10:56:00 AM
"Martin Honnen" <mahotrash@y...> wrote in message
news:OoVYXJfFKHA.4968@T......
> tshad wrote:
>> That did it, but now I need to use that number to get a field from a
>> previous set of nodes, but the select is not working.
>>
>> If I make the following changes the XML looks like:
>>
>> <FORM>
>> <FIELDS>
>> <TITLE1>This is Title1</TITLE1>
>> <TITLE2>This is Title2</TITLE2>
>> <TITLE3>This is Title3</TITLE3>
>> </FIELDS>
>> <FORMPHOTOS>
>> <PHOTO NUM="1">
>> <FILENAME>09May001.jpg</FILENAME>
>> <FILETYPE>JPEG</FILETYPE>
>> </PHOTO>
>> <PHOTO NUM="2">
>> <FILENAME>09005.jpg</FILENAME>
>> <FILETYPE>JPEG</FILETYPE>
>> </PHOTO>
>> <PHOTO NUM="3">
>> <FILENAME>09002.jpg</FILENAME>
>> <FILETYPE>JPEG</FILETYPE>
>> </PHOTO>
>> </FORMPHOTOS>
>> </FORM>
>>
>> I am doing:
>>
>> <xsl:template match="FORMPHOTOS/PHOTO">
>> <xsl:choose>
>> <xsl:when test=". != ''">
>> <attachment>
>> <source>
>> <xsl:value-of select="../../FIELDS/*[name() =
>> concat('TITLE',@NUM)]"/>
>
> Inside of the square brackets the context node is no longer the PHOTO
> element but rather that * child element. So you either need to store the
> attribute value in a variable and use that variable e.g.
> <source>
> <xsl:variable name="n" select="@NUM"/>
> <xsl:value-of select="../../FIELDS/*[name() = concat('TITLE',$n)]"/>
>
> or you can use the current() function e.g.
> <source>
> <xsl:value-of select="../../FIELDS/*[name() =
> concat('TITLE',current()/@NUM)]"/>
> as that refers to the node currently processed by an xsl:for-each or
> xsl:apply-templates.
>
Worked perfectly.
When you say current node, are you talking about everything inside the PHOTO
tags?
Or FORMPHOTOS as well. In otherword, if I change the FORMPHOTOS element to:
<FORMPHOTOS LABEL="HOUSE">
Could I have also accessed the LABEL as:
<source>
<xsl:value-of select="@HOUSE"/>
When you say that "Inside of the square brackets the context node is no
longer the PHOTO element but rather that * child element", what is the *
child element refering to?
Thanks,
Tom
>
>
> --
>
> Martin Honnen --- MVP XML
> http://msmvps.com/blogs/martin_honnen/
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
