|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] checking for a node in the ancestor axis
Hi, 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"> <Invens> <Inven> <Entity>Ent1</Entity> </Inven> <Inven> <Entity>Ent2</Entity> </Inven> <Inven> <Entity>Ent3</Entity> </Inven> </Invens> </Rpt_Inven> <!-- 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"> <_Table> <_Col name="Entity"/> </_Table> </_Ctrl> </data> 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:choose> <xsl:when test="_Ctrl"> <xsl:value-of select="'1'"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="'0'"/> </xsl:otherwise> </xsl:choose> </xsl:variable> <_Ctrl> <xsl:for-each select="rep:Rpt_Inven/rep:Invens"> <_Table> <_Col name="Entity"> <xsl:if test="$CtrlExists='1'"> <xsl:for-each select="rep:Inven/rep:Entity"> <xsl:sort select="."/> <_Item> <xsl:value-of select="."/> </_Item> </xsl:for-each> </xsl:if> </_Col> </_Table> </xsl:for-each> </_Ctrl> </xsl:template> </xsl:stylesheet> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








