473,769 Members | 2,355 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

XSLT: Global Parameters

I have a problem using a global parameter to control the
XSL-Transformation of my XML-Document.

My XML-Document looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<Football xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespace SchemaLocation= "d:\_Privat\Foo tball\XML\Footb all.xsd">
<Season>
<Opponents>
<Opponent ID="ID1001" Town="Duesseldo rf"/>
</Opponents>
</Season>
<Football>

And my XSLT:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:styleshe et version="1.0"
xmlns:xsl="http ://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format">

<xsl:output method="html" encoding="UTF-8" indent="no"/>

<xsl:param name="Selection " select="Try"/>

<xsl:template match="Football ">
<html>
<xsl:apply-templates/>
</html>
</xsl:template>

<xsl:template match="Season">
<head>
<title>
<xsl:text>Saiso n </xsl:text>
<xsl:value-of select="@Year"/>
<xsl:text> (</xsl:text>
<xsl:value-of select="$Select ion"/>
<xsl:text>)</xsl:text>
</title>
</head>
<body>
<center>
<xsl:text><xsl: value-of select="$Select ion"/></xsl:text>
</center>
</body>
</xsl:template>

If I transform the XML-Document with this stylesheet the
value-of($Selection)-Part is in both cases empty. If I change the
select-Value to 1 or 12 (Number) or add this to the
Xalan-Transformator (-p Selection 1) as a parameter the given value
appears. But I can't understand why this only works with numbers? What
am I doing wrong?

Thanks
Stefan
Jul 20 '05 #1
2 3080
The problem is here:
<xsl:param name="Selection " select="Try"/>
This will select the node-set of all children with name "Try" of the current
node (the document node "/") -- that is either the top element of the xml
document is named "Try" in which case it will be selected, or the XPath
expression "Try" will select nothing -- and this is exactly your
case as the top element is named "Football".

The solution is to use:

<xsl:param name="Selection " select="'Try'"/>

that is, enclose Try in inner apostrophes. Then it is interpreted as a
string literal and not as a name that is part of a location step of an XPath
expression.
Hope this helped.
Cheers,

Dimitre Novatchev.


"Stefan Schmitz" <Ca**********@g mx.de> wrote in message
news:b0******** *************** **@posting.goog le.com...I have a problem using a global parameter to control the
XSL-Transformation of my XML-Document.

My XML-Document looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<Football xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespace SchemaLocation= "d:\_Privat\Foo tball\XML\Footb all.xsd">
<Season>
<Opponents>
<Opponent ID="ID1001" Town="Duesseldo rf"/>
</Opponents>
</Season>
<Football>

And my XSLT:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:styleshe et version="1.0"
xmlns:xsl="http ://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format">

<xsl:output method="html" encoding="UTF-8" indent="no"/>

<xsl:param name="Selection " select="Try"/>

<xsl:template match="Football ">
<html>
<xsl:apply-templates/>
</html>
</xsl:template>

<xsl:template match="Season">
<head>
<title>
<xsl:text>Saiso n </xsl:text>
<xsl:value-of select="@Year"/>
<xsl:text> (</xsl:text>
<xsl:value-of select="$Select ion"/>
<xsl:text>)</xsl:text>
</title>
</head>
<body>
<center>
<xsl:text><xsl: value-of select="$Select ion"/></xsl:text>
</center>
</body>
</xsl:template>

If I transform the XML-Document with this stylesheet the
value-of($Selection)-Part is in both cases empty. If I change the
select-Value to 1 or 12 (Number) or add this to the
Xalan-Transformator (-p Selection 1) as a parameter the given value
appears. But I can't understand why this only works with numbers? What
am I doing wrong?

Thanks
Stefan

Jul 20 '05 #2
Tempore 11:24:21, die Wednesday 09 February 2005 AD, hinc in foro {comp.text.xml} scripsit Stefan Schmitz <Ca**********@g mx.de>:
<xsl:text><xsl: value-of select="$Select ion"/></xsl:text>

And do replace this invalid line with:
<xsl:value-of select="$Select ion"/>

--
Joris Gillis (http://www.ticalc.org/cgi-bin/acct-v...i?userid=38041)
Fiat W3C in tenebris
Jul 20 '05 #3

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

Similar topics

2
4793
by: Geathaa | last post by:
Hi everyone, I want to transform a xml document containing the description of a menu tree to HTML. The MenuTree XML contains the target URL for each tree node. Some URL's contain parameters which are only known at runtime though. These "runtime parameters" are also set as global parameters in the XSLT stylesheet. What I want to do now is check the URL defined in the XML and replace any "runtime parameter" with the stylesheet parameter...
1
1464
by: David Way | last post by:
I have an xml file looks like this: <root> <L1>a</L1> <L2>b <L3>c</L3> </L2> </root> In my xslt file, I do a template match to get to <L3>
2
2011
by: philips | last post by:
Hi everybody, I am using the Xalan 1.8 C++ API in a real-time financial application which need to apply XSLT transformations on XML input messages received on-the- fly. On the process output, I get the transformed output XML. In the XSLT stylesheet, I defined several templates which take input parameters (like function calls) and I also defined global XSL variables.
4
10314
by: Thomas Mann | last post by:
Hi, how can I make my XSLT-stylesheet insert a timestamp (date/time) into the output file ? Regards Thomas
1
2156
by: Michael | last post by:
I am having a problem with scoping of parameters in my XSLT Stylesheet...here is the stylesheet (the xml document is irrelevant for the example) <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:param name="myParam">Stylesheet Default</xsl:param> <xsl:template match="/"> <result_explicit_call>
12
3419
by: Keith Chadwick | last post by:
I have a fairly hefty XSLT file that for the sake of debugging and clarity I wish to split into some separate sub-templates contained within the same file. The master template calls an apply-templates and passes a node set to it. This template in turn defines approximately 15 variables that dictate how the following template should proceed. Pseudo example: <!-- Root transformation called via .NET XSLTransform()--> <xsl:template...
2
1460
by: Richard L Rosenheim | last post by:
Is it possible to include addition tags in a XSLT file, that the XSLT processor will, for all practical purposes, ignore? What I'm looking to do is to include a section to contain information regarding what parameters the XSLT file is expecting. Then my program can retrieve the information from the style sheet and prompt the user for the necessary parameters. I'm envisioning the section would be something like this: <myParameters>
7
2868
by: Harolds | last post by:
The code below worked in VS 2003 & dotnet framework 1.1 but now in VS 2005 the pmID is evaluated to "" instead of what the value is set to: .... xmlItems.Document = pmXML // Add the pmID parameter to the XSLT stylesheet XsltArgumentList xsltArgList = new XsltArgumentList(); xsltArgList.AddParam("pmID", "", pmID); xmlItems.TransformArgumentList = xsltArgList;
2
7361
by: Efi Merdler | last post by:
Hello, As I understand it is impossible in xslt to change the value of a variable after you assigned a value to it. I would like to simulate a flag. For example if something happens in template A then update my flag. Template B reads the flag and according to its value decides to do something. The main idea is that template B is independent of template A, i.e.
0
9589
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
9423
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
10222
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
10050
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
9999
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
8876
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7413
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6675
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();...
2
3570
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.