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

Re: Copying-Replacing Elements

Subject: Re: Copying-Replacing Elements
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Thu, 01 Sep 2005 17:39:15 -0400
xsl copy of replacing deep
Matt,

Your are on the right track. What you need is a "modified identity transformation", an idiom widely used in XSLT to deal with problems like yours.

At 05:43 PM 9/1/2005, you wrote:
The original node would look something like this...
<data>
        <cell id="8" flag="false">
                <name>bob</name>
                <member>5</member>
        </cell>
</data>

The output would like something like this...
<data>
        <cell id="8" flag="true">
                <name>matt</name>
        </cell>
</data>
<data>
        <cell id="8" flag="false">
                <name>bob</name>
                <member>5</member>
        </cell>
</data>

I'm thinking the xsl would look something like this
<xsl:template name="createNewSiblingMember" match="something that
returns a single node">
        <xsl:copy-of select=".">
                ...do some kind of transformations...
        </xsl:copy-of>
        <xsl:copy-of select="."/>
</xsl:template>

<xsl:template match="data"> <xsl:copy> <!-- the copy instruction copies the element, but not its attributes or children --> ...what do you want to do? add new stuff? change values of attributes or child elements? based on what rules?... </xsl:copy> <!-- the copy-of instruction "deep-copies" the node as is --> <xsl:copy-of select="."/> </xsl:template

Check out more in the FAQ at http://www.dpawson.co.uk/xsl/sect2/identity.html

Cheers,
Wendell


====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Direct Phone: 301/315-9635 Suite 207 Phone: 301/315-9631 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ======================================================================

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.