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

Re: Need help with XSLT: adding new node btw existing

Subject: Re: Need help with XSLT: adding new node btw existing elements
From: "Nishi Bhonsle" <nishiandprafull@xxxxxxxxx>
Date: Thu, 17 Aug 2006 15:32:30 -0700
xslt add existing node output
I got it.
Thanks for listening.


On 8/17/06, Nishi Bhonsle <nishiandprafull@xxxxxxxxx> wrote:
Hi:
I found a way to workout the xmlns="".
Although there is one other issue,  some of the existing elements from
my input xml doc arent getting copied over. The templates work
correctly in the sense that they add the new nodes but then existing
nodes from that element dont get copied over...maybe I am missing
something in my xslt?
Can you please let me know?
The input, xslt and ouput are in this email below.

Thanks again!

On 8/17/06, Nishi Bhonsle <nishiandprafull@xxxxxxxxx> wrote:
> On 8/17/06, David Carlisle <davidc@xxxxxxxxx> wrote:
> >
> > > This sounds to me that you are using MSXML. Afaik, it is the only xslt
> > > processor that adds xmlns="" to nodes that do not belong to a
> > > namespace,
> >
> > No, every processor would do this in this example, unless it has a bug.
> >
> > David
>
> So, is there no way using xslt to avoid the addition of xmlns=" " ?
> Apparently I cant use anything external like perl to remove this
> string later from the output xml file.
>
> I also noticed that if i my input xml doc contains some additional
> elements then they get skipped in the output xml doc using my existing
> xslt. Can you please tell me what I am missing in my current xslt?
> Thanks a lot!
>
> <--Input xml doc -->
> <?xml version="1.0" encoding="UTF-8"?>
> <?xml-stylesheet type="text/xsl" href="C:\test.xslt"?>
> <test xmlns="blabla">
> <comp id="Old">
> <process-type id="ASG" module-id="TESTER1" status="enabled">
> <environment>
> <variable id="TMP" value="C:\DOCUME~1\manez\LOCALS~1\Temp"/>
> </environment>
> <start timeout="600"/>
> <stop timeout="120"/>
> </process-type>
> </comp>
> <comp id="New">
> <process-type id="home" module-id="TESTER" status="enabled">
> <module-data>
> <category id="start-parameters">
> </category>
> <category id="stop-parameters">
> </category>
> </module-data>
> <start timeout="600" retry="2"/>
> <stop timeout="120"/>
> <restart timeout="720" retry="2"/>
> <process-set id="default_group" numprocs="1"/>
> </process-type>
> </comp>
> </test>
>
> <--XSLT -- >
> <?xml version="1.0" encoding="UTF-8"?>
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:b="blabla"
> exclude-result-prefixes="b">
> <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
> <xsl:template match="node() | @*">
> <xsl:copy>
> <xsl:apply-templates select="node() | @*" />
> </xsl:copy>
> </xsl:template>
> <xsl:template match="b:process-type">
> <xsl:if test="@id='ASG'">
> <xsl:call-template name="copy"/>
> </xsl:if>
> <xsl:if test="@id='home'">
> <process-type id="home" module-id="TESTER" status="enabled">
> <environment>
> <variable id="SAROOTDIR" value="D:\Dir1"/>
> <variable id="SADATADIR" value="D:\Dir2"/>
> </environment>
> </process-type>
> </xsl:if>
> </xsl:template>
>
> <-- INTERNAL TEMPLATES -->
> <!-- create a root document, so the result is wellformed -->
> <xsl:template match="/">
> <filtered-data>
> <xsl:apply-templates/>
> </filtered-data>
> </xsl:template>
>
> <!-- copy one element with its attributes and apply templates for
> nested elements -->
> <xsl:template name="copy">
> <xsl:copy>
> <xsl:apply-templates select="@*" mode="copy" />
> <xsl:apply-templates/>
> <xsl:value-of select="text()"/>
> </xsl:copy>
> </xsl:template>
>
> <!-- copy attributes -->
> <xsl:template match="@*" mode="copy">
> <xsl:copy/>
> </xsl:template>
> </xsl:stylesheet>
>
>
> <--Output XML document -->
> <?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet type="text/xsl"
> href="C:\test.xslt"?>
> <test xmlns="blabla">
> <comp id="Old">
> <process-type id="ASG" module-id="TESTER1" status="enabled"><environment>
> <variable id="TMP" value="C:\DOCUME~1\manez\LOCALS~1\Temp"/>
> </environment><start timeout="600"/><stop timeout="120"/></process-type>
> </comp>
> <comp id="New">
> <process-type xmlns="" id="home" module-id="TESTER" status="enabled">
> <environment xmlns="">
> <variable xmlns="" id="SAROOTDIR" value="D:\Dir1"/>
> <variable xmlns="" id="SADATADIR" value="D:\Dir2"/>
> </environment>
> <!--THE OTHER ELEMENTS such as module-data DIDNOT GET PRINTED-->
> </process-type>
> </comp>
> </test>

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.