• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 467
  • 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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