Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: Need to get previous node

From: "tshad" <toms@----.--->
To: NULL
Date: 8/5/2009 10:21:00 AM
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)]"/>
     </source>
    </attachment>
   </xsl:when>
  </xsl:choose>
 </xsl:template>

This gives me blanks.

The concat works fine and comes back with TITLE1, TITLE2 or TITLE3.

And if I change the line to:

      <xsl:value-of select="../../FIELDS/TITLE1"/>

So I assume the FIELDS/* is wrong.

What would I put there instead?

Thanks,

Tom

"Martin Honnen" <mahotrash@y...> wrote in message 
news:OxWoD2eFKHA.4168@T......
> tshad wrote:
>> "Martin Honnen" <mahotrash@y...> wrote in message 
>> news:%23AP5tGbFKHA.3816@T......
>>> tshad wrote:
>>>> Here is part of my xml:
>>>>
>>>>       <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>
>>>>
>>>> In my xsl sheet I am doing:
>>>>
>>>>  <xsl:template match="FORMPHOTOS/PHOTO">
>>>>       <xsl:value-of select="../PHOTO/@NUM"/>
>>>
>>>> In my source tag I am actually doing a little more but I am trying to 
>>>> get the value of @NUM from the immediately preceding node.
>>>         <xsl:value-of select="preceding-sibling::PHOTO[1]/@NUM"/>
>>
>> Almost worked, but not quite.
>>
>> It seems to go back 2.
>>
>> The results I got for my xml were:
>>
>> 09May001.jpg    ->    blank
>> 09005.jpg          ->   1
>> 09002.jpg         ->   2
>
> Then your subject of "previous node" confused me.
> If you simply want to output the 'NUM' attribute of the context node then 
> within
>   <xsl:template match="FORMPHOTOS/PHOTO">
> you simply need
>      <xsl:value-of select="@NUM"/>
>
> -- 
>
> Martin Honnen --- MVP XML
> http://msmvps.com/blogs/martin_honnen/ 




transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent