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

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

Subject: RE: 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)
2006 mail name offset ltd
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

PURCHASE STYLUS STUDIO ONLINE TODAY!

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