• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 471
  • Last Modified:

Ampersand in XSL

Hi, when using & in xsl it causes an error. Can someone help with this?
0
mitesh114
Asked:
mitesh114
  • 6
  • 3
1 Solution
 
R7AFCommented:
Use & instead.

You have to escape the ampersand. The same goes for < (&lt;), > (&gt;), " (&quot;), ' (&apos;).
0
 
mitesh114Author Commented:
how do you escape? using brackets?  that doesn't seem to work
0
 
R7AFCommented:
0
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

 
R7AFCommented:
You need to use &amp;
The & is the escape character. So if you use that, it is expected that you give a character code. This can be one of the five predefined character entities. Or you can use numeric codes like &#160; (this is the &nbsp; that you use in HTML).

Another way to handle this is using a CDATA section.

Can you give example XML and XSLT of what you do?
0
 
mitesh114Author Commented:
here's the sample code:

  <xsl:variable name="Rows" select="/soap:Envelope/soap:Body/ddw1:GetListItemsResponse/ddw1:GetListItemsResult/ddw1:listitems/rs:data/z:row[normalize-space(@ows_LinkTitle) = 'M(&amp)X ]"/>

between M and X is where I want to place the &
0
 
R7AFCommented:
You forgot the ending ; !!!

<xsl:variable name="Rows"  select="/soap:Envelope/soap:Body/ddw1:GetListItemsResponse/ddw1:GetListItemsResult/ddw1:listitems/rs:data/z:row[normalize-space(@ows_LinkTitle) = '&amp;']"/>
0
 
R7AFCommented:
NB: you probably wanted: 'M&amp;X'

In the source XML you need to use the same value. Otherwise the XML is not well formed. You might want to use CDATA for this, but in effect that's the same. (You cannot use CDATA in an attribute though.)

 <![CDATA[M&X]]>
0
 
mitesh114Author Commented:
worked after I entered the ;
0
 
R7AFCommented:
Glad I could help. Thanks for the points!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

  • 6
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now