You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Christoph Hermann <ch...@guschtel.de> on 2005/10/04 11:31:26 UTC
Re: dynamic template matches
Geert Josten schrieb:
Hello,
>> [named/mode templates]
>> <xsl:template match="*">
>> <xsl:apply-templates select="xalan:evaluate($parameter_xpath)"
>> mode="{$parameter_xpath}" />
>> </...>
>>
>> and then a
>> <xsl:template match="*" mode="{$parameter_xpath}" ...>
>>
>> (untested)
>> I don't know if this works, maybe substitute the
>> mode="{$parameter_xpath}" with mode="somestring".
> No, this gets worse, actually. You cannot use parameters or expressions
> at all in a mode attribute. :-(
>
> And by replacing the expression by a string, you remove the dynamic
> element again.. :-P
Why? I mean the "xpath string" is still evaluated for a different xpath.
Or do you need every xpath to be processed differently?
If then make the difference by looking at your variable (which is static).
Or did i get sth wrong?
Christoph
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: dynamic template matches
Posted by Sandor Spruit <sa...@cs.uu.nl>.
On 4 Oct 2005, at 13:19, Geert Josten wrote:
>> What i meant was:
>> <template match="*">
>> <xsl:apply-templates select="xalan:evaluate($xpath)" mode="my-
>> xpath-mode"/>
>> </template>
>> <template match="*" mode="my-xpath-mode">
>> <choose>
>> <!-- Or any other check -->
>> <when test="contains($xpath,'sth')">
>> Do sth with nodes when the xpath contains "sth"
>> </when>
>> <otherwise>
>> Do sth else
>> </otherwise>
>> </choose>
>> </template>
>>
>
> Ah, just one mode string. Ever used this approach? With the
> evaluate in it I mean?
>
>
>> And the above example would match the xpath expression contained in
>> $xpath doesn't it? (That was the Goal i thought.)
>>
>
> Though I'm not the problem owner (so don't ask me about the
> goal ;), i think this approach with apply-templates is useful in
> only limited situations. The original posted tried to test for
> certain xpaths. That can be done with the apply-templates, somehow,
> I guess. But the one that suggested to generate an XSL had a
> different use case, in which most is copied and the xpath matching
> elements were only marked. In that case apply-templates is not that
> useful...
>
Exactly! Spot-on, said the original problem owner
still struggling to get things working as intended.
Damned, and I left this issue casually lying around
to be resolved later. If only I'd known... :(
Sandor
Sandor Spruit
sandor@cs.uu.nl
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: dynamic template matches
Posted by Geert Josten <Ge...@daidalos.nl>.
> What i meant was:
>
> <template match="*">
> <xsl:apply-templates select="xalan:evaluate($xpath)" mode="my-xpath-mode"/>
> </template>
>
> <template match="*" mode="my-xpath-mode">
> <choose>
> <!-- Or any other check -->
> <when test="contains($xpath,'sth')">
> Do sth with nodes when the xpath contains "sth"
> </when>
> <otherwise>
> Do sth else
> </otherwise>
> </choose>
> </template>
Ah, just one mode string. Ever used this approach? With the evaluate in it I mean?
> And the above example would match the xpath expression contained in
> $xpath doesn't it? (That was the Goal i thought.)
Though I'm not the problem owner (so don't ask me about the goal ;), i think this approach with
apply-templates is useful in only limited situations. The original posted tried to test for certain
xpaths. That can be done with the apply-templates, somehow, I guess. But the one that suggested to
generate an XSL had a different use case, in which most is copied and the xpath matching elements
were only marked. In that case apply-templates is not that useful...
:-P
Cheers,
Geert
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: dynamic template matches
Posted by Christoph Hermann <ch...@guschtel.de>.
Geert Josten schrieb:
Hello,
>>> No, this gets worse, actually. You cannot use parameters or expressions
>>> at all in a mode attribute. :-(
>>>
>>> And by replacing the expression by a string, you remove the dynamic
>>> element again.. :-P
>> Why? I mean the "xpath string" is still evaluated for a different xpath.
>> Or do you need every xpath to be processed differently?
>> If then make the difference by looking at your variable (which is
>> static).
> You can use a literal xpath string in a mode attribute, but you will
> have to guess which xpath expressions might occur if you want the XSL to
> be static.
>
> Next to this, you cannot use {..} inside a mode attribute, not at
> xsl:apply-templates, nor at xsl:template.
What i meant was:
<template match="*">
<xsl:apply-templates select="xalan:evaluate($xpath)" mode="my-xpath-mode"/>
</template>
<template match="*" mode="my-xpath-mode">
<choose>
<!-- Or any other check -->
<when test="contains($xpath,'sth')">
Do sth with nodes when the xpath contains "sth"
</when>
<otherwise>
Do sth else
</otherwise>
</choose>
</template>
> You could use your method in a generated XSL, though, but then are you
> making things more difficult than necessary.. :-P
And the above example would match the xpath expression contained in
$xpath doesn't it? (That was the Goal i thought.)
Christoph
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: dynamic template matches
Posted by Geert Josten <Ge...@daidalos.nl>.
>>No, this gets worse, actually. You cannot use parameters or expressions
>>at all in a mode attribute. :-(
>>
>>And by replacing the expression by a string, you remove the dynamic
>>element again.. :-P
>
>
> Why? I mean the "xpath string" is still evaluated for a different xpath.
> Or do you need every xpath to be processed differently?
> If then make the difference by looking at your variable (which is static).
>
> Or did i get sth wrong?
> Christoph
I'm not sure I understand what you are trying to say, so I'll just explain the problems a bit further.
You can use a literal xpath string in a mode attribute, but you will have to guess which xpath
expressions might occur if you want the XSL to be static.
Next to this, you cannot use {..} inside a mode attribute, not at xsl:apply-templates, nor at
xsl:template.
You could use your method in a generated XSL, though, but then are you making things more difficult
than necessary.. :-P
Cheers,
Geert
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org