RE: Question about xpath

Subject: RE: Question about xpath
From: Kay Michael <Michael.Kay@xxxxxxx>
Date: Thu, 7 Oct 1999 17:32:52 +0100
Try something like:

>    <xsl:for-each select="contract">
>         <xsl:variable name="current-contract" select="."/>
>         <xsl:for-each select="*[$view/column=name()]">
>             <xsl:value-of select="$current-contract"/>
>         </xsl:for-each>
>    </xsl:for-each>

(not tested.)
Mike Kay

> I want to edit a portfolio page with mulitple views.
> My views definition is stored in an xml file:
> 
> <view>
>     <name>my view</name>
>     <column>stock/name</column>
>     <column>quantity</column>
>     <column>price</column>
> </view>
> <view>
>     <name>another view</name>
>     .....
> </view>
> 
> where the "<columns>" define which column I want to select.
> and my portfolio xml looks like:
> 
> <portfolio>
>      <contract>
>         <stock>
>             <name>Red Pat</name>
>                ...
>         </stock>
>         <quantity>1000</quantity>
>         <price>20</price>
>     </contract>
>     <contract>
>         ....
>     </contract>
> </portfolio>
> 
> The question is : Can I use xsl to apply the views? If so, how?
> I have considered something like
> 
> <xsl:template match="portfolio">
>    <xsl:variable name="view"
> select="document('views.xml')/view[@name='my view']"/>
>    <xsl:for-each select="contract">
>          <xsl:variable name="current-contract" select="self::node()"/>
>         <xsl:for-each select="$view/column">
>             <xsl:value-of select="$current-contract/text()"/>
>         </xsl:for-each>
>    </xsl:for-each>
> </xsl:template>
> 
> and of course it doesn't work.:<
> 
> Thx a lot
> Daniel
> 
> 
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> 


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


Current Thread