Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
| 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 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 August 29th, 2007, 07:04 AM
Friend of Wrox
Points: 1,676, Level: 16
Points: 1,676, Level: 16 Points: 1,676, Level: 16 Points: 1,676, Level: 16
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2006
Location: , , .
Posts: 430
Thanks: 28
Thanked 5 Times in 5 Posts
Send a message via Yahoo to bonekrusher
Default Copy parent node and not its children

Hi,

I am trying to do an XML to XMl conversion and having some trouble. I want to copy the value of a node but not its childrens value.

here is the input XML:

Code:
<addremark oprocedure="1">
                <Para id="d210e105"> May be inoperative provided:<RemarksList id="d210e110">
                        <Para id="d210e112">Operational Procedures below are followed,  and</Para>
                        <Para id="d210e118">
                            <RED id="d210e120">Repairs are made within two flight days. </RED>
                        </Para>
                    </RemarksList>
                </Para>
            </addremark>


here is my XSLT:

Code:
<xsl:for-each select="additem/Para[position()=1]">
        <para>
            <xsl:value-of select="."/>
        </para>
</xsl:for-each>
I want the desired output to be:

    <para> May be inoperative provided:</para>

but I get all the children values.

Thanks
 
Old August 29th, 2007, 07:41 AM
samjudson's Avatar
Friend of Wrox
Points: 8,687, Level: 40
Points: 8,687, Level: 40 Points: 8,687, Level: 40 Points: 8,687, Level: 40
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2007
Location: Newcastle, , United Kingdom.
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

The following should work:

Code:
<xsl:value-of select="text()"/>

/- Sam Judson -/
 
Old August 29th, 2007, 07:57 AM
Friend of Wrox
Points: 1,676, Level: 16
Points: 1,676, Level: 16 Points: 1,676, Level: 16 Points: 1,676, Level: 16
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2006
Location: , , .
Posts: 430
Thanks: 28
Thanked 5 Times in 5 Posts
Send a message via Yahoo to bonekrusher
Default

Hi Sam,

Thanks... how easy.
 
Old August 29th, 2007, 08:23 AM
samjudson's Avatar
Friend of Wrox
Points: 8,687, Level: 40
Points: 8,687, Level: 40 Points: 8,687, Level: 40 Points: 8,687, Level: 40
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2007
Location: Newcastle, , United Kingdom.
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

Works fine here. The whole stylesheet:

Code:
<xsl:stylesheet version="2.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

  <xsl:template match="/">
    <xsl:for-each select="addremark/Para[position()=1]">    
        <para>
            <xsl:value-of select="text()"/>
        </para>
    </xsl:for-each>
  </xsl:template>
</xsl:stylesheet>
/- Sam Judson : Wrox Technical Editor -/
 
Old August 29th, 2007, 08:44 AM
Friend of Wrox
Points: 1,676, Level: 16
Points: 1,676, Level: 16 Points: 1,676, Level: 16 Points: 1,676, Level: 16
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2006
Location: , , .
Posts: 430
Thanks: 28
Thanked 5 Times in 5 Posts
Send a message via Yahoo to bonekrusher
Default

Hi Sam,

Thanks... how easy.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Finding parent node Chamkaur XSLT 4 August 9th, 2006 06:26 AM
How to delete an element and parent node. crossedge XSLT 1 March 14th, 2006 05:10 AM
Counting node-set children in template rufustfirefly XSLT 2 May 3rd, 2004 08:48 AM
Saving the parent node Doyle Bradely XML 2 December 23rd, 2003 07:05 PM
Trying to get node name of childs children keldan XML 1 August 1st, 2003 03:11 PM





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