Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > Dynamic parameter names in xsl

Reply
Thread Tools

Dynamic parameter names in xsl

 
 
systemutvecklare@gmail.com
Guest
Posts: n/a
 
      09-08-2005
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 -->
<xslaram 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

 
Reply With Quote
 
 
 
 
Joris Gillis
Guest
Posts: n/a
 
      09-08-2005
Tempore 18:11:56, die Thursday 08 September 2005 AD, hinc in foro {comp.text.xml} scripsit <(E-Mail Removed)>:

> 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
 
Reply With Quote
 
 
 
 
Dimitre Novatchev
Guest
Posts: n/a
 
      09-08-2005
Use a single xslaram, 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"
xmlnssl="http://www.w3.org/1999/XSL/Transform"
xmlns:myParam="my:myParam"
exclude-result-prefixes="xsl myParam">

<xslutput omit-xml-declaration="yes"/>

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

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

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


Cheers,
Dimitre Novatchev




<(E-Mail Removed)> wrote in message
news:(E-Mail Removed) 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 -->
> <xslaram 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
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
XSL for converting all rows and columns of XSL for Export to Excel. dynamic looping enggr XML 0 06-30-2010 10:06 PM
XSL Question tp xsl:for-each and xsl:variable schaf@2wire.ch XML 1 05-27-2005 09:25 PM
Converting 'flat' gate level names to hierarchical names Paddy McCarthy VHDL 3 09-24-2004 05:34 PM
table field names vs. display names Bob ASP .Net 1 07-30-2004 05:06 PM
XSL rules applying to XSD (XML schema) defined type names (as opposed to node names) Lewis G. Pringle, Jr. XML 0 09-30-2003 10:34 PM



Advertisments