[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Get children and text, excluding a child

Subject: Get children and text, excluding a child
From: "Rick Quatro rick@xxxxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 12 Jun 2015 20:44:15 -0000
 Get children and text
Hello,

Here is my input xml:

<?xml version="1.0"?>
<root>
  <span><number>9.3</number> <code>protected</code> members</span>
  <span><number>9.4</number> miscellaneous members.</span>
</root>

Here is the desired output:

<?xml version="1.0"?>
<root>
  <span> <code>protected</code> members</span>
  <span> miscellaneous members.</span>
</root>

I want to output all of the elements and text of the original <span> element,
but without the <number> element. I am using this for my xsl:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    exclude-result-prefixes="xs"
    version="2.0">

    <xsl:output method="xml" indent="yes"/>

    <xsl:template match="/root">
        <root>
            <xsl:for-each select="span">
                <xsl:copy-of select="descendant::*[not(self::number)]"/>
            </xsl:for-each>
        </root>
    </xsl:template>

</xsl:stylesheet>

This is my current (incorrect) output:

<?xml version="1.0" encoding="UTF-8"?>
<root>
   <code>protected</code>
</root>

Any help or pointers would be appreciated. Thanks.

Rick Quatro
Carmen Publishing Inc.
585-366-4017
rick@xxxxxxxxxxxxxxx

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.