You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by "AESYS S.p.A. [Enzo Arlati]" <en...@aesys.it> on 2005/09/20 14:00:45 UTC

convert the entities ' and "

I build a DOM document and inside a Node I put some string with the standard
entities ( ie. & < > ' and " ).
The first 3 entities are converted in their equivalent entity reference
 ie. &amp; &lt; &gt; )
while the last 2 are not converted ( as show in the example belowe.
What can I do in order to tell the xerces to replace it with their enity
ref.
Please , if possible, send me an example.

    DOMImplementation * impl =
DOMImplementationRegistry::getDOMImplementation( X("LS") );

    if( impl != NULL )
    {
       DOMDocument * pDoc = impl->createDocument( 0, X("Messaggio"), 0 );
       pDoc->setEncoding( X("UTF-16") );
       DOMElement * pRoot = pDoc->getDocumentElement();
       DOMElement * pTest = pDoc->createElement( X("TEST2") );
       pRoot->appendChild( pTest );
       stmp = " std_entities: & < > \" ' ";
       dtxt = pDoc->createTextNode( X( stmp.c_str()));
       pTest->appendChild( dtxt );
       .............
    }

DOCUMENT: <?xml version="1.0" encoding="UTF-16" standalone="no" ?>
<Messaggio><TEST2> std_entities: &amp; &lt; &gt; " ' </TEST2></Messaggio>

Regards, Enzo


---------------------------------------------------------------------
To unsubscribe, e-mail: c-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: c-dev-help@xerces.apache.org


Re: convert the entities ' and "

Posted by Alberto Massari <am...@datadirect.com>.
Hi Enzo,
XML requires that ' and " should only be escaped when used inside 
attribute values (and even in that case, only the one that has been 
actually used to delimit the attribute value).

Alberto

At 14.00 20/09/2005 +0200, AESYS S.p.A. [Enzo Arlati] wrote:

>I build a DOM document and inside a Node I put some string with the standard
>entities ( ie. & < > ' and " ).
>The first 3 entities are converted in their equivalent entity reference
>  ie. &amp; &lt; &gt; )
>while the last 2 are not converted ( as show in the example belowe.
>What can I do in order to tell the xerces to replace it with their enity
>ref.
>Please , if possible, send me an example.
>
>     DOMImplementation * impl =
>DOMImplementationRegistry::getDOMImplementation( X("LS") );
>
>     if( impl != NULL )
>     {
>        DOMDocument * pDoc = impl->createDocument( 0, X("Messaggio"), 0 );
>        pDoc->setEncoding( X("UTF-16") );
>        DOMElement * pRoot = pDoc->getDocumentElement();
>        DOMElement * pTest = pDoc->createElement( X("TEST2") );
>        pRoot->appendChild( pTest );
>        stmp = " std_entities: & < > \" ' ";
>        dtxt = pDoc->createTextNode( X( stmp.c_str()));
>        pTest->appendChild( dtxt );
>        .............
>     }
>
>DOCUMENT: <?xml version="1.0" encoding="UTF-16" standalone="no" ?>
><Messaggio><TEST2> std_entities: &amp; &lt; &gt; " ' </TEST2></Messaggio>
>
>Regards, Enzo
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: c-dev-unsubscribe@xerces.apache.org
>For additional commands, e-mail: c-dev-help@xerces.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: c-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: c-dev-help@xerces.apache.org


RE: convert the entities ' and "

Posted by Matthias Niggemeier <li...@tthias.de>.
Enzo,
I think you are confusing XML and HTML. In fact, there is no
entitiy ref für " or ' (unless you define them). It may depend
on the used encoding if these chars have to be masked, but
within UTF16 you can use them as in your mail.

Regards

Matthias 

> -----Original Message-----
> From: AESYS S.p.A. [Enzo Arlati] [mailto:enzo.arlati@aesys.it] 
> Sent: Tuesday, September 20, 2005 2:01 PM
> To: C-Dev@Xerces. Apache. Org (E-mail)
> Subject: convert the entities ' and "
> 
> 
> I build a DOM document and inside a Node I put some string 
> with the standard
> entities ( ie. & < > ' and " ).
> The first 3 entities are converted in their equivalent entity 
> reference
>  ie. &amp; &lt; &gt; )
> while the last 2 are not converted ( as show in the example belowe.
> What can I do in order to tell the xerces to replace it with 
> their enity
> ref.
> Please , if possible, send me an example.
> 
>     DOMImplementation * impl =
> DOMImplementationRegistry::getDOMImplementation( X("LS") );
> 
>     if( impl != NULL )
>     {
>        DOMDocument * pDoc = impl->createDocument( 0, 
> X("Messaggio"), 0 );
>        pDoc->setEncoding( X("UTF-16") );
>        DOMElement * pRoot = pDoc->getDocumentElement();
>        DOMElement * pTest = pDoc->createElement( X("TEST2") );
>        pRoot->appendChild( pTest );
>        stmp = " std_entities: & < > \" ' ";
>        dtxt = pDoc->createTextNode( X( stmp.c_str()));
>        pTest->appendChild( dtxt );
>        .............
>     }
> 
> DOCUMENT: <?xml version="1.0" encoding="UTF-16" standalone="no" ?>
> <Messaggio><TEST2> std_entities: &amp; &lt; &gt; " ' 
> </TEST2></Messaggio>
> 
> Regards, Enzo
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: c-dev-unsubscribe@xerces.apache.org
> For additional commands, e-mail: c-dev-help@xerces.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: c-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: c-dev-help@xerces.apache.org


RE: convert the entities ' and "

Posted by Matthias Niggemeier <M...@thias.de>.
Enzo,
I think you are confusing XML and HTML. In fact, there is no
entitiy ref für " or ' (unless you define them). It may depend
on the used encoding if these chars have to be masked, but
within UTF16 you can use them as in your mail.

Regards

Matthias 

> -----Original Message-----
> From: AESYS S.p.A. [Enzo Arlati] [mailto:enzo.arlati@aesys.it] 
> Sent: Tuesday, September 20, 2005 2:01 PM
> To: C-Dev@Xerces. Apache. Org (E-mail)
> Subject: convert the entities ' and "
> 
> 
> I build a DOM document and inside a Node I put some string 
> with the standard
> entities ( ie. & < > ' and " ).
> The first 3 entities are converted in their equivalent entity 
> reference
>  ie. &amp; &lt; &gt; )
> while the last 2 are not converted ( as show in the example belowe.
> What can I do in order to tell the xerces to replace it with 
> their enity
> ref.
> Please , if possible, send me an example.
> 
>     DOMImplementation * impl =
> DOMImplementationRegistry::getDOMImplementation( X("LS") );
> 
>     if( impl != NULL )
>     {
>        DOMDocument * pDoc = impl->createDocument( 0, 
> X("Messaggio"), 0 );
>        pDoc->setEncoding( X("UTF-16") );
>        DOMElement * pRoot = pDoc->getDocumentElement();
>        DOMElement * pTest = pDoc->createElement( X("TEST2") );
>        pRoot->appendChild( pTest );
>        stmp = " std_entities: & < > \" ' ";
>        dtxt = pDoc->createTextNode( X( stmp.c_str()));
>        pTest->appendChild( dtxt );
>        .............
>     }
> 
> DOCUMENT: <?xml version="1.0" encoding="UTF-16" standalone="no" ?>
> <Messaggio><TEST2> std_entities: &amp; &lt; &gt; " ' 
> </TEST2></Messaggio>
> 
> Regards, Enzo
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: c-dev-unsubscribe@xerces.apache.org
> For additional commands, e-mail: c-dev-help@xerces.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: c-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: c-dev-help@xerces.apache.org