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

Re: Concatenating the attribute values of ancestors

Subject: Re: Concatenating the attribute values of ancestors
From: Mukul Gandhi <mukul_gandhi@xxxxxxxxx>
Date: Fri, 8 Jul 2005 00:55:55 -0700 (PDT)
xsl concatenating
Probably some sort of following logic is required..
Please be beware, this is not tested.

<?xml version="1.0" encoding="UTF-8"?>

<xsl:output method="xml" indent="yes" />
<xsl:template match="node() | @*" priority="5">
    <xsl:apply-templates select="node() | @*" />
<xsl:template match="*" priority="6">
      <xsl:apply-templates select="@*" />
      <xsl:attribute name="newSeq">
           <xsl:with-param name="attr_value"
select="''" />
           <xsl:with-param name="anestors"
select="ancestor::*" />
<xsl:template name="concatenate-ancestor-attributes">
    <xsl:param name="attr_value" />
    <xsl:param name="ancestors" />
      <xsl:when test="parent::*">
	  <xsl:with-param name="attr_value"
select="concat($attr_value, parent::*/@seq)" />
	  <xsl:with-param name="anestors"
select="ancestor::*" />
        <xsl:value-of select="$attr_value" />


--- Lakshmi narayana <lchintala@xxxxxxxxxxxx> wrote:

> Hi
> I want a template which adds the attribute values of
> its ancestors and
> create an attribute to the current
> node. The value to this attribute is the result of
> conactination of all the
> node values added of its parents.
> For example,
> <A seq="1">
> 	<B seq="2" />
> 	<C seq="3">
> 		<D seq="4" />
> 	</C>
> </A>
> In the above xml, I want to concatenate all the seq
> values of all ancestors
> and its seq value also. And add new attribute
> to the current node as newSeq with the result
> concatenated value.
> Note : if seq attribute is not there concatenate
> value "0".
> Output should look like this.
> <A seq="1" newSeq="1">
> 	<B seq="2" newSeq="12"/>
> 	<C seq="3" newSeq="13">
> 		<D seq="4"  newSeq="134"/>
> 	</C>
> 	<E  newSeq="10">
> 		<F seq="5"  newSeq="105"/>
> 	</E>
> </A>
> Thanks
> Laxmi Narayana

Sell on Yahoo! Auctions  no fees. Bid on great items.  

Current Thread


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.
First Name
Last Name
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.