469,313 Members | 2,536 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,313 developers. It's quick & easy.

XSLT: concat and quotes

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
Jul 20 '05 #1
4 7895


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;, ')'" />

--

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

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;, ')'" />


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


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;')">

--

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

Martin Honnen wrote:

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;')">


Thank you very much :)

Gerald
Jul 20 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Patrick Reilly | last post: by
3 posts views Thread by Son KwonNam | last post: by
4 posts views Thread by Frederik Sørensen | last post: by
reply views Thread by david.paik | last post: by
2 posts views Thread by Scott Sauyet | last post: by
1 post views Thread by Sandeep Singh | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by harlem98 | last post: by
1 post views Thread by Geralt96 | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.