473,402 Members | 2,053 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,402 software developers and data experts.

Dynamic parameter names in xsl

Hi!

I have an application that generates an html-form from an xml-file
using an xsl-file. My problem is that I want the xsl to use some
"unknown" parameters that I pass to the xslt processor before
processing the xml. The parameters are not totally unknown but they are
not static, they are built by an attribute in the xml and a constant
name.

Is it possible to define a "runtime" parameter and use the value passed
to the xslt processor?

xsl example:
.... begin code ...
<!-- BUILD PARAMETER NAME -->
<xsl:variable name="param_name"><xsl:value-of
select="@name"/>_T</xsl:variable>
<!-- DEFINE PARAMETER -->
<xsl:param name="$param_name"/>
<!-- USE PARAMETER -->
<xsl:if test="$param_name = 'some_value'">do something</xsl:if>
.... end code ...

Any other solution to this problem is appreciated

Thanx!
/Andreas

Sep 8 '05 #1
2 4607
Tempore 18:11:56, die Thursday 08 September 2005 AD, hinc in foro {comp.text.xml} scripsit <sy**************@gmail.com>:
Is it possible to define a "runtime" parameter and use the value passed
to the xslt processor?


No, you'll have to redesign your xslt.
--
Joris Gillis (http://users.telenet.be/root-jg/me.html)
Deserta faciunt et innovationem appelant
Sep 8 '05 #2
Use a single xsl:param, whose value is a node-set that combines many
name-value pairs. Then you can use this "aggregate parameter" (or
"environment") like this:

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:myParam="my:myParam"
exclude-result-prefixes="xsl myParam">

<xsl:output omit-xml-declaration="yes"/>

<myParam:param>
<param name="param1">
<value>xxx1</value>
</param>
<param name="param2">
<value>xxx2</value>
</param>
<param name="param3">
<value>xxx3</value>
</param>
</myParam:param>

<xsl:param name="pallParams"
select="document('')/*/myParam:*[1]/*"/>

<xsl:template match="/">
<xsl:value-of select=
"$pallParams[@name='param2']/value"/>
</xsl:template>
</xsl:stylesheet>
Cheers,
Dimitre Novatchev


<sy**************@gmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
Hi!

I have an application that generates an html-form from an xml-file
using an xsl-file. My problem is that I want the xsl to use some
"unknown" parameters that I pass to the xslt processor before
processing the xml. The parameters are not totally unknown but they are
not static, they are built by an attribute in the xml and a constant
name.

Is it possible to define a "runtime" parameter and use the value passed
to the xslt processor?

xsl example:
... begin code ...
<!-- BUILD PARAMETER NAME -->
<xsl:variable name="param_name"><xsl:value-of
select="@name"/>_T</xsl:variable>
<!-- DEFINE PARAMETER -->
<xsl:param name="$param_name"/>
<!-- USE PARAMETER -->
<xsl:if test="$param_name = 'some_value'">do something</xsl:if>
... end code ...

Any other solution to this problem is appreciated

Thanx!
/Andreas

Sep 8 '05 #3

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

Similar topics

0
by: Shailesh | last post by:
If I'm not mistaken, C++ doesn't have support for dynamic class members. I'm considering if such a facility would be useful, and what method would make a good workaround. I have a generic...
3
by: CSDunn | last post by:
Hello, I have a situation with MS Access 2000 in which I need to display report data in spreadsheet orientation (much like a datasheet view for a form). If you think of the report in terms of what...
1
by: Nathan Bloomfield | last post by:
Does anyone know if there is any documentation which relates to Access2k + ? or can anyone help adjust the code? I am having trouble converting the DAO references. TITLE :INF: How to...
3
by: Stephen Gennard | last post by:
Hello, I having a problem dynamically invoking a static method that takes a reference to a SByte*. If I do it directly it works just fine. Anyone any ideas why? I have include a example...
4
by: Andrew | last post by:
Hey all, Been working with the Crystal Report Viewer, and have run into a situation I am hoping someone can help me get past. This may be more of a CR question, but hoping for some CR gurus to...
4
by: =?Utf-8?B?SGF5U2VlZA==?= | last post by:
Is there some way to use Generics in dynamic code using the Type.GetType("MyClassName") as an argument? List<Type.GetType("MyClassName") oList = new List<Type.GetType("MyClassName") > ...
26
by: Aaron \Castironpi\ Brady | last post by:
Hello all, To me, this is a somewhat unintuitive behavior. I want to discuss the parts of it I don't understand. .... f= lambda: n .... 9 9
6
by: =?ISO-8859-1?Q?Tim_B=FCthe?= | last post by:
Hi, we are building a Java webapplication using JSF, running on websphere, querying a DB2 9 on Suse Enterprise 10. The app uses JDBC and PreparedStatements only (aka dynamic SQL). Every night,...
1
by: Sundhas | last post by:
Hey! I am working on jrxml to create dynamic re0ports. I have parameterized the columns i.e. the jrxml for that report can be used to generate other reports as well. However, i have not managed...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...
0
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...
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
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,...
0
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...

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.