Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XSLT
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 13th, 2006, 03:38 AM
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
  #2 (permalink)  
Old June 13th, 2006, 03:57 AM
mhkay's Avatar
Wrox Author
Points: 18,487, Level: 59
Points: 18,487, Level: 59 Points: 18,487, Level: 59 Points: 18,487, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

You could start with <xsl:value-of select="Seg". If you really need to do the case conversion, it's something like

concat(substring(Seg,1,1), translate(substring(Seg,2), 'ABCDE...', 'abcde...')))

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem adding element to the previous element dani1 XSLT 5 September 10th, 2008 01:38 AM
translate element name to element name lexzeus XSLT 3 September 4th, 2006 09:04 AM
Finding the last element jeremycod XSLT 4 March 12th, 2006 05:45 PM
Can I tell what element I am currently in? insanek XSLT 4 September 19th, 2005 05:44 AM
adding of element and assigning to one element sushovandatta XSLT 2 November 16th, 2004 07:04 PM



All times are GMT -4. The time now is 06:30 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.