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

Re: deep copy without attributes

Subject: Re: deep copy without attributes
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Mon, 20 May 2013 09:20:49 -0400
Re:  deep copy without attributes
At 2013-05-20 14:12 +0100, Ihe Onwuka wrote:
I have done this

  <xsl:template match="*">
    <pattern id="{@*[1]}">
      <xsl:copy>
        <xsl:apply-templates mode="no-attributes"/>
      </xsl:copy>
    </pattern>
  </xsl:template>

  <xsl:template match="*" mode="no-attributes">
    <xsl:copy>
      <xsl:apply-templates mode="no-attributes"/>
    </xsl:copy>
  </xsl:template>


which seems cumbersome when what I really want to do is


  <xsl:template match="*">
    <pattern id="{@*[1]}">
      <xsl:copy-of select="node() except @*"/>
    </pattern>
  </xsl:template>

idea being to deep copy leaving the attribute nodes behind although
that syntax will not do that.

Correct, because "node()" is an abbreviation for "child::node()" and you cannot find attributes along the child axis.


And because your address is only looking at the child axis, there is no recursing down the depth of the tree. You are asking for a lot of things to be different about the select= address you've written.

I'm not sure why you feel that adding single template rule is cumbersome. And given the way you've written your template rule you can shorten the first template as follows:

  <xsl:template match="*">
    <pattern id="{@*[1]}">
      <xsl:apply-templates select="." mode="no-attributes"/>
    </pattern>
  </xsl:template>

. . . . . . . . Ken

--
Contact us for world-wide XML consulting and instructor-led training |
Free 5-hour lecture: http://www.CraneSoftwrights.com/links/udemy.htm |
Crane Softwrights Ltd.            http://www.CraneSoftwrights.com/s/ |
G. Ken Holman                   mailto:gkholman@xxxxxxxxxxxxxxxxxxxx |
Google+ profile: https://plus.google.com/116832879756988317389/about |
Legal business disclaimers:    http://www.CraneSoftwrights.com/legal |

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.