cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joerg Heinicke <joerg.heini...@gmx.de>
Subject Re: dynamic node selection
Date Thu, 24 Jul 2003 01:26:53 GMT
Hello Adam,

> My apologies for the lack of clarity. I was trying to use the value I have
> calcualted for the $targetNode variable to select a node in my XML document.
> 
> If I had an xml source like the following, I would like to be able to
> 'dynamically' select nodes for processing.

...

> The xslt template to do the processing:
> 
> <xsl:template name="createOptionList">
>    <xsl:param name="parentNode" select="string()" />
>    <xsl:param name="childNode" select="string()" />
> 
>    <xsl:variable 
>         name="targetNode" 
>         select="concat(name($listNode),'/',$listItem)" />
> 
>    <xsl:for-each select="$targetNode" >
>        ... do the processing ....
>    </xsl:for-each>
> </xsl:template>

if you know the path as exact as above (i.e. step by step) you can 
simply do something like

<xsl:for-each select="*[name() = $listNode]/*[name() = $listItem]">

> For example if parameters parentNode = "foo" and childNode = "bar", then
> $targetNode would evaluate to the string "foo/bar". I would want the 'for-each'
> statement to select all the "bar" nodes under the "foo" parent node.
> 
> I think the only step I am missing is how to write a xpath node selection query
> that can take a string parameter as its argument.

If you want to evaluate more complex XPathes and can't find a work 
around the are processor specific extension functions like 
http://xml.apache.org/xalan-j/extensionslib.html#evaluate or a bit more 
common http://www.exslt.org/dyn/functions/evaluate/index.html.

Regards,

Joerg


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


Mime
View raw message