473,396 Members | 1,938 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,396 software developers and data experts.

apply-templates not passing with-param

Hello
I am using apply-templates and would like to pass a parameter to the
template using with-param. Using call-template passes the parameter,
but when I use apply-templates, the parameter seems to be lost. Can
parameters be passed with apply-templates? Any ideas?

<!--xml-->
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="tran2.xsl"?>
<doc>
<parameters>
<parameter name="a">
<options>2</options>
</parameter>
<parameter name="b"/>
<parameter name="c" >
<options>1</options>
</parameter>
<parameter name="d"/>
</parameters>
</doc>

<!--xsl called trans2.xsl-->
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" media-type="text/xml" indent="yes"/>

<xsl:template match="/">
<xsl:element name="treeview" >
<xsl:element name="element" >
<xsl:attribute name="name">doc</xsl:attribute>
<xsl:element name="contents">

<!--this works-->

<xsl:call-template name = "parameters">
<xsl:with-param name="testParam" select="1"/>
</xsl:call-template>
<!--this does not-->
<!--
<xsl:apply-templates match="parameters">
<xsl:with-param name="testParam" select="1"/>
</xsl:apply-templates>
-->
</xsl:element>
</xsl:element>
</xsl:element>
</xsl:template>

<!--paramaters tag. Can hold options -->
<xsl:template name="parameters" match="parameters">
<xsl:param name="testParam" />

<xsl:if test="$testParam='1'">
Ok
</xsl:if>

<xsl:if test="$testParam=''">
failed
</xsl:if>

</xsl:template>
</xsl:stylesheet>

Cheers in advance
Daryl
Jul 20 '05 #1
1 2691
Hello,
I am using apply-templates and would like to pass a parameter to the
template using with-param. Using call-template passes the parameter,
but when I use apply-templates, the parameter seems to be lost. Can
parameters be passed with apply-templates?
Hopefully yes :-)
<xsl:apply-templates match="parameters">

^^^^^

I guess you meant :
<xsl:apply-templates select="doc/parameters">

1/ I do not know what does match (no error, but not it the
recommandation). "select" should do what you intended to.

2/ as you are in the root element, there is the doc element before
parameters.

Hth

--
Rémi Peyronnet
Jul 20 '05 #2

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

Similar topics

1
by: Achim Domma | last post by:
Hi, I'm using py2exe to create a exe out of a python script. If works fine so far, but a get lot's of this warnings: warning: use func(*args, **kwargs) instead of apply(func, args, kwargs) ...
3
by: Mark Hahn | last post by:
Does the python license apply to all the modules in the standard distribution? For example, does the bsddb module only require the standard python license or does it include the sleepycat...
4
by: topjun | last post by:
using osql to apply SPs in mutiple threads Hello, I got a weird problem when I was using osql to apply scripts for msde database in multiple threads mode. Sometime 2 sps were missing during the...
7
by: Troy Heber | last post by:
Can anyone tell me how to force an immediate apply of system based registry changes. I have an application written in C# that updates the registry. However I’m forced to logout and log back in for...
1
by: Christopher Benson-Manica | last post by:
IE 5.0 apparently does not support the apply() method for function objects - the following fails: function foo() { alert( this.length ); } foo.apply( ); Is there a convenient way to add an...
3
by: Dave | last post by:
How do I apply a font name to an entire HTML table without specifying it in each cell/row, or applying a CSS ID to each cell or row? -- - Dave
3
by: almousawi | last post by:
I am working on a DB2 replication program that used to work. I ran the "warm" capture program to get a cold start and I am running the apply program, but, the apply does not replicate the data. I...
4
by: esmith2112 | last post by:
Having a bear of a time trying to implement replication under 8.2 environment. I've created all of the control structures on both source and target database and can actually see data being staged...
1
by: mattscho | last post by:
Re: Filter By From, Apply Filter, Remove Filter Buttons in a Form. -------------------------------------------------------------------------------- Hi All, Trying to create a set of 3 buttons in...
3
by: yawnmoth | last post by:
Based on my understanding of the apply function, the following code snippet should, at the very least, not yield any errors. Unfortunately, it does, suggesting my understanding is... limited. Any...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.