473,396 Members | 1,972 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,396 software developers and data experts.

textstring as atributes in xsl

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
Jul 20 '05 #1
2 1042


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:output 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.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 20 '05 #2
Martin Honnen schrieb:

...
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
Jul 20 '05 #3

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

Similar topics

2
by: Filipe | last post by:
Hi all, This is a urgent situation. I´m counting on you guys to give some clue to get the right XSL Transformation. I need do group all nested tags <Entry> inside tag <Record> according to an...
3
by: Bernardo | last post by:
Hi, I want to Get all controls names, some properties, etc... from a form at runtime. Anyone knows how can i enumerate all controls from a form? Thanks for your help,
1
by: bamapookie | last post by:
I want to apply an attribute (ExpandableObjectConverter) to an existing ..NET class (actually, I want to apply it to Microsoft.SharePoint.SPUser) Since this class already exists, I can't just...
5
by: Dennis | last post by:
I know this is probably a very overworked issue but thought I'd share the code below to convert words in a text string to capitalize the first letter of the word using an array of word delimiters. ...
3
by: Roman | last post by:
Does anybody know an easy way (or tool) to guess the language of a given text string? e.g. Feeding in "This is an example." --> should return "english" or ISO code Feeding in "Das ist ein...
6
by: Christian Sonne | last post by:
Long story short, I'm trying to find all ISBN-10 numbers in a multiline string (approximately 10 pages of a normal book), and as far as I can tell, the *correct* thing to match would be this:...
1
by: technod | last post by:
Hi, I have constructed a clickable list of words which are added to a select box. I then have buttons to move the added elements up or down in the list. The code below seems to work fine for...
3
by: nhaldsev | last post by:
Can anyone help me how to convert this java function to PHP function dec2hex ( textString ) { return (textString+0).toString(16).toUpperCase(); } function convertChar2CP ( textString ) { ...
1
by: TOUNSI | last post by:
Hi at every body i want to know how i can display all attribute of ldap_get_entries() I'm using Active Directory and i success in the connection with Active Directory
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: 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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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,...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.