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

RE: Question about xpath

Subject: RE: Question about xpath
From: Mike Brown <mbrown@xxxxxxxxxxxxx>
Date: Thu, 7 Oct 1999 10:19:19 -0600
xpath underscore
There are a few things wrong with your stylesheet.

<xsl:variable name="view" select="document('views.xml')/view[@name='my
view']"/>

By using the '@' you are implying that name is an attribute of view. But in
your XML, it is a child element. Use
select="document('views.xml')/view[name='my view']" (or, for clarity,
[./name='my view'] )

Replace the hyphen in $current-contract with an underscore. Hyphens are not
allowed in variable names.

Because one of your view columns is 'stock/name', you'll need to handle that
case specially. You can assign the string 'stock/name' to a variable, but
you can't use that in an XPath expression as if it were a node-set. You also
need to pick the child element of contract with the same name as the view
column. So, replace this:

  <xsl:for-each select="$view/column">
    <xsl:value-of select="$current-contract/text()"/>
  </xsl:for-each>

With this:

  <xsl:for-each select="$view/column">
      <xsl:variable name="current_column" select="."/>
      <xsl:choose>
          <xsl:when test=".='stock/name'">
              <xsl:value-of select="$current_contract/stock/name"/>
          </xsl:when>
          <xsl:otherwise>
              <xsl:value-of
select="$current_contract/*[name(.)=$current_column]"/>
          </xsl:otherwise>
      </xsl:choose>
   </xsl:for-each>

If that's not the exact solution, it should be pretty close.


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


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.