Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 4th, 2008, 08:08 AM
Authorized User
 
Join Date: Feb 2008
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default xslt code for xml

hello all,
i am new to xsl and xslt
<POLICIES>
      <POLICY NAME="Policy 1">
 <POLINPUTS>
          <FLD NM="Pol In 2" >7</FLD>
          <FLD NM="PolIn1" >sr8</FLD>
          <FLD NM="Pol In 3" >uuu</FLD>
        </POLINPUTS>
</POLICY >
</POLICIES>

here i am trying to get the values of FLD like
7, sr8, uuu in XSLT using for loop.

how to write xslt code for that.....

but i dint get any exact idea for that.

could any one help ......


 
Old February 4th, 2008, 11:25 AM
Friend of Wrox
 
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
Default

With XSLT 2.0 you can use
Code:
<xsl:stylesheet
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  version="2.0">
  <xsl:output method="text"/>
  <xsl:template match="/">
    <xsl:value-of 
      select="POLICIES/POLICY/POLINPUTS/FLD"
      separator=", "/>
  </xsl:template>
</xsl:stylesheet>
With XSLT 1.0 you can use
Code:
<xsl:stylesheet
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  version="1.0">
  <xsl:output method="text"/>
  <xsl:template match="/">
    <xsl:for-each select="POLICIES/POLICY/POLINPUTS/FLD">
      <xsl:value-of select="."/>
      <xsl:if test="position() != last()">
        <xsl:text>, </xsl:text>
      </xsl:if>
    </xsl:for-each>
  </xsl:template>
</xsl:stylesheet>
 
Old February 5th, 2008, 12:18 AM
Authorized User
 
Join Date: Feb 2008
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hey,
thanx a lot............ :)






Similar Threads
Thread Thread Starter Forum Replies Last Post
NEED XSLT CODE FOR XML suji XSLT 2 February 7th, 2008 11:54 PM
xml and xsl templates as input to xslt gives xml rameshnarayan XSLT 5 August 3rd, 2005 01:58 AM
XSLT for complicated xml to xml transf. required doug@sirvisetti XSLT 3 June 17th, 2005 04:26 PM
merge two xml file and make new xml using xslt ketan XSLT 0 September 21st, 2004 08:48 AM
Merge XML files into a xml file using xslt lxu XML 4 November 6th, 2003 06:01 PM





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