[xsl] Node positions with xsl:number count="" level="MULTIPLE" - AND po sition()

Subject: [xsl] Node positions with xsl:number count="" level="MULTIPLE" - AND po sition()
From: Bill Shaw - EBCX <BillShaw@xxxxxxxxxxxxxxxxx>
Date: Thu, 28 Dec 2000 07:39:43 -0700
I have an XML with a similar structure:
<root>
<dept>

<agency>
	<agency>
	</agency>
	<agency>
	</agency>
	<agency>
	</agency>
</agency>
<agency>
	<agency>
	</agency>
	<agency>
	</agency>
	<agency>
	</agency>
</agency>   ....... and so on

</dept>
</root>

When I need to access a particular "sub" agency within a certain "parent"
agency, I need the count of the parent agency and the count of the child
agency.  I have been able to get the count using <xsl:number count="agency"
level="multiple"/> ... so say I am on the 45th parent agency node and 3rd
child agency node, the count returns 45.3 (which is exactly what I need).
Now my problem is using the 45.3 in my second style sheet to get to child 3
of the 45th parent node.  In my second style sheet where I try to use the
count produced by the first style sheet, I have the following partial code:

<xsl:apply-templates
select="./agency[position()=$mainDept]/agency[position()=$subDept]">

I am currently breaking the string apart in VB and passing them in as params
which is working but I feel sure there is an easier XSL way (which I stumped
to find so far).


Below is an abbreviated sample of the 1st stylesheet getting the count:

<xsl:template match="agency">
	<xsl:choose>
		<xsl:when test="ancestor::agency">
			<a class="sub"><xsl:attribute
name="href">/deptmap.asp?link=<xsl:number count="agency"
level="multiple"/></xsl:attribute><xsl:apply-templates select="display[@lang
= $language]"/></a><br/>&#xD;
		</xsl:when>
		<xsl:otherwise>	
			<a class="main"><xsl:attribute
name="href">/deptmap.asp?link=<xsl:number
count="agency"/></xsl:attribute><xsl:apply-templates select="display[@lang =
$language]"/></a><br/>&#xD;
		</xsl:otherwise>
	</xsl:choose>
</xsl:template>	


Any and all help is greatly appreciated!

Sincerely,
 
Bill Shaw
301 W. Jefferson, Suite 400
Phoenix, AZ 85003-2157
ph:  602-506-7919
fax: 602-506-5864
 
<http://www.maricopa.gov>

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


Current Thread