|
Subject: RE: Question about xpath From: Mike Brown <mbrown@xxxxxxxxxxxxx> Date: Thu, 7 Oct 1999 10:19:19 -0600 |
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 |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: Question about xpath, Zvi Avraham | Thread | RE: Question about xpath, Kay Michael |
| :IE5 and XML/XSL together, Barnes Steve J | Date | RE: Question about xpath, Kay Michael |
| Month |