Conversion of special characters not working

View: New views
2 Messages — Rating Filter:   Alert me  

Conversion of special characters not working

by Mick - :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


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

by Alberto Massari :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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
>  

LightInTheBox - Buy quality products at wholesale price!