You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Christian Barth <co...@barth-zone.de> on 2006/01/18 19:20:37 UTC

How to asign a value to a variable??

Hi!
 
I want to define a global variable with no value.
 
Then I want to asign a value to the variable in a choose-when-select.
 
I think of something like this (but this one doesn't work):
 
<xsl:variable name="element" />

    <xsl:for-each select="*">

        <xsl:choose>

            <xsl:when test="local-name() = 'rettungswege'">

                <xsl:variable name="element" select="rettungswege/rw" />

            </xsl:when>

            <xsl:when test="local-name() = 'trennwaende'">

                <xsl:variable name="element" select="trennwaende/trennwand"
/>

            </xsl:when>

        </xsl:choose>

    </xsl:for-each> 

<xsl:for-each select="$element">

    ...do something...

</xsl:for-each> 

 

Is this possible?

 

Thanks,

Barthi


Re: How to asign a value to a variable??

Posted by Jason Johnston <co...@lojjic.net>.
> Hi!
>
> I want to define a global variable with no value.
>
> Then I want to asign a value to the variable in a choose-when-select.
>
> I think of something like this (but this one doesn't work):
>
> <xsl:variable name="element" />
>
>     <xsl:for-each select="*">
>
>         <xsl:choose>
>
>             <xsl:when test="local-name() = 'rettungswege'">
>
>                 <xsl:variable name="element" select="rettungswege/rw" />
>
>             </xsl:when>
>
>             <xsl:when test="local-name() = 'trennwaende'">
>
>                 <xsl:variable name="element"
> select="trennwaende/trennwand"
> />
>
>             </xsl:when>
>
>         </xsl:choose>
>
>     </xsl:for-each>
>
> <xsl:for-each select="$element">
>
>     ...do something...
>
> </xsl:for-each>
>
>
>
> Is this possible?
>


Nope, sorry!

"Variables" in XSLT aren't reassignable, so once you create a variable its
value is set.  In this way the term "variable" is a bit of a misnomer.

There are probably other ways besides reassigning variables to accomplish
what you're trying to do though.  Your best bet would be to post to an
XSLT-related mailing list as that's where you're going to find the most
experts able and willing to help you out.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: How to asign a value to a variable??

Posted by Geert Josten <Ge...@daidalos.nl>.
What are you trying to achieve?

Christian Barth wrote:
> Hi!
>  
> I want to define a global variable with no value.
>  
> Then I want to asign a value to the variable in a choose-when-select.
>  
> I think of something like this (but this one doesn't work):
>  
> 
> <xsl:variable name="element" />
> 
>     <xsl:for-each select="*">
> 
>         <xsl:choose>
> 
>             <xsl:when test="local-name() = 'rettungswege'">
> 
>                 <xsl:variable name="element" select="rettungswege/rw" />
> 
>             </xsl:when>
> 
>             <xsl:when test="local-name() = 'trennwaende'">
> 
>                 <xsl:variable name="element" 
> select="trennwaende/trennwand" />
> 
>             </xsl:when>
> 
>         </xsl:choose>
> 
>     </xsl:for-each>
> 
> <xsl:for-each select="$element">
> 
>     ...do something...
> 
> </xsl:for-each>
> 
>  
> 
> Is this possible?
> 
>  
> 
> Thanks,
> 
> Barthi
> 

-- 
Drs. G.P.H. Josten
Consultant



Daidalos BV
Source of Innovation
Hoekeindsehof 1-4
2665  JZ  Bleiswijk
Tel: +31 (0) 10 850 1200
Fax: +31 (0) 10 850 1199
www.daidalos.nl


De informatie - verzonden in of met dit emailbericht - is afkomstig van Daidalos BV en is 
uitsluitend bestemd voor de geadresseerde. Indien u dit bericht onbedoeld hebt ontvangen, verzoeken 
wij u het te verwijderen. Aan dit bericht kunnen geen rechten worden ontleend.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


How to process Dom Object from Form Binding

Posted by Pe...@gmx.net.
Hello,

I would like to further process the xml data from my cform in another 
pipeline. I saw in the samples that it's possible to build a 
dom object. But I saw the tree is directly written to file. 
I my case I need to further process the data so I don't want to do an file
operation. How can I do that? 

The code I'm refering to is below:

var doc =
Packages.javax.xml.parsers.DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
    doc.appendChild(doc.createElement("project"));
    form.createBinding("bind.xml");
    form.save(doc);

 cocoon.sendPage("some-pipeline-for-postprocessing-xml",
        {, document: doc}

cheers,
Pete

-- 
Lust, ein paar Euro nebenbei zu verdienen? Ohne Kosten, ohne Risiko!
Satte Provisionen f�r GMX Partner: http://www.gmx.net/de/go/partner

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


RE: How to asign a value to a variable??

Posted by Andrew Stevens <at...@hotmail.com>.
>From: "Christian Barth" <co...@barth-zone.de>
>Date: Wed, 18 Jan 2006 19:20:37 +0100
>
>Hi!
>
>I want to define a global variable with no value.
>
>Then I want to asign a value to the variable in a choose-when-select.
>
>I think of something like this (but this one doesn't work):
>
><xsl:variable name="element" />
>     <xsl:for-each select="*">
>         <xsl:choose>
>             <xsl:when test="local-name() = 'rettungswege'">
>                 <xsl:variable name="element" select="rettungswege/rw" />
>             </xsl:when>
>             <xsl:when test="local-name() = 'trennwaende'">
>                 <xsl:variable name="element" 
>select="trennwaende/trennwand"
>/>
>             </xsl:when>
>         </xsl:choose>
>     </xsl:for-each>
><xsl:for-each select="$element">
>     ...do something...
></xsl:for-each>
>
>Is this possible?

No, because that's not how variables work in XSL.  Once they're assigned 
they're visible at that level and below, and you can't change them.  You 
have to use something structured more like

<p>Try visiting<ul>
<xsl:for-each select="tutorial">
<xsl:variable name="foo">
<xsl:choose>
<xsl:when test="@id = '1'>
http://www.topxml.com/xsl/tutorials/intro/default.asp
</xsl:when>
<xsl:when test="@id = '2'>
http://en.wikipedia.org/wiki/XSLT
</xsl:when>
<xsl:otherwise>
http://www.jenitennison.com/xslt/
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<li><xsl:value-of select="$foo"/></li>
</xsl:for-each>
</ul></p>

This isn't really a Cocoon issue, though, and there are plenty of dedicated 
XSL sites and mailing lists...


Andrew.



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org