[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

AW: problem with Xpath in Variable filled by choose

Subject: AW: problem with Xpath in Variable filled by choose
From: "Dietmar Klotz" <dklotz@xxxxxxxxxxx>
Date: Wed, 16 Nov 2005 18:51:32 +0100
xpath choose
I am not sure if i understand the concept fully. If I follow your advice my
output of: <xsl:copy-of select="$CategoryPointer"/>

Is than this:
		<news xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
                    <HeadlineColor>#ff0000</HeadlineColor>
                    <TeaserColor>#00ff00</TeaserColor>
                    <TeaserColorSub>#0000ff</TeaserColorSub>
                </news> 

But if I do:
<xsl:copy-of select="$CategoryPointer/HeadlineColor"/>

I don't get anything but I want to have this output:
#ff0000

Thanks for your answer also I didn't understand fully it helped already :)

Didi

-----Urspr|ngliche Nachricht-----
Von: David Carlisle [mailto:davidc@xxxxxxxxx]
Gesendet: Mittwoch, 16. November 2005 17:48
An: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Betreff: Re:  problem with Xpath in Variable filled by choose



  <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/*[na
me()=$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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.