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

Subject: RE: [xsl] Node positions with xsl:number count="" level="MULTIPLE" - AND position()
From: "Chris Bayes" <Chris@xxxxxxxxxxx>
Date: Thu, 28 Dec 2000 17:26:07 -0000
Bill,
Have a look at substring-before and substring-after

<xsl:param name="Dept" /> <!-- Dept being equal to '45.3' -->
<xsl:apply-templates
select="./agency[position()=substring-before($Dept,
'.')]/agency[position()=substring-after($Dept, '.')]">

Ciao Chris

XML/XSL Portal
http://www.bayes.co.uk/xml


>-----Original Message-----
>From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
>[mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of Bill Shaw -
>EBCX
>Sent: 28 December 2000 14:40
>To: 'xsl-list@xxxxxxxxxxxxxxxxxxxxxx'
>Subject: [xsl] Node positions with xsl:number count="" level="MULTIPLE"
>- AND position()
>
>
>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
>


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


Current Thread