473,322 Members | 1,781 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Problem with xsl:call-template

When using xsl:call-template it seems that we can't use a parameter as the
name of the template to call.
Example :

<xsl:template name="cadre">
<xsl:param name="p_contenu"/>

<xsl:call-template name="{$p_contenu}"/>
</xsl:template>

It does'nt work : Xalan logs this error (sorry it's french)

2003-12-22 03:16:28 - path="/gcdev" :gc:
javax.xml.transform.TransformerConfigurationExcept ion:
javax.xml.transform.TransformerException:
javax.xml.transform.TransformerException: Valeur incorrecte : {$p_contenu}
utilisée pour l'attribut QNAME : name

Any suggestion to fix this problem?



Jul 20 '05 #1
2 1558
Remi COCULA wrote:
When using xsl:call-template it seems that we can't use a parameter as the
name of the template to call.
Example :

<xsl:template name="cadre">
<xsl:param name="p_contenu"/>

<xsl:call-template name="{$p_contenu}"/>
</xsl:template>

It does'nt work : Xalan logs this error (sorry it's french)

2003-12-22 03:16:28 - path="/gcdev" :gc:
javax.xml.transform.TransformerConfigurationExcept ion:
javax.xml.transform.TransformerException:
javax.xml.transform.TransformerException: Valeur incorrecte : {$p_contenu}
utilisée pour l'attribut QNAME : name

Any suggestion to fix this problem?


hi,

this is not an error : the name of a template *must* be a QName, as
xalan output shows

however, you may use the following design pattern, known as "template
tag" to get the requested behaviour :

<xsl:stylesheet xmlns:xsl="..."
xmlns:tt="*** template tag ***">

....

<xsl:template name="cadre">
<xsl:param name="p_contenu"/>
<xsl:apply-templates
select="document('')/*/tt:template[@name=$p_contenu]"/>
</xsl:template>

<tt:template name="theName"/>
<xsl:template match="tt:template[@name='theName']">
<!--your stuff here-->
</xsl:template>

<tt:template name="anotherName"/>
<xsl:template match="tt:template[@name='anotherName']">
<!--your stuff here-->
</xsl:template>

--
Cordialement,

///
(. .)
-----ooO--(_)--Ooo-----
| Philippe Poulard |
-----------------------

Jul 20 '05 #2

"Remi COCULA" <re*********@wanadoo.fr> wrote in message
news:bs**********@news-reader5.wanadoo.fr...
When using xsl:call-template it seems that we can't use a parameter as the
name of the template to call.


This cannot be done with xsl:call-template, because the Spec requires the
value of its "select" attribute to be a QName, which, among other things by
definition, must be statically known (at compile time).
What you want to achieve is done by using the general XSLT design pattern of
"generic templates" or "template references".

For more information read the first article on the home page of FXSL -- the
functional programming library for XSLT.

See also my presentation "Functional programming in XSLT using the FXSL
library" delivered at this year's "Extreme Markup Languages" conference:

http://www.idealliance.org/papers/ex...ovatchev01.pdf


Dimitre Novatchev.
FXSL developer, XML Insider,

http://fxsl.sourceforge.net/ -- the home of FXSL
Resume: http://fxsl.sf.net/DNovatchev/Resume/Res.html
Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: xcomm | last post by:
I tried to create some images with php and gd and get always Call to undefined function imagejpeg() or Call to undefined function imagepng() PHP was build with --with-gd --with-zlib but I...
1
by: bart | last post by:
This is the python way i have. imgref = 'image.py' out.write('<img src="%s">' % (imgref) in ASP.NET u can do something like this <img src="<%# image() %>">
0
by: schaf | last post by:
Hi ! I'm writing a new xsl:function, which uses two other functions. But by the call of the first function, it would be abort just after the call. Not even the xsl:param would be set. I don't...
1
by: David | last post by:
I am attempting to use the GetDiskFreeSpaceExA api to get the disksapce for a drive. When I call the function from C#, I receive an OK rc but the space is for my default drive "c:". No matter...
6
by: Ted | last post by:
Hello all, Please could somebody with a little time on their hands help me with my net sockets program? The aim is to send multiple transactions via C# network stream and read them back. The...
7
by: Andrew Christiansen | last post by:
Hey everyone. I have Visual Basic .NET 2003 and am trying to show images on a treeview control. I have the imagelist on the form filled with images, and have the ImageList property of the...
1
by: Eduard Ralph | last post by:
Hi, I've been having a very weird problem in connection with using the Enterprise Library. I'm programming a Windows Service and utilise the logging and configuration component. During the...
6
by: enjoying the view | last post by:
I am working on a school project, trying to build a simple RPC stub generator. The idea is that the generator takes a normal python file with functions defined in it and produces a client and...
7
by: lumo2000 | last post by:
hello i am not able to get mysql running. you can get my server/php settings/details here: http://damn-i-have.no-ip.com/phpinfo.php i already enabled the following stuff in my php.ini NOTE:...
1
by: shidhincr | last post by:
I have some doubts regarding XML and XSL transfornation using javascript.Hope SomeOne will help me for solving this problem. Actually i Created a javascript for transforming XML and XSL. i made...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.