Subject: Re: Re: dynamic template caller problems
From: Smoother@xxxxxx
Date: Sun, 30 Jul 2006 22:32:22 +0200
|
Thanks for your replies.
Based upon the idea from http://archive.gingerall.cz/archives/public/sablot2002/msg00925.html, I wrote the following:
XML-file:
===============================================
<?xml version='1.0' encoding='utf-8'?>
<root>
<page1 template="single" />
<page2 template="double" />
<page3 template="single" />
<page4 template="float" />
<page5 template="double" />
<page6 template="double" />
</root>
XSL-File:
===============================================
...
<xsl:template match="/">
<!-- simplifies REQUEST_URI: "/a(/)" -> "a" -->
<xsl:variable name="REQUEST_URI" select="translate($REQUEST_URI,'/ ','')" />
<!--<xsl:copy-of select="$REQUEST_URI" />-->
<!-- get "template" -->
<xsl:variable name="template" select="dyn:evaluate(concat('/root/',$REQUEST_URI,'/@template'))" />
<!--<xsl:copy-of select="$template" />-->
<!-- apply related template -->
<xsl:apply-templates select="dyn:evaluate(concat('//',$REQUEST_URI))" />
</xsl:template>
<xsl:template match="*[@template='single']">
<p>single template selected</p>
</xsl:template>
<xsl:template match="*[@template='float']">
<p>float template selected</p>
</xsl:template>
<xsl:template match="*[@template='double']">
<p>double template selected</p>
</xsl:template>
...
I haven't tried yet, to access the node related to the selected template from inside (=from inside of the selected template), but I'm confident of this.
Cheers, S.R.
-------- Original-Nachricht --------
Datum: Sun, 30 Jul 2006 21:23:11 +0100
Von: David Carlisle <davidc@xxxxxxxxx>
An: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Betreff: Re: dynamic template caller problems
>
>
> just use
> <xsl:apply-templates/>
>
> and have (eg)
> <xsl:template match="page2[@template='template_b']">
>
> no need to make it difficult by using template names here.
>
> David
--
Echte DSL-Flatrate dauerhaft f|r 0,- Euro*. Nur noch kurze Zeit!
"Feel free" mit GMX DSL: http://www.gmx.net/de/go/dsl
|