[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
On 8/17/06, David Carlisle <davidc@xxxxxxxxx> wrote:
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>
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|