> > theSerializer->canSetFeature(XMLUni::fgUTF8EncodingString,
> true) will still
>
> There is no such feature.
>
> > > (theSerializer->canSetFeature(XMLUni::fgUTF16EncodingString, true))
> > >
> > > theSerializer->setFeature(XMLUni::fgUTF16EncodingString, true);
>
> No such feature.

They're both on the XMLUni man page at
http://xml.apache.org/xerces-c/apiDocs/classXMLUni.html.  I've seen them
used in code examples.  What's the dealio?

> > >           XMLFormatTarget *myFormTarget = new
> > > LocalFileFormatTarget(X(pszFilePath));
> > >
> > >           theSerializer->writeNode(myFormTarget, *pRootElement);
>
> Here lies the problem. You are printing out the root element as
> opposed to
> the document. The root element does not have an XML Decl.

Eureka!  That was it!

The file is now written in UTF-16 with a XML declaration.  However, now
*all* calls to canSetFeature return false.  Coud it be something in the
DOMImplementation?

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

        DOMDocument* pDoc = impl->createDocument();

        pDoc->setEncoding(X("UTF-16"));
        pDoc->setStandalone(true);
        pDoc->setVersion(X("1.0"));

        DOMElement* pRootElement = CreateElementFromNode(pNode, pDoc);

        pDoc->appendChild(pRootElement);

        DOMWriter         *theSerializer =
((DOMImplementationLS*)impl)->createDOMWriter();

        // All the following calls return false

        if (theSerializer->canSetFeature(XMLUni::fgDOMWRTSplitCdataSections, true))
                theSerializer->setFeature(XMLUni::fgDOMWRTSplitCdataSections, true);

        if (theSerializer->canSetFeature(XMLUni::fgDOMWRTDiscardDefaultContent,
true))
                theSerializer->setFeature(XMLUni::fgDOMWRTDiscardDefaultContent, true);

        if (theSerializer->canSetFeature(XMLUni::fgDOMWRTFormatPrettyPrint, true))
                theSerializer->setFeature(XMLUni::fgDOMWRTFormatPrettyPrint, true);

        if
(theSerializer->canSetFeature(XMLUni::fgDOMWRTWhitespaceInElementContent,
true))
                theSerializer->setFeature(XMLUni::fgDOMWRTWhitespaceInElementContent,
true);

How do I get my pretty print?



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to