apply template with variable

Philipp Kraus

Usenet Archive
Joined
Oct 16, 2009
Messages
176
Reaction score
0
Hello,

I have got a problem with a query, that is passend by a parameter.
See this two templates

<xsl:call-template name="section">
<xsl:with-param name="query">
<xsl:value-of select="sectiondef[@kind='public-func']"/> </xsl:with-param> </xsl:call-template>

<xsl:template name="section">
<xsl:param name="query" required="yes"/>
<xsl:apply-templates select="sectiondef[@kind='public-func']"> <xsl:sort select="name"/> </xsl:apply-templates>

do other things
</xsl:template>

I have set up the query on the second template equal / fixed, this works, if I now subsitute the select query on apply to

<xsl:template name="section">
<xsl:param name="query" required="yes"/>
<xsl:apply-templates select="$query">
<xsl:sort select="name"/>
</xsl:apply-templates>

do other things
</xsl:template>

The apply results 0 nodes and this does not work anymore. So I would push a query to the template and call in the template an apply with this query.

Thanks

Phil
 

Martin Honnen

Usenet Archive
Joined
Apr 8, 2000
Messages
6,174
Reaction score
0
Philipp said:
I have got a problem with a query, that is passend by a parameter.
See this two templates

<xsl:call-template name="section">
<xsl:with-param name="query">
<xsl:value-of select="sectiondef[@kind='public-func']"/> </xsl:with-param>

I think you simply want to use the "select" attribute of "with-param", as in <xsl:with-param name="query" select="sectiondef[@kind='public-func']"/>

Then the below template should work.
<xsl:template name="section">
<xsl:param name="query" required="yes"/>
<xsl:apply-templates select="$query">
<xsl:sort select="name"/>
</xsl:apply-templates>

do other things
</xsl:template>

But seeing all those named template being called with parameters I wonder whether you could not simply use template matching, perhaps with modes instead, to leverage the power of XSLT.
 

Philipp Kraus

Usenet Archive
Joined
Oct 16, 2009
Messages
176
Reaction score
0
Philipp said:
I have got a problem with a query, that is passend by a parameter.
See this two templates

<xsl:call-template name="section">
<xsl:with-param name="query">
<xsl:value-of select="sectiondef[@kind='public-func']"/> </xsl:with-param>

I think you simply want to use the "select" attribute of "with-param", as in <xsl:with-param name="query" select="sectiondef[@kind='public-func']"/>

Then the below template should work.
<xsl:template name="section">
<xsl:param name="query" required="yes"/>
<xsl:apply-templates select="$query">
<xsl:sort select="name"/>
</xsl:apply-templates>

do other things
</xsl:template>

But seeing all those named template being called with parameters I wonder whether you could not simply use template matching, perhaps with modes instead, to leverage the power of XSLT.

Thanks for your answer, I will test it.
The solution is, that I use the call name, that I mixed up matching & calling templates. I'm using XSLT for creating a plain text output and I have created the name-matching templates for structures that are always used like function in other languages eg the calling templates generates a header
--- my header ---
and the matching templates fills the section, in this case the section templates creates the full plaintext section (header + content)

Phil
 

Philipp Kraus

Usenet Archive
Joined
Oct 16, 2009
Messages
176
Reaction score
0
Philipp said:
I have got a problem with a query, that is passend by a parameter.
See this two templates

<xsl:call-template name="section">
<xsl:with-param name="query">
<xsl:value-of select="sectiondef[@kind='public-func']"/> </xsl:with-param>

I think you simply want to use the "select" attribute of "with-param", as in <xsl:with-param name="query" select="sectiondef[@kind='public-func']"/>

Then the below template should work.

Thanks with the select call it works

Phil
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
548,049
Messages
3,104,245
Members
248,133
Latest member
DujonT

Latest Threads

Top