[xsl] Controlling ancestor reference in the result tree

Subject: [xsl] Controlling ancestor reference in the result tree
From: "Roshan Sharma" <roshansharma@xxxxxxxxxxx>
Date: Mon, 12 Mar 2001 07:32:48
While traversing thru the locations in xml below, I have 2 questions:
Q 1: How do I get the value of the attr named "name" of the ancestor
Q 2: I recursively call apply-templates for every office locations and
    want to print customer node info only once.

    The attempt to control with var $did_i_print=1 and marking it "0"
    failed.

I would like to print out the report only if the customer node has
child element office as:

test.xml

<customer name="big_one" revenue="100000000" employees="20000" >
 <office location="uno" revenue="200000" rent="3000" />
 <office location="dos" revenue="300000" rent="2000" />
</customer>
<customer name="little_one" revenue="30000" employees="1" />

test.xsl:

<xsl:variable name="did_i_print" select="1" />
<xsl:template name="blah" match="office" >
 <xsl:if test="contains(name(..),'customer') and ($did_i_print=1)" >
   <xsl:value-of select="name[name(..)]" />    <---- Q 1
                                               <---- Q 2
   <xsl:variable name="did_i_print" select="0" />

... processing for office ...

desired output:
Customer big_one
Total Rev 1000000000, # of employees 20000
  location uno
     revenue   20000
     rent      3000
  location dos
     revenue   30000
     rent      2000






_________________________________________________________________ Get your FREE download of MSN Explorer at http://explorer.msn.com


XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list



Current Thread