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 Jesse Pelton <js...@PKC.com> on 2000/07/27 14:48:15 UTC

DOMPrint sample

I'm using the DOMPrint sample as a model for my own utility function to dump
a DOM tree to an MFC CString.  The function "ostream& operator<<(ostream&
target, DOM_Node& toWrite)" includes the following:

<code>
        case DOM_Node::XML_DECL_NODE:
        {
            DOMString  str;

            *gFormatter << gXMLDecl1 << ((DOM_XMLDecl
&)toWrite).getVersion();

            *gFormatter << gXMLDecl2 << gEncodingName;
</code>

I'm not sure why this code uses gEncodingName, rather than
gFormatter->getEncodingName().  Is it purely for efficiency (or laziness),
or is it for some other reason that I'm missing?  I don't want to have a
global, class member, or parameter that I pass around if I don't need it; if
gFormatter->getEncodingName() is authoritative, I want to use it.

I guess another way to put this is: is it ever legal to specify a different
encoding in the document's XML declaration than the output encoding that is
used by XMLFormatter()?  It seems like the answer should be no.  (If I'm
right, I'd suggest changing DOMPrint.cpp, so later users don't have to
wrestle with this question.)

-jesse-

Re: DOMPrint sample

Posted by Dean Roddey <dr...@charmedquark.com>.
> I guess another way to put this is: is it ever legal to specify a
different
> encoding in the document's XML declaration than the output encoding that
is
> used by XMLFormatter()?  It seems like the answer should be no.  (If I'm
> right, I'd suggest changing DOMPrint.cpp, so later users don't have to
> wrestle with this question.)
>

Absolutey that would be legal, even desireable. For instance, no matter what
the input encoding, you might want to spit it out as UTF-8.

--------------------------
Dean Roddey
The CIDLib C++ Frameworks
Charmed Quark Software
droddey@charmedquark.com
http://www.charmedquark.com

"You young, and you gotcha health. Whatchoo wanna job fer?"