Re: [xsl] Saxon errors

Subject: Re: [xsl] Saxon errors
From: Abel Braaksma <abel.online@xxxxxxxxx>
Date: Thu, 10 May 2007 11:15:59 +0200
Kamal Bhatt wrote:
In your input, change "<" to &lt; and ">" to &gt; .

You cannot use < and > in XML data (unless it is enclosed in CDATA "tags"). Actually, you probably could use < in some circumstances, but it is best to play it safe.



No, the < can never be used unless inside CDATA. But you can use the > safely without escaping. There are only two entities that must always be escaped: &lt; and &amp;. The other default entities, &gt;, &quot; and &apos; sometimes do and sometimes don't need to be used:

<!-- valid xml -->
<input value=" ' " />
<input>>>></input>
<input value=">>>" />
<input value=' " ' />

(to take this to an extreme, note that the string ]]> cannot be used inside CDATA... or... outside CDATA. but all the rest: np)

but the OP had < in an attribute and like you said: that is illegal. In addition, there also appeared a " in the attribute and without changing the surrounding quotes, it should be escaped. The attribute equals the XML declaration string. I think the OP does not want valid XML like this (note the quote change):

<pfarr name='&lt;?xml version="1.0" encoding="iso-8859-1"?>'>

but like this:

<?xml version="1.0" encoding="iso-8859-1"?>
<pfarr name="xyz">
  <pfarr name="dls">

which, interestingly, is precisely the way the XML looked in a post by the same person, at 6 feb 2007 about multiple sorts on element attributes. My guess is, that somehow the source got tangled during these months... ;)

Cheers,
-- Abel Braaksma

Current Thread