[xsl] checking for a node in the ancestor axis

Subject: [xsl] checking for a node in the ancestor axis
From: "Murali Korrapati" <murali.korrapati@xxxxxxxxx>
Date: Tue, 21 Oct 2003 21:23:39 -0400

   I have a situation here, where I have to check for the node in the ancestor axis. I tried setting a flag depending upon _Ctrl node into a xsl:variable and checking 
for that variable later. But it doesn't seem like working. 

	<xsl:if test="$CtrlExists='1'"> in the following code is always turning out false

But I can't do <xsl:if test="../../_Ctrl">, b'cos my xml inside <Rpt_Inven> varies all the time.

I am sure there is a better way to do this. But I couldn't  get to it. Is there any proper way to do this.

Thanks a lot.

my xml:
<data xmlns="urn:abcd:layers">
	<Rpt_Inven xmlns="urn:abcd:RepInven">
	<!-- This node is optional. Doesn't exists all the time -->
	<_Ctrl xmlns="" xmlns:lay="urn:abcd:layers"  xmlns:rep="urn:abcd:RepInven" xmlns:obj="urn:abcd:objects">
			<_Col name="Entity"/>

my xsl:

<xsl:stylesheet version="1.0" xmlns="" xmlns:lay="urn:abcd:layers" xmlns:rep="urn:abcd:RepInven" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
	<xsl:output method="xml" encoding="UTF-8"/>
	<xsl:template match="lay:data">
		<xsl:variable name="CtrlExists">
				<xsl:when test="_Ctrl">
					<xsl:value-of select="'1'"/>
					<xsl:value-of select="'0'"/>
			<xsl:for-each select="rep:Rpt_Inven/rep:Invens">
					<_Col name="Entity">
						<xsl:if test="$CtrlExists='1'">
							<xsl:for-each select="rep:Inven/rep:Entity">
								<xsl:sort select="."/>
									<xsl:value-of select="."/>

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

Current Thread