[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
--On Wednesday, November 14, 2007 04:28:09 PM +0530 Raghu Narayan Koratagere wrote:
Is this the sort of thing you mean? Note that this is an XSLT2 transform:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:output indent="yes"/>
<xsl:template match="node()">
<xsl:variable name="children" as="node()*">
<xsl:apply-templates/>
</xsl:variable>
<xsl:copy>
<xsl:sequence select="@*"/>
<xsl:sequence select="($children/@a)[1]"/>
<xsl:sequence select="$children"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
with input
gives output
Re: [xsl] XSL support of Bottom up transformations?
Subject: Re: [xsl] XSL support of Bottom up transformations? From: Owen Rees <owen.rees@xxxxxx> Date: Wed, 14 Nov 2007 12:44:39 +0000 |
--On Wednesday, November 14, 2007 04:28:09 PM +0530 Raghu Narayan Koratagere wrote:
I have specific business requirement where I need to transform the source tree bottom up. The reason being certain attribute of the parent node gets its value from a similarly caluclated child node. i.e I need to calculate a derived attribute of a child node before I can calculate the parent node's attribtue.
Is such a requirement be addressed using XSL? If yes any pointers will be very helpful.
Is this the sort of thing you mean? Note that this is an XSLT2 transform:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:output indent="yes"/>
<xsl:template match="node()">
<xsl:variable name="children" as="node()*">
<xsl:apply-templates/>
</xsl:variable>
<xsl:copy>
<xsl:sequence select="@*"/>
<xsl:sequence select="($children/@a)[1]"/>
<xsl:sequence select="$children"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
with input
<?xml version="1.0" encoding="UTF-8"?> <x> <y> <z a="1" b="1"/> </y> <y> <z a="2" c="2"/> </y> </x>
gives output
<?xml version="1.0" encoding="UTF-8"?> <x a="1"> <y a="1"> <z a="1" b="1"/> </y> <y a="2"> <z a="2" c="2"/> </y> </x>
-- Owen Rees; speaking personally, and not on behalf of HP. ======================================================== Hewlett-Packard Limited. Registered No: 690597 England Registered Office: Cain Road, Bracknell, Berks RG12 1HN
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] XSL support of Bottom up , Michael Kay | Thread | [xsl] Split Strings with multiple s, Alice Ju-Hsuan Wei |
Re: [xsl] Template matching precedi, Ilya Konanykhin | Date | [xsl] Split Strings with multiple s, Alice Ju-Hsuan Wei |
Month |