473,785 Members | 2,575 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Applying templates to parameters

Hi,

I think the following is not possible but maybe (hopefully) I am wrong:

I have:

<xsl:param name="test">
<tag1>asdfasd f</tag1>
<tag2>asdfasd f</tag2>
</xsl:param>

Is the following possible ?

<xsl:apply-templates select="$test/tag1"/>

Thanks

Thomas
Jul 20 '05 #1
2 2018
Hi Thomas,

No, it is not possible in XSLT 1.0 - because the $test param would contain
an RTF (Result Tree Fragment) and RTF's cannot be used as node-sets in XPath
expressions.

Many XSLT engines have an extension function (e.g. msxsl:node-set() or
exslt:node-set() functions) that will convert an RTF to a node-set. This
route, obviously, makes your stylesheets far less portable.

If the content within your <xsl:param> is static/constant XML that is to be
defaulted to if no <xsl:with-param> value overrides it then there is an
alternative method that avoids using extension functions, e.g....

<?xml version="1.0"?>
<xsl:styleshe et version="1.0"
xmlns:xsl="http ://www.w3.org/1999/XSL/Transform"
xmlns:static="u rn:my-static-stuff">
<xsl:output method="text"/>

<static:stuff >
<tag1>asdfasd f</tag1>
<tag2>asdfasd f</tag2>
</static:stuff>

<xsl:template match="/">
<xsl:call-template name="test-param-defaults">
</xsl:call-template>
</xsl:template>

<xsl:template name="test-param-defaults">
<xsl:param name="test" select="documen t('')/*/static:stuff"/>
<xsl:apply-templates select="$test/tag1"/>
</xsl:template>

<xsl:template match="tag1">
<xsl:text>tag 1 matched</xsl:text>
</xsl:template>
</xsl:stylesheet>
HTH
Marrow
http://www.marrowsoft.com - home of Xselerator (XSLT IDE and debugger)
http://www.topxml.com/Xselerator
"Thomas Sommer" <ma****@gmx.d e> wrote in message
news:pa******** *************** *****@gmx.de...
Hi,

I think the following is not possible but maybe (hopefully) I am wrong:

I have:

<xsl:param name="test">
<tag1>asdfasd f</tag1>
<tag2>asdfasd f</tag2>
</xsl:param>

Is the following possible ?

<xsl:apply-templates select="$test/tag1"/>

Thanks

Thomas

Jul 20 '05 #2
Thanks for the info. It definitely helps.
Thomas
Jul 20 '05 #3

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

Similar topics

2
2091
by: Kimmo | last post by:
Folks, I have a XML document that has been put together from a "dynamic part" (generated somehow during runtime) and a "static part" (read from a control file). Basically the document looks like this: <?xml version="1.0" encoding="UTF-8"?> <rootelement> <subelementName>subelementTwo</subelementName> <subelements>
1
2717
by: Daryl | last post by:
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>
22
2195
by: E. Robert Tisdale | last post by:
According to the C++ FAQ Lite: http://www.parashift.com/ What is "genericity"? Yet another way to say, "class templates." Not to be confused with "generality" (which just means avoiding solutions which are overly specific),
1
3975
by: Bo Xu | last post by:
Object of Combination By Bo Xu Introduction A combination of n things, taken s at a time, often referred as an s-combination out of n, is a way to select a subset of size s from a given set of size n. There are n!/(s!(n-s)!) ways to do this. Donald E. Knuth gives several methods (algorithms) to generate all the s-combinations in . In such procedure-oriented way, each s-combination is processed while it's being generated. In some
16
16291
by: WittyGuy | last post by:
Hi, What is the major difference between function overloading and function templates? Thanks! http://www.gotw.ca/resources/clcm.htm for info about ]
7
567
by: Jon Slaughter | last post by:
#pragma once #include <vector> class empty_class { }; template <int _I, int _J, class _element, class _property> class RDES_T {
3
1410
by: Christoph | last post by:
I'm still learning how to write stylesheets and the ones I've come up with for learning purposes are pretty simple and straightforward. I can get it to work, but probably not in the most ideal way. I have a node in the XML I'm transforming that contains CRLFs. I did a search on how to do a search/replace but am not 100% sure how to fit it into my template. Here is a sample xml record: <UserRecordRoot> <UserItems>
4
1212
by: RThaden | last post by:
Hi all, I looked in several books, articles, etc. but did not find a solution to my problem. Maybe somebody out there can help a desperate, not toooo experienced programmer: I want to represent functional blocks by lists of parameters. Lets say, functional blocks represent different algorithms which, of course, have very different parameters. Thus, a functional block contains lists of parameters which, and now
7
1711
by: Chris | last post by:
Hi All, This is a weird one but I am hoping someone can help or has some pointers, a recipe how to do the following: I have to move some code from c++ to objective-c and to do this I must remove all defined templates. I am not really a c++ guy so I have not worked with templates all that much (not really at all) and as such I don't have a good idea where to start.
0
9645
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10325
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10148
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10091
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6740
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4053
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3646
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.