|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Question about xpath
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
|
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








