List Info

Thread: replacing & in a string




replacing & in a string <xsl:if>
country flaguser name
United States
2007-05-17 04:58:32
Hi,
I'm a newbee to xsl. I have to do the following in my .xsl file.

<;xsl:if test="statement_type = 'Myself & bod went to a movie'">;

<call template&gt;
</xsl:if>

The problem is in this xsl:if the char '&' is considered as a conditional statement. But its part of the string. Is there a way to replace it.

Thanks in advance.

-- S.Srinivasan
 &nbsp; Res: 044-28445520

;


Pinpoint customers who are looking for what you sell.
Re: replacing & in a string <xsl:if>
country flaguser name
United States
2007-05-17 09:57:00
On Thu, May 17, 2007 at 02:58:32AM -0700, Srinivasan.S
wrote:
> I'm a newbee to xsl. I have to do the following in my
.xsl file.
> 
> <xsl:if test="statement_type = 'Myself &
bod went to a movie'">
> <call template>
> </xsl:if>

Use &amp; or &#38; to escape an & sign
(whichever you prefer)

You are asking if the contents of a subelement called
statement_type is exactly equal to the given string, with 
no extra spaces.  I don't know if this is what you want.

I'm also assuming your <call template> is actually
<xsl:apply-templates />
or
<xsl:call-template name="touch-my-sock" />
or something.

Liam

-- 
Liam Quin, W3C XML Activity Lead, http://www.w3.org/Peop
le/Quin/
http://www.holoweb.net/
~liam/ * http://www.fromoldbooks.
org/
Mandriva Linux: http://www.mandriva.co
m/linux/
_______________________________________________
Perl-XML mailing list
Perl-XMLlistserv.ActiveState.com
To unsubscribe: http:/
/listserv.ActiveState.com/mailman/mysubs

Re: replacing & in a string <xsl:if>
country flaguser name
Russian Federation
2007-05-17 10:14:10
SS> <xsl:if test="statement_type = 'Myself &
bod went to 
SS> a movie'">

SS> The problem is in this xsl:if the char '&' is 
SS> considered as a
SS> conditional statement. But its part of the string. 
SS> Is there a way to replace it.

A conditional statement? No--XSLT use the keyword 'and'
instead of '&'. An error you get is because your
XSLT-file is not proper XML. 

Ampersand character have to be treated as a starting symbol
of an entity. When the parser sees substring '& ' with a
space following '&', it will definetly fail. Use
'&amp;' if you expect to find the exact string in
<statement_type> tag. 

I'd also preffered to say statement_type/text() instead of
statement_type.


--
Andrew Shitov
____________________________________________________________
__________
andyshitov.ru | http://shitov.ru

_______________________________________________
Perl-XML mailing list
Perl-XMLlistserv.ActiveState.com
To unsubscribe: http:/
/listserv.ActiveState.com/mailman/mysubs

[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )