borovikpe
borovikpe

Reputation: 71

unescaped value within input element

could please someone tell me why 'disable-output-escaping' attribute takes no effect in the following piece of XSL template?

<INPUT type="text">
  <xsl:attribute name="value" >
    <xsl:value-of select="$query"  disable-output-escaping = "yes" />
  </xsl:attribute>
</INPUT>

I would like to see an unescaped value within the 'input' element.

Thanks in advance

Upvotes: 0

Views: 499

Answers (3)

cgatian
cgatian

Reputation: 22994

I came across this as a hack to the situation. By creating a text node and then putting your html there, up until the attribute you need escaped. The document will escape properly.

<xsl:text disable-output-escaping>&lt;input type="text" SIZE="62" name="text1" value="</xsl:text>
<xsl:value-of select="$temp" disable-output-escaping="yes"/>
<xsl:text disable-output-escaping>" /></xsl:text>

Where I discovered the hack...

Upvotes: 0

Dimitre Novatchev
Dimitre Novatchev

Reputation: 243549

why 'disable-output-escaping' attribute takes no effect in the following piece of XSL template?

  <xsl:attribute name="value" >
    <xsl:value-of select="$query"  disable-output-escaping = "yes"

/>

D-O-E has effect only for text nodes -- not for attributes.

If the output method is xml, then an XSLT processor must output a well-formed XML document and then it is mandatory to escape special characters in any attribute value.

You may try specifying:

<xsl:output method="html"/>

However, bear in mind that D-O-E is not a mandatory feature of XSLT at all and some XSLT processors don't implement D-O-E. Therefore, you may need to enter the wanted value manually (and maybe use the "text" output method).

Upvotes: 1

Kirill Polishchuk
Kirill Polishchuk

Reputation: 56202

You can change output method to html, i.e.:

<xsl:output method="html"/>

Upvotes: 0

Related Questions