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 September 17th, 2008, 01:56 AM
Authorized User
 
Join Date: Sep 2008
Posts: 87
Thanks: 1
Thanked 0 Times in 0 Posts
Default xslt for a given xml

Hi,
I have the xml :

<richtext xmlns:dxl="http://www.lotus.com/dxl">
  <pardef id="2" align="full" leftmargin="1in" rightmargin="100%" keeptogether="true" />
  <par def="2">The Company announcement released today </par>
  <par def="3" />
  <par def="3" />
  <par def="3">By Order of the Board</par>
  <par def="3" />
  <par def="3" />
  <par def="3">LAM DING LING</par>
  <par def="3">Company Secretary</par>
  <par def="3" />
  <par def="3">Singapore </par>
  <par def="3">25 September 1997</par>
</richtext>

i need to create an xsl for the same.

how to loop and get the values for par def="3",i tried this way

<xsl:for-each select="richtext/par[@def='3']">
  <xsl:value-of select="richtext/par"/>
</xsl:for-each>

but i didnt get any result..
 thnx in adv...


 
Old September 17th, 2008, 03:11 AM
Friend of Wrox
 
Join Date: Jun 2008
Posts: 291
Thanks: 9
Thanked 29 Times in 29 Posts
Default

Try this:

 <xsl:template match="richtext">
        <xsl:apply-templates/>
    </xsl:template>

    <xsl:template match="par">
        <xsl:value-of select=".[@def = 3]"></xsl:value-of>
    </xsl:template>

 
Old September 17th, 2008, 03:15 AM
Friend of Wrox
 
Join Date: Jun 2008
Posts: 291
Thanks: 9
Thanked 29 Times in 29 Posts
Default

or try like your way:

 <xsl:template match="par">
        <xsl:for-each select=".[@def='3']">
            <xsl:value-of select="."/>
        </xsl:for-each>

    </xsl:template>

 
Old September 17th, 2008, 04:00 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

A relative path expression like richtext/par selects downwards from the current node. The current node is the one that the for-each is currently processing. That's a <par> element, and there aren't any richtext elements as children of a <par>, so it selects nothing.

Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer's Reference
 
Old September 17th, 2008, 08:36 PM
Authorized User
 
Join Date: Sep 2008
Posts: 87
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Thanks alot for the replies

<xsl:for-each select="richtext/par">
<tr>
<td><xsl:value-of select="." /></td>
</tr>
</xsl:for-each>

i have done this way and getting everything which is independent of 'def' as mentioned in example...








Similar Threads
Thread Thread Starter Forum Replies Last Post
xml and xsl templates as input to xslt gives xml rameshnarayan XSLT 5 August 3rd, 2005 01:58 AM
XSLT read through XML to transform another XML dendenx2 XSLT 8 July 7th, 2005 08:18 PM
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.