textstring as atributes in xsl

  • Thread starter =?ISO-8859-15?Q?Joachim_Wei=DF?=
  • Start date
?

=?ISO-8859-15?Q?Joachim_Wei=DF?=

Hi,
does anybody know a simple solution for this XSL-Problem:

<xsl:param name='controlName'>theName</xsl:param>
<xsl:param name='otherOptions'><![CDATA[size="5" value="45"]]></xsl:param>

these parameters shoul result in sth. like
<input type="text" name="theName" size="5" value="45" />

the approach is

<xsl:element name="input>
<xsl:attribute name="type">text</xsl:attribute>
<xsl:attribute name="name"><xsl:value-of select="$controlName"
/></xsl:attribute>


how do i get my $otherOptions in here?

</xsl:element>


TIA

Jo
 
M

Martin Honnen

Joachim Weiß wrote:

does anybody know a simple solution for this XSL-Problem:

<xsl:param name='controlName'>theName</xsl:param>
<xsl:param name='otherOptions'><![CDATA[size="5" value="45"]]></xsl:param>

these parameters shoul result in sth. like
<input type="text" name="theName" size="5" value="45" />

the approach is

<xsl:element name="input>
<xsl:attribute name="type">text</xsl:attribute>
<xsl:attribute name="name"><xsl:value-of select="$controlName"
/></xsl:attribute>


how do i get my $otherOptions in here?

Obviously with some text stuffed in a CDATA you simply have unstructured
text which is not suitable to create structured result nodes of it,
unless you wrote a parser.
Why is it not possible for you to continue as with the other parameters,
e.g.
<xsl:with-param name="size" select="5" />
<xsl:with-param name="value" select="45" />
then you could simply use those parameters as you have done with the
other parameters.

There are also ways in XSLT to predefine attribute sets e.g.

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

<xsl:eek:utput method="xml" />

<xsl:attribute-set name="defaultSize">
<xsl:attribute name="size">5</xsl:attribute>
</xsl:attribute-set>

<xsl:attribute-set name="defaultValue">
<xsl:attribute name="value">45</xsl:attribute>
</xsl:attribute-set>

<xsl:attribute-set name="defaultSizeAndValue"
use-attribute-sets="defaultSize defaultValue" />

<xsl:template match="/">
<results>
<xsl:call-template name="example">
<xsl:with-param name="controlName" select="'theName'" />
</xsl:call-template>
</results>
</xsl:template>

<xsl:template name="example">
<xsl:param name="controlName" />
<input type="text" name="{$controlName}"
xsl:use-attribute-sets="defaultSizeAndValue"></input>
</xsl:template>

</xsl:stylesheet>

although that will not help you as far as I can see if you want to pass
specific parameter values when calling a template.
 
?

=?ISO-8859-15?Q?Joachim_Wei=DF?=

...
Thanks for your answer!

My problem is that I don't know the names of the parameters in advance.
I think, that there is no easy solution for that problem.

Jo
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top