How to embed XSL expression within an attribute?

D

D. Alvarado

Hello,
I am outputting HTML from an XSLT and I am having trouble setting
the value of a form-action field based on certain conditions. Here is
the non-working code:

<xsl:template match="dictionary-link[$no-dictionary = 'false']">
<form name="dictionaryform" method="get"
action="<xsl:choose><xsl:when
test="$var1=''">dictionary.jsp</xsl:when><xsl:eek:therwise>dictionary.jsp</xsl:eek:therwise></xsl:choose>"
target="dictwin" onSubmit="dictwin=window.open('','dictwin','fullscreen=no,toolbar=no,status=no,menubar=no,scrollbars=yes,resizable=yes,directories=no,location=no,width=300,height=400')">
<div class="dictionary-link">
<table width="100%"><tr>
<td align="left" width="33%">
Look up a word
</td>
<td align="center" width="33%">
<input type="text" name="word" size="20"/>
</td>
<td align="right" width="33%">
<input type="image" alt="Go" border="0"
src="gobutton.gif"/>
</td>
</tr></table>
</div>
</form>
</xsl:template>


When I try and run the transform, things crash and burn because I'm
told the value of the "action " attribute cannot contain "<". Can
anyone suggest a work-around?

Thanks, -
 
I

Igor Zlatkovic

D. Alvarado said:
Hello,
I am outputting HTML from an XSLT and I am having trouble setting
the value of a form-action field based on certain conditions. Here is
the non-working code:

<xsl:template match="dictionary-link[$no-dictionary = 'false']">
<form name="dictionaryform" method="get"
action="<xsl:choose><xsl:when
test="$var1=''">dictionary.jsp</xsl:when><xsl:eek:therwise>dictionary.jsp</xsl:eek:therwise></xsl:choose>"
target="dictwin" onSubmit="dictwin=window.open('','dictwin','fullscreen=no,toolbar=no,status=no,menubar=no,scrollbars=yes,resizable=yes,directories=no,location=no,width=300,height=400')">
<div class="dictionary-link">
<table width="100%"><tr>
<td align="left" width="33%">
Look up a word
</td>
<td align="center" width="33%">
<input type="text" name="word" size="20"/>
</td>
<td align="right" width="33%">
<input type="image" alt="Go" border="0"
src="gobutton.gif"/>
</td>
</tr></table>
</div>
</form>
</xsl:template>


When I try and run the transform, things crash and burn because I'm
told the value of the "action " attribute cannot contain "<". Can
anyone suggest a work-around?

Create the attribute with <xsl:attribute/>

http://www.w3.org/TR/xslt#element-attribute

Ciao,
Igor
 
J

Johannes Koch

D. Alvarado said:
When I try and run the transform, things crash and burn because I'm
told the value of the "action " attribute cannot contain "<". Can
anyone suggest a work-around?

<xsl:template match="dictionary-link[$no-dictionary = 'false']">
<form name="dictionaryform" method="get" ...>
<xsl:attribute name="action">
<xsl:choose>
<xsl:when test="$var1=''">dictionary.jsp</xsl:when>
<xsl:eek:therwise>dictionary.jsp</xsl:eek:therwise>
</xsl:choose>
</xsl:attribute>
...
</form>
</xsl:template>
 

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,781
Messages
2,569,615
Members
45,296
Latest member
HeikeHolli

Latest Threads

Top