|
Subject: Re: [xsl] putting all the elements with a given name one level up From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx> Date: Mon, 28 Jun 2004 19:54:22 -0400 |
I have this xml: ... And I want to transform it to this one: (The difference is that all the ccc elements, and it's children are removed from the location where they are and putted below the root element)
T:\ftemp>type pedro.xml
<root>
<aaa>
<bbb/>
<ccc/>
<bbb/>
</aaa>
<aaa>
<ccc>
<abc>test</abc>
</ccc>
<bbb/>
<bbb/>
</aaa>
</root>T:\ftemp>type pedro.xsl <?xml version="1.0" encoding="iso-8859-1"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="root">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
<xsl:copy-of select="//ccc"/><!--collect all ccc elements-->
</xsl:copy>
</xsl:template><xsl:template match="@*|node()"><!--identity for all other nodes-->
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template><!--this cleans up the output when using indent="yes"--> <xsl:template match="text()[not(normalize-space())]"/>
</xsl:stylesheet>
T:\ftemp>saxon pedro.xml pedro.xsl
<?xml version="1.0" encoding="utf-8"?>
<root>
<aaa>
<bbb/>
<bbb/>
</aaa>
<aaa>
<bbb/>
<bbb/>
</aaa>
<ccc/>
<ccc></ccc> </root> T:\ftemp>
-- Public training 3 days XSLT & 2 days XSL-FO: Phoenix,AZ 2004-08-23 World-wide on-site corporate, govt. & user group XML/XSL training. G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (F:-0995) Male Breast Cancer Awareness http://www.CraneSoftwrights.com/s/bc Legal business disclaimers: http://www.CraneSoftwrights.com/legal
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| putting all the elements with a giv, Pedro Castro | Thread | RE: [xsl] putting all the elements , Pedro Castro |
| putting all the elements with a giv, Pedro Castro | Date | RE: [xsl] putting all the elements , Pedro Castro |
| Month |