RE: [xsl] Is it possible to modify the source-tree?

Subject: RE: [xsl] Is it possible to modify the source-tree?
From: "Agnisys Technology \(P\) Ltd." <agnisys@xxxxxxxxx>
Date: Tue, 13 Sep 2005 12:24:44 -0700 (PDT)
Appreciate the responses. I'm using 2.0 so I'll ignore xx:node-set().
I'm still a little fuzzy, since I can't get the node to "stich" into the variable tree. Once
again,
Input is :
<a>
    <b offset="5">
         <reg>reg_1</reg>
        <reg>reg_2</reg>
        <reg href="REGDEF1"></reg>
         <reg>reg_3</reg>
     </b>
  
    <regdef name="REGDEF1">
          <reg>reg_10</reg>
         <reg>reg_20</reg>
     </regdef>
 </a>
  
XSLT is :
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; version="2.0">

    <xsl:template match="*">
        <xsl:copy>
            <xsl:copy-of select="@*"/>
            <xsl:apply-templates/>
        </xsl:copy>
    </xsl:template>
    
    <xsl:template match="reg[@href]">
        <xsl:variable name="reg_href">
            <xsl:copy-of select="//regdef[@name=current()/@href]"/>
        </xsl:variable>
        <xsl:apply-templates select="$reg_href/*"/>
    </xsl:template>
    
    <xsl:template match="regdef"/>
    
    <xsl:template match="reg">
        <br/>Register : <xsl:value-of select="."/>
        Offset = <xsl:value-of select="../@offset"/>
        Prev-Sibling count = <xsl:value-of select="count(preceding-sibling::reg)"/>
    </xsl:template>

</xsl:stylesheet>

Output is : 

Register : reg_1 Offset = 5 Prev-Sibling count = 0 
Register : reg_2 Offset = 5 Prev-Sibling count = 1 
Register : reg_3 Offset = 5 Prev-Sibling count = 3 

I want the output to say:
Register : reg_1 Offset = 5 Prev-Sibling count = 0 
Register : reg_2 Offset = 5 Prev-Sibling count = 1 
Register : reg_10 Offset = 5 Prev-Sibling count = 2 
Register : reg_20 Offset = 5 Prev-Sibling count = 3 
Register : reg_3 Offset = 5 Prev-Sibling count = 4 

Thanks,
Anupam.

P.S. Jay, this is similar to the problem you helped me solve couple of weeks ago, but the
difference here is the need to acccess the parent attributes and sibling information.




		
__________________________________ 
Yahoo! Mail - PC Magazine Editors' Choice 2005 
http://mail.yahoo.com

Current Thread