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

XSL ver. 2 to copy, replace, and insert new node

Subject: XSL ver. 2 to copy, replace, and insert new node
From: Henry Dong <henryb.dong@xxxxxxxxx>
Date: Fri, 18 Jun 2010 12:48:39 -0700
 XSL ver. 2 to copy
  I'm not sure how to complete my XSL using XSL 2.0 to copy, replace,
and insert a new node.  Your help will be greatly appreciated.  Thank

 I have a xml that look like below

      <one> test1 </one>
      <two> test2 </two>
          <aaa> test3 </aaa>
              <data>test4 </data>

I want to copy my XML to a new XML with a few changes.
     If <one> or <aaa> is there, I want to replace it with a new value
     If <bbb> is there, I want to replace the sub node <data> value
with a new value
     If <bbb> or <ddd> is NOT there, I want to insert <bbb> between
<aaa> and <ccc>, and add a new node <ddd> below the <ccc> based on my schema

Here is my incompleted or incorrect XSL file,
<xsl:output method="xml" encoding="utf-8" indent="yes"/>
    <xsl:template match="@*|node()" />
          <xsl:apply-templates select="@*|node()"/>
    <xsl:template mach="group">
            <xsl:apply-templates select="@*|node()" />
                  <xsl:when test="not(b)">
                  <xsl:when test="b">
                  <xsl:when test ="not(d)">
                       <xsl:element name="d"> test6</xsl:element>
                  <xsl:when test="d">
                         <xsl:text>test6 </xsl:text>

The result I would like to get is

     <one> new value 1 </one>
     <two> test2 </two>
          <aaa> new value 2 </aaa>
                  <data> new value 3 </data>
             <ddd> new value 4 </ddd>


Current Thread


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.
First Name
Last Name
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.