XSLT: concat and quotes

G

Gerald Aichholzer

Hello,

I need to specify the following attribute in an xhtml-file
containing TAL templates:

<div tal:attributes="onMouseOver concat('func(',xyz,')')">

which results in

<div onMouseOver=func( )>
^
value of xyz here


My problem is, that I need to put quotes around the content
of xyz:

<div onMouseOver=func(' ')>


How can I achieve this? The double quotes are already in
use by tal:attributes, the single quotes are used by the
concat-function.

thanx in advance,
Gerald
 
M

Martin Honnen

Gerald Aichholzer wrote:

I need to specify the following attribute in an xhtml-file
containing TAL templates:

<div tal:attributes="onMouseOver concat('func(',xyz,')')">

which results in

<div onMouseOver=func( )>
^
value of xyz here


My problem is, that I need to put quotes around the content
of xyz:

<div onMouseOver=func(' ')>


How can I achieve this? The double quotes are already in
use by tal:attributes, the single quotes are used by the
concat-function.

I don't know what TAL is but if you are asking about the XPath function
concat then you need to split up the string into parts containing single
quotes and into parts contaning double quotes if needed e.g.
<xsl:value-of select="concat('func(', &quot;'&quot;, 'xyz',
&quot;'&quot;, ')'" />
 
G

Gerald Aichholzer

Martin said:
I don't know what TAL is but if you are asking about the XPath function
concat then you need to split up the string into parts containing single
quotes and into parts contaning double quotes if needed e.g.
<xsl:value-of select="concat('func(', &quot;'&quot;, 'xyz',
&quot;'&quot;, ')'" />

I'm speaking about the XPath function concat. I think I should
have specified my problem a little bit better. In my application
the tal:attributes works as follows:

<div tal:attributes="attrname XPath-expression">

where

attrname is the name of an attribute which is created
XPath-expression specifies an XPath-expression which
value is assigned to the attribute.

e.g.

<div tal:attributes="sample concat('hello',' ','world')">

will be expanded to

<div sample="hello world">


My problem is, that I need single _and_ double quotes in
the strings used by concat, but the double quotes are
already used for tal:attributes="..."

I don't think that

<div tal:attributes=
"sample concat('hello ','"',$world,'"')">

will work, because the second " is considered to be the
end of tal:attributes.

If $world="gerald" then the above should result to

<div sample="hello 'gerald'">

How can I achieve this?

Thanx in advance,
Gerald
 
M

Martin Honnen

Gerald Aichholzer wrote:

My problem is, that I need single _and_ double quotes in
the strings used by concat, but the double quotes are
already used for tal:attributes="..."

I don't think that

<div tal:attributes=
"sample concat('hello ','"',$world,'"')">

will work, because the second " is considered to be the
end of tal:attributes.

You need to escape the double quotes then

<div tal:attributes=
"sample concat('hello ','&quot;',$world,'&quot;')">
 
G

Gerald Aichholzer

Martin said:
You need to escape the double quotes then

<div tal:attributes=
"sample concat('hello ','&quot;',$world,'&quot;')">

Thank you very much :)

Gerald
 

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

Forum statistics

Threads
473,999
Messages
2,570,246
Members
46,843
Latest member
WizcraftEntertainmentAgen

Latest Threads

Top