If you invoke

pRow1->setAttribute(L"description", L"	The vale of PI");

what you are writing is the literal "	", not a tab character. Have you 
tried writing the same content as in the Java version,

pRow1->setAttribute(L"description", L"test tab \t,     and \x09 as	 value" 
);

Alberto


On 4/6/2010 11:20 PM, ritesh.dhope wrote:
I have a sample xerces writer code to create an attribute with tab character
in value. When I write the xml file out, the tab character is preserved and
written as literal tab. I want to convert this tab character to its
hexadecimal char reference (	) so that this tab character can be parsed
back. I tried the same code using Xerces-J and it is replacing the tab
character with hexadecimal char reference.

Here is the code snippets.
-------------------
C++
-------------------
        XMLPlatformUtils::Initialize();

        DOMImplementation * pDOMImplementation = NULL;

        pDOMImplementation =
DOMImplementationRegistry::getDOMImplementation(XMLString::transcode("core"));

        DOMDocument * pDOMDocument = NULL;


        pDOMDocument = pDOMImplementation->createDocument(0, L"Hello_World", 0);



        DOMElement * pRootElement = NULL;
        pRootElement = pDOMDocument->getDocumentElement();



        DOMElement * pRow = NULL;


        pRow = pDOMDocument->createElement(L"row");
     pRow->setAttribute(L"description", L"\tThe value of PI");
        pRootElement->appendChild(pRow);

        DOMElement * pRow1 = NULL;
        pRow1 = pDOMDocument->createElement(L"row");
        pRow1->setAttribute(L"description", L"	The vale of PI");
        pRootElement->appendChild(pRow1);

        DOMElement * pRow2 = NULL;


        pRow2 = pDOMDocument->createElement(L"row");
     pRow2->setAttribute(L"description", L"\nThe value of PI");
        pRootElement->appendChild(pRow2);

        DOMWriter *pwriter = pDOMImplementation->createDOMWriter();
        XMLFormatTarget *pTarget = new
LocalFileFormatTarget("f:\\june1\\june.xml");


        pwriter->writeNode(pTarget, *pDOMDocument);
-------------------------------------------------------------------------

------------------
Java
------------------
             Document zTest =
DocumentBuilderFactoryImpl.newInstance().newDocumentBuilder().newDocument();
             Element base = zTest.createElement( "Base" );
             base.setAttribute( "test", "test tab \t,     and \u0009 as	
value" );
             zTest.appendChild( base );

             Serializer z = new XMLSerializer();

             z.setOutputByteStream( System.out );
             z.asDOMSerializer().serialize( zTest );
----------------------------------------------------------------------

Reply via email to