You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by Rajic Zeljko <Ze...@encorus.com> on 2003/07/09 09:03:56 UTC

escaping does not work properly

Hi,

I'm currently experiencing a strange behaviour when using Xerces to serialize a XML document: for some reason the ">" character does not get escaped to "&gt;" when adding it as attribute or element value.

To demonstrate what I mean I've attached a small Java Application. When running it, I receive the following output:

<?xml version="1.0" encoding="UTF-8"?>
<testcase name="testcasename" time="19:00:12">
    <error type="This is the testcase description: a tag &lt;descriptiontag> !!"
>This is the error text with the &lt;errortag> !!</error>
</testcase>

Instead I'd expect to receive the following:

<?xml version="1.0" encoding="UTF-8"?>
<testcase name="testcasename" time="19:00:12">
    <error type="This is the testcase description: a tag &lt;descriptiontag%gt; !!"
>This is the error text with the &lt;errortag&gt; !!</error>
</testcase>


I've tried the application with a older version of Xerces, but also with the current 2.4.0. Both with the same result.

As I can't imagine to be the first to see this behaviour I guess that I must doing something wrong. So it would be nice if someone could point me to my mistake.

And by the way: is it possible to escape more characters than only "<>&' with Xerces or SAX in common? For example also escaping the [] characters?

Regards,
Zeljko

Re: escaping does not work properly

Posted by Maksym Kovalenko <mk...@marketswitch.com>.
Why in this xml example start tag of 'error' element doesn't end with '>'?
I mean attribute 'type' defined with some odd looking string but then 
starts text node and > to close 'error' element is missing...

Rajic Zeljko wrote:

>Hi,
>
>I'm currently experiencing a strange behaviour when using Xerces to serialize a XML document: for some reason the ">" character does not get escaped to "&gt;" when adding it as attribute or element value.
>
>To demonstrate what I mean I've attached a small Java Application. When running it, I receive the following output:
>
><?xml version="1.0" encoding="UTF-8"?>
><testcase name="testcasename" time="19:00:12">
>    <error type="This is the testcase description: a tag &lt;descriptiontag> !!"
>  
>
>>This is the error text with the &lt;errortag> !!</error>
>>    
>>
></testcase>
>
>Instead I'd expect to receive the following:
>
><?xml version="1.0" encoding="UTF-8"?>
><testcase name="testcasename" time="19:00:12">
>    <error type="This is the testcase description: a tag &lt;descriptiontag%gt; !!"
>  
>
>>This is the error text with the &lt;errortag&gt; !!</error>
>>    
>>
></testcase>
>
>
>I've tried the application with a older version of Xerces, but also with the current 2.4.0. Both with the same result.
>
>As I can't imagine to be the first to see this behaviour I guess that I must doing something wrong. So it would be nice if someone could point me to my mistake.
>
>And by the way: is it possible to escape more characters than only "<>&' with Xerces or SAX in common? For example also escaping the [] characters?
>
>Regards,
>Zeljko
>  
>
>------------------------------------------------------------------------
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
>For additional commands, e-mail: xerces-j-user-help@xml.apache.org
>

-- 
------------------------------------------------------------------------

Maksym Kovalenko
Software Engineer
Marketswitch Corporation
http://www.marketswitch.com <http://www.marketswitch.com/>
108 Powers Court, Suite 225
Dulles, VA 20166
Phone: +1 (703) 444-6750 ext. 302
Fax: +1 (703) 444-6812



Re: escaping does not work properly

Posted by "K. Venugopal" <k....@sun.com>.
Hi Rajic ,

Refer to bug http://nagoya.apache.org/bugzilla/show_bug.cgi?id=18374.

Did you try with latest version of xerces ?
http://gump.covalent.net/jars/latest/xml-xerces2/

Regards,
venu



Rajic Zeljko wrote:

>Hi,
>
>I'm currently experiencing a strange behaviour when using Xerces to serialize a XML document: for some reason the ">" character does not get escaped to "&gt;" when adding it as attribute or element value.
>
>To demonstrate what I mean I've attached a small Java Application. When running it, I receive the following output:
>
><?xml version="1.0" encoding="UTF-8"?>
><testcase name="testcasename" time="19:00:12">
>    <error type="This is the testcase description: a tag &lt;descriptiontag> !!"
>  
>
>>This is the error text with the &lt;errortag> !!</error>
>>    
>>
></testcase>
>
>Instead I'd expect to receive the following:
>
><?xml version="1.0" encoding="UTF-8"?>
><testcase name="testcasename" time="19:00:12">
>    <error type="This is the testcase description: a tag &lt;descriptiontag%gt; !!"
>  
>
>>This is the error text with the &lt;errortag&gt; !!</error>
>>    
>>
></testcase>
>
>
>I've tried the application with a older version of Xerces, but also with the current 2.4.0. Both with the same result.
>
>As I can't imagine to be the first to see this behaviour I guess that I must doing something wrong. So it would be nice if someone could point me to my mistake.
>
>And by the way: is it possible to escape more characters than only "<>&' with Xerces or SAX in common? For example also escaping the [] characters?
>
>Regards,
>Zeljko
>  
>
>------------------------------------------------------------------------
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
>For additional commands, e-mail: xerces-j-user-help@xml.apache.org
>