Subject: Re: [xsl] problem with Xpath in Variable filled by choose From: David Carlisle <davidc@xxxxxxxxx> Date: Wed, 16 Nov 2005 16:48:08 GMT |
<xsl:variable name="CategoryPointer"> <xsl:choose> <xsl:when test="$category = 'main'"> <xsl:copy-of select="document('style.xml')/root/DeviceParameters/DesignMood/Category/main "/> </xsl:when> Note that's a relatively expensive way of setting things up as it imples _copying_ the selected tree. If xsl:variiabel is used with no as= attribute it always generates a new tree with a new document node (/) In this case the child of / will be either a main element or a news element depending on the test. So this <xsl:value-of select="$CategoryPointer/HeadlineColor"/> will never select anything as the child of $CategoryPointer is never a HeadlineColor element. It is either a main element (from the first branch) or a text node (from the second branch) I suspect you actually just want the variable to refererence in to nodes in your input tree rather than to copies, so: <xsl:variable name="CategoryPointer" as="element()"> <xsl:choose> <xsl:when test="$category = 'main'"> <xsl:sequence select="document('style.xml')/root/DeviceParameters/DesignMood/Category/main "/> </xsl:when> <xsl:when test="$category = 'news'"> <xsl:sequence select="document('style.xml')/root/DeviceParameters/DesignMood/Category/news "/> </xsl:when> </xsl:choose> </xsl:variable> or equivalently the less verbose form: <xsl:variable name="CategoryPointer" select="document('style.xml')/root/DeviceParameters/DesignMood/Category/*[name()=$category]"/> David ________________________________________________________________________ This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] problem with Xpath in Variabl, Dietmar Klotz | Thread | AW: [xsl] problem with Xpath in Var, Dietmar Klotz |
[xsl] problem with Xpath in Variabl, Dietmar Klotz | Date | AW: [xsl] problem with Xpath in Var, Dietmar Klotz |
Month |