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=""; version="2.0">
<xsl:output indent="yes"/>
<xsl:template match="node()">
<xsl:variable name="children" as="node()*">
<xsl:sequence select="@*"/>
<xsl:sequence select="($children/@a)[1]"/>
<xsl:sequence select="$children"/>

with input

<?xml version="1.0" encoding="UTF-8"?>
       <z a="1" b="1"/>
       <z a="2" c="2"/>

gives output

<?xml version="1.0" encoding="UTF-8"?>
<x a="1">
   <y a="1">
       <z a="1" b="1"/>
   <y a="2">
       <z a="2" c="2"/>

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