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 );
----------------------------------------------------------------------
-- 
View this message in context: 
http://old.nabble.com/Xerces-CPP-does-not-replace-tab-character-in-attribute-value-with-hexadecimal-char-reference-tp28157670p28157670.html
Sent from the Xerces - C - Users mailing list archive at Nabble.com.

Reply via email to