Little more info.

Even if I setEncoding(X(UTF-8")),
theSerializer->canSetFeature(XMLUni::fgUTF8EncodingString, true) will still
return false, and the xml declaration is not written to the file (and not in
pretty print), though the file is written in UTF-8.

So I must be doing something fundamentally wrong.

Any ideas?

> -----Original Message-----
> From: Bren Lynne [mailto:[EMAIL PROTECTED]
> Sent: Monday, October 20, 2003 1:12 PM
> To: [EMAIL PROTECTED]
> Subject: RE: DOMwriter and xml declaration
>
>
>
> Thanks for the replies.
>
> Here's my code:
>
>               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);
>
>               DOMWriter *theSerializer =
> ((DOMImplementationLS*)impl)->createDOMWriter();
>
>               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);
>
>               // see note below
>               if
> (theSerializer->canSetFeature(XMLUni::fgUTF16EncodingString, true))
>
> theSerializer->setFeature(XMLUni::fgUTF16EncodingString, true);
>
>               XMLFormatTarget *myFormTarget = new
> LocalFileFormatTarget(X(pszFilePath));
>
>               theSerializer->writeNode(myFormTarget, *pRootElement);
>
> I notice that theSerializer->canSetFeature(XMLUni::fgUTF16EncodingString,
> true) returns false.  This must be my problem.  Why would this be
> the case?
>
> Originally I had all the doc creation code after the writer
> stuff.  Thought
> this might be the problem, but it appears not.
>
> BTW setVersion(X("2.0")) cause an exception.  Not even sure this
> is valid --
> just experimenting.
>
> Any suggestions?
>
>
> > -----Original Message-----
> > From: Gareth Reakes [mailto:[EMAIL PROTECTED]
> > Sent: Monday, October 20, 2003 12:08 PM
> > To: [EMAIL PROTECTED]
> > Subject: Re: DOMwriter and xml declaration
> >
> >
> > Hi,
> >     A look at the current code gives this:
> >
> >             // We always print out the xmldecl no matter whether it is
> >             // present in the original XML instance document or not.
> >             //
> >             const XMLCh* versionNo = (docu->getVersion()) ?
> > docu->getVersion() : gXMLDecl_ver10;
> >             *fFormatter << gXMLDecl_VersionInfo << versionNo <<
> > gXMLDecl_separator;
> >
> >
> >
> > and in my experience I always get an XML decl. What version are
> > you using?
> > If it is the most recent would you post a snippet of your code?
> >
> > Gareth
> >
> >
> > --
> > Gareth Reakes, Head of Product Development  +44-1865-203192
> > DecisionSoft Limited                        http://www.decisionsoft.com
> > XML Development and Services
> >
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>


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

Reply via email to