You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-users@xerces.apache.org by Mick - <mi...@hotmail.com> on 2008/09/15 01:30:07 UTC
Conversion of special characters not working
I have attempted to create a DOM writer using the documented examples that came with Xerces-C++ v2.8, without success.
The problem is, the attribute-name pair (Name="Blah") is written to file as (Name="<Blah>")... note the ">" not being converted to ">".
I have traced the problem to the XMLFormatter class, and believe the 'EscapeFlags' value nees to be set to 'StdEscapes'. Currently it defaults to 'AttrEscapes'. This is what I have derrived from looking at the code, however this is open to debate/suggestions.
If this is the case, my question is, how do I set the EscapeFlags value to StdEscapes cosidering I have used the following to write the DOM tree to file:
m_serialiser->setFeature( XERCES::XMLUni::fgDOMWRTFormatPrettyPrint, true );
XERCES::XMLFormatTarget *target = new XERCES::LocalFileFormatTarget( filename );
m_serialiser->writeNode( target, *m_xmlDocument );
target->flush( );
delete target;
_________________________________________________________________
Are you a friend magnet? Play now to win prizes for you and your friends!
http://clk.atdmt.com/GBL/go/106906016/direct/01/?href=http://www.friendmagnet.com.au
Re: Conversion of special characters not working
Posted by Alberto Massari <am...@datadirect.com>.
Hi Mick,
the XML specs (http://www.w3.org/TR/xml/#NT-AttValue) states that the
attribute value should not contain <, & and " (or '); the > character is
allowed to be written without being escaped.
[10] |AttValue| ::= |'"' ([^<&"] | Reference
<http://www.w3.org/TR/xml/#NT-Reference>)* '"' |
|| "'" ([^<&'] | Reference <http://www.w3.org/TR/xml/#NT-Reference>)*
"'"|
Alberto
Mick - wrote:
> I have attempted to create a DOM writer using the documented examples that came with Xerces-C++ v2.8, without success.
> The problem is, the attribute-name pair (Name="Blah") is written to file as (Name="<Blah>")... note the ">" not being converted to ">".
> I have traced the problem to the XMLFormatter class, and believe the 'EscapeFlags' value nees to be set to 'StdEscapes'. Currently it defaults to 'AttrEscapes'. This is what I have derrived from looking at the code, however this is open to debate/suggestions.
>
> If this is the case, my question is, how do I set the EscapeFlags value to StdEscapes cosidering I have used the following to write the DOM tree to file:
>
> m_serialiser->setFeature( XERCES::XMLUni::fgDOMWRTFormatPrettyPrint, true );
> XERCES::XMLFormatTarget *target = new XERCES::LocalFileFormatTarget( filename );
> m_serialiser->writeNode( target, *m_xmlDocument );
> target->flush( );
> delete target;
>
> _________________________________________________________________
> Are you a friend magnet? Play now to win prizes for you and your friends!
> http://clk.atdmt.com/GBL/go/106906016/direct/01/?href=http://www.friendmagnet.com.au
>