Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XSLT single and double quotes in form input value attribute?

Tags:

xml

xslt

Hopefully a quick question, how can I get this to be well formed, and therefore run?

<input type="rad" name="RadGroup" value="<xsl:value-of select="productOptionInfo"/>" />

I basically want to have a value placed inside of the attribute value, but they both need double quotes!?

Any ideas?

Many thanks

like image 789
Ross Avatar asked Jan 03 '11 14:01

Ross


People also ask

Are double quotes allowed in XML?

Double quotes, "" , and single quotes, '' , are valid entities in XML file when they are part of element value in XML.

Does XML allow single quotes?

Strings inside XML Tags are enclosed by a start tag and an end tag. So the content may have any combination of single and double quotes. The values of XML attributes are delimited by either single or double quotes.

What is attribute in XSLT?

The xsl:attribute element is used to add an attribute value to an xsl:element element or literal result element, or to an element created using xsl:copy. The attribute must be output immediately after the element, with no intervening character data. Available in XSLT 1.0 and later versions.


1 Answers

In XSLT, there is a shortcut to use values within attributes:

<input type="rad" name="RadGroup" value="{productOptionInfo}" />

There is another option, which it to use xsl:attribute:

<input type="rad" name="RadGroup">
    <xsl:attribute name="value">
       <xsl:value-of select="productOptionInfo"/>
    </xsl:attribute>
</input>
like image 129
Oded Avatar answered Nov 16 '22 04:11

Oded