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

Re: (How) can I randomly access the result of a <xsl

Subject: Re: (How) can I randomly access the result of a <xsl:for-each select="...?
From: Ferdinand Soethe <xsl-list@xxxxxxxxxx>
Date: Sat, 15 Oct 2005 09:09:50 +0200
Re:  (How) can I randomly access the result of a   <xsl
Thanks everybody for your quick responses. I'm one major step closer
to my goals now.

Yet I seem to be missing something in this part if Michaels code:

> First, you put the result in a variable:

> <xsl:variable name="x">
>   <xsl:for-each select=...
>     <something/>
>   </xsl:for-each>
> </xsl:variable>

Still XSLT 1.0:

If I do

 <xsl:variable name="fragment" select="//ul"/>

(not using a for-each) everything works fine and I can cast the
variable to a nodeset and access it as documented.

However if I try

<xsl:variable name="fragment">
    <xsl:for-each select="//ul">
        <xsl:copy-of select="."/>
    </xsl:for-each>
</xsl:variable>

or

<xsl:variable name="fragment">
    <xsl:for-each select="//ul">
        <xsl:value-of select="."/>
    </xsl:for-each>
</xsl:variable>


I only get a count() of 1 when transforming this test-document:

<?xml version="1.0" encoding="UTF-8"?>
<html>
    <head></head>
    <body>
        <ul id="1">
            <li id="11">Listenpunkt 11</li>
            <li id="12">Listenpunkt 12</li>
            <li id="13">Listenpunkt 13</li>
            <li id="14">Listenpunkt 14</li>
        </ul>  
        <ul id="2">
            <li id="21">Listenpunkt 21</li>
            <li id="22">Listenpunkt 22</li>
            <li id="23">Listenpunkt 23</li>
            <li id="24">Listenpunkt 24</li>
        </ul>    
        <ul id="3">
            <li id="31">Listenpunkt 31</li>
            <li id="32">Listenpunkt 32</li>
            <li id="33">Listenpunkt 33</li>
            <li id="34">Listenpunkt 34</li>
        </ul>    
    </body>
</html>

Any ideas what I got wrong here?

--
Ferdinand Soethe

(Btw: Xalan seems to also support the common:node-set function from
 the xmlns:common="http://exslt.org/common" namespace, so I used that
 for portability)

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.