Thread: Element
View Single Post
  #1 (permalink)  
Old June 13th, 2006, 03:38 AM
Neal Neal is offline
Friend of Wrox
Points: 718, Level: 10
Points: 718, Level: 10 Points: 718, Level: 10 Points: 718, Level: 10
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2006
Location: Ennis, Clare, Ireland.
Posts: 131
Thanks: 10
Thanked 0 Times in 0 Posts
Default Element

Hi,

The following is the XML that I need to transform (Input):

Code:
<Anal Type="PGRP">
 <Seg No="1" Code="1">FEED</Seg>
 <Seg No="2" Code="1D">ANIMAL</Seg>
 <Seg No="3" Code="DC">FIN</Seg>
</Anal>
The following format is my required Output:

Code:
<Reference Type="Class Code" AssignedBy="Manufacturer" Explanation="Feed">1</Reference>
I have coded the following lines which retrieves the value '1', but how do I retrieve the value 'Feed' (See **** in code below)?

Code:
<xsl:template name="Anal" match="*[@Type='PGRP']">
 <xsl:for-each select=".//*[@Type='PGRP']/Seg/@No">
  <xsl:if test="position() =1">
   <xsl:element name="Reference">
    <xsl:attribute name="Type">Major Class Code</xsl:attribute>
     <xsl:attribute name="AssignedBy">Manufacturer</xsl:attribute>
      <xsl:attribute name="Explanation">****</xsl:attribute>    
       <xsl:value-of select="current()"/>    
   </xsl:element>
  </xsl:if>
 </xsl:for-each>
</xsl:template>
The above code produces the following (current) Output:

Code:
<Reference Type="Major Class Code" AssignedBy="Manufacturer" Explanation="">1</Reference>
Question
How do I retreive the 'Feed' value in my code (to be positioned after 'Explanation=')?

Thanks in advance,


Neal

A Northern Soul
__________________
Neal

A Northern Soul
Reply With Quote