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 sp...@gmx.net on 2002/09/02 16:11:08 UTC

Doctype in DOM

Hi all,

I'm using xerces-c 2.1.0 on Windows and I want to construct a DOM-tree
and write it into a file. Everything looks fine, but the doctype element
isn't correct. It should look like this:

 <!DOCTYPE root SYSTEM "file.dtd">


But I'm getting the following output:

 <!DOCTYPE root>


I also did some testing:

 DOMImplementation* impl =
DOMImplementationRegistry::getDOMImplementation(XMLString::transcode("Core"));
 DOMDocumentType* dtd =
impl->createDocumentType(XMLString::transcode("root"),
                                                 0,
                                                
XMLString::transcode("file.dtd"));
 DOMDocument* doc = impl->createDocument(0, XMLString::transcode("root"),
dtd);


 // for testing only
 cout << XMLString::transcode((doc->getDoctype())->getName()) << "\n";     
// output: "root"
 cout << XMLString::transcode((doc->getDoctype())->getSystemId()) << "\n"; 
// output: ""

I don't know, why the getSystemId method doesn't return "file.dtd".
What am I doing wrong? Is the argument for getDOMImplementation correct
(what
other values are possible - I only found "Core" in the sample files).



Thanks in advance,
Bjoern Lechmann

-- 
GMX - Die Kommunikationsplattform im Internet.
http://www.gmx.net


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


RE: Attribute default values in DTD is not available in the DOMDocument.

Posted by Erik Rydgren <er...@mandarinen.se>.
I say yes.

/ Erik

-----Original Message-----
From: Gareth Reakes [mailto:gareth@decisionsoft.com]
Sent: den 23 september 2002 19:11
To: xerces-c-dev@xml.apache.org
Subject: RE: Attribute default values in DTD is not available in the
DOMDocument.


OK,
	well this is the code thats the problem (in 
DOMDocumentImpl::importNode):

            if (smap != 0) {
                for(XMLSize_t i = 0; i < smap->getLength(); i++) {
                    tmap->setNamedItem(importNode(smap->item(i), true, 
false));
                }
            }
            // NOTE: At this time, the DOM definition of DocumentType
            // doesn't cover Elements and their Attributes. domimpl's
            // extentions in that area will not be preserved, even if
            // copying from domimpl to domimpl. We could special-case
            // that here. Arguably we should. Consider. ?????
            newnode = newdoctype;

It seems that this has not yet been discussed. What do people think? When 
you clone a document should you have access the the element info from the 
DTD? I would say yes. I will provide a patch if it is agreed that this 
should be the behaviour.


Gareth


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


RE: Attribute default values in DTD is not available in the DOMDocument.

Posted by Gareth Reakes <ga...@decisionsoft.com>.
OK,
	well this is the code thats the problem (in 
DOMDocumentImpl::importNode):

            if (smap != 0) {
                for(XMLSize_t i = 0; i < smap->getLength(); i++) {
                    tmap->setNamedItem(importNode(smap->item(i), true, 
false));
                }
            }
            // NOTE: At this time, the DOM definition of DocumentType
            // doesn't cover Elements and their Attributes. domimpl's
            // extentions in that area will not be preserved, even if
            // copying from domimpl to domimpl. We could special-case
            // that here. Arguably we should. Consider. ?????
            newnode = newdoctype;

It seems that this has not yet been discussed. What do people think? When 
you clone a document should you have access the the element info from the 
DTD? I would say yes. I will provide a patch if it is agreed that this 
should be the behaviour.


Gareth




On Mon, 23 Sep 2002, Gareth Reakes wrote:

> Hi,
> 	well this has been fun. Ive looked into this a bit now and think I 
> know whats going on. cloneNode is implemented by using importNode. 
> Unfortunately there is a difference in behaviour. 
> 
> >From the level 2 spec for importNode:
> 
> "Specified attribute nodes of the source element are imported, and the 
> generated Attr nodes are attached to the generated Element. Default 
> attributes are not copied, though if the document being imported into 
> defines default attributes for this element name, those are assigned."
> 
> >From the Level 2 spec for cloneNode:
> 
> "Cloning an Element copies all attributes and their values, including
> those generated by the XML processor to represent defaulted attributes"
> 
> 
> The code for importNode seems to be correct. 
> 
> for(XMLSize_t i=0;i<srcattr->getLength();++i)
>    {
>        DOMAttr *attr = (DOMAttr *) srcattr->item(i);
>        if (attr -> getSpecified()) { // not a default attribute
> 
> so this is a bug. Its not our fault though because this code was ported 
> from the java ;)
> 
> 
> Gareth
> 
> 
> On Mon, 23 Sep 2002, Erik Rydgren wrote:
> 
> > Well now it is time to set things streight.
> > The default values in DOM are in fact working *blush*.
> > Found it out during the test that Gareth did suggest. The extra code that I
> > suggested is not needed.
> > Somewhere deep down in the parser the default values are transferred into
> > the standard attribute list.
> > (There I got fooled by not reading all the hundred thousand lines of code
> > but just a subset. Silly me.)
> > 
> > BUT! After a document clone then the default values ARE in fact removed. So
> > if there is something that needs fixing it is the document clone process.
> > 
> > Sorry for taking up your time.
> > / Erik Rydgren
> > 
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
> > For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
> > 
> > 
> 
> 

-- 
Gareth Reakes, Head of Product Development  
DecisionSoft Ltd.            http://www.decisionsoft.com
Office: +44 (0) 1865 203192



---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


RE: Attribute default values in DTD is not available in the DOMDocument.

Posted by Gareth Reakes <ga...@decisionsoft.com>.
Hi,
	well this has been fun. Ive looked into this a bit now and think I 
know whats going on. cloneNode is implemented by using importNode. 
Unfortunately there is a difference in behaviour. 

>From the level 2 spec for importNode:

"Specified attribute nodes of the source element are imported, and the 
generated Attr nodes are attached to the generated Element. Default 
attributes are not copied, though if the document being imported into 
defines default attributes for this element name, those are assigned."

>From the Level 2 spec for cloneNode:

"Cloning an Element copies all attributes and their values, including
those generated by the XML processor to represent defaulted attributes"


The code for importNode seems to be correct. 

for(XMLSize_t i=0;i<srcattr->getLength();++i)
   {
       DOMAttr *attr = (DOMAttr *) srcattr->item(i);
       if (attr -> getSpecified()) { // not a default attribute

so this is a bug. Its not our fault though because this code was ported 
from the java ;)


Gareth


On Mon, 23 Sep 2002, Erik Rydgren wrote:

> Well now it is time to set things streight.
> The default values in DOM are in fact working *blush*.
> Found it out during the test that Gareth did suggest. The extra code that I
> suggested is not needed.
> Somewhere deep down in the parser the default values are transferred into
> the standard attribute list.
> (There I got fooled by not reading all the hundred thousand lines of code
> but just a subset. Silly me.)
> 
> BUT! After a document clone then the default values ARE in fact removed. So
> if there is something that needs fixing it is the document clone process.
> 
> Sorry for taking up your time.
> / Erik Rydgren
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
> 
> 

-- 
Gareth Reakes, Head of Product Development  
DecisionSoft Ltd.            http://www.decisionsoft.com
Office: +44 (0) 1865 203192



---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


RE: Attribute default values in DTD is not available in the DOMDocument.

Posted by Erik Rydgren <er...@mandarinen.se>.
Well now it is time to set things streight.
The default values in DOM are in fact working *blush*.
Found it out during the test that Gareth did suggest. The extra code that I
suggested is not needed.
Somewhere deep down in the parser the default values are transferred into
the standard attribute list.
(There I got fooled by not reading all the hundred thousand lines of code
but just a subset. Silly me.)

BUT! After a document clone then the default values ARE in fact removed. So
if there is something that needs fixing it is the document clone process.

Sorry for taking up your time.
/ Erik Rydgren


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


RE: Attribute default values in DTD is not available in the DOMDocument.

Posted by Gareth Reakes <ga...@decisionsoft.com>.
Hi again,
	thank god, I was being stupid. I can now access the attrs. Monday 
morning thinking. I do think that the default attr code may be a bit 
broken though.

Gareth



On Mon, 23 Sep 2002, Gareth Reakes wrote:

> Hi,
> 	what version of xerces are you using? I still cant get any 
> attributes if I use the following xml:
> 
> <!DOCTYPE greeting SYSTEM "foo.dtd"><greeting xmlns="foo" ls="ping" />
> 
> <!ELEMENT greeting EMPTY>
> <!ATTLIST greeting
>    ls CDATA #IMPLIED
>    xmlns CDATA #IMPLIED >
> 
> 
> let alone if I have default attrs!! I have now tried this with the CVS 
> tree as well as 2.0. I have difficulty in believing that this has not been 
> noticed by users as it seems fairly fundamental. Does anyone else see this 
> behaviour? If I remove the DOCTYPE then I can access the attributes via 
> any of the get methods.
> 
> I believe that you are correct in thinking that the default attrs should
> be available through the getAttrs methods. Spec says
> 
> "The Attr value as a string, or the empty string if that attribute does 
> not have a specified or default value."
> 
> All the removing stuff is dealt with properly inside of DOMAttrMap but the 
> get stuff is not overridden. If it is agreed that this is the correct 
> behaviour then perhaps we should put the code in there. 
> 
> 
> Gareth
> 
> 
> On Fri, 20 Sep 2002, Erik Rydgren wrote:
> 
> > I did some serious debugging and have tracked my problem down to the
> > document cloning process. Everything looks dandy until then except that I
> > can not access the default attributes but at least they are there in
> > DOMElementImpl::fDefaultAttributes.
> > So I modified some fuctions to be able to access the default values.
> > 
> > *************************************************************************
> > const XMLCh * DOMElementImpl::getAttribute(const XMLCh *nam) const
> > {
> >     static const XMLCh emptyString[]  = {0};
> >     DOMNode * attr=0;
> > 
> >     attr=fAttributes->getNamedItem(nam);
> > 
> >     if (!attr && fAttributes->hasDefaults())
> >       attr=fDefaultAttributes->getNamedItem(nam);
> > 
> >     const XMLCh *retString = emptyString;
> >     if (attr != 0)
> >         retString = attr->getNodeValue();
> > 
> >     return retString;
> > };
> > *************************************************************************
> > DOMAttr *DOMElementImpl::getAttributeNode(const XMLCh *nam) const
> > {
> >     DOMNode * attr=0;
> >     attr=fAttributes->getNamedItem(nam);
> >     if (!attr && fAttributes->hasDefaults())
> >       attr=fDefaultAttributes->getNamedItem(nam);
> >     return  (DOMAttr*) attr;
> > };
> > *************************************************************************
> > 
> > I'm not sure how the DOM API is supposed to work with default values.
> > Should getAttributes also return default value attributes?
> > If it should, then the solution needs to be modified a bit.
> > 
> > I came to realize that a document clone totally removes all default values.
> > How it is supposed to work?
> > Personally I found the new handy function adoptDocument() in the parser so I
> > do not sweat about the cloning problem anymore ( plus that I saved tons of
> > CPU cykles. YES! :o) )
> > 
> > Regards
> > Erik Rydgren
> > 
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
> > For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
> > 
> > 
> 
> 

-- 
Gareth Reakes, Head of Product Development  
DecisionSoft Ltd.            http://www.decisionsoft.com
Office: +44 (0) 1865 203192



---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


RE: Attribute default values in DTD is not available in the DOMDocument.

Posted by Gareth Reakes <ga...@decisionsoft.com>.
Hi,
	what version of xerces are you using? I still cant get any 
attributes if I use the following xml:

<!DOCTYPE greeting SYSTEM "foo.dtd"><greeting xmlns="foo" ls="ping" />

<!ELEMENT greeting EMPTY>
<!ATTLIST greeting
   ls CDATA #IMPLIED
   xmlns CDATA #IMPLIED >


let alone if I have default attrs!! I have now tried this with the CVS 
tree as well as 2.0. I have difficulty in believing that this has not been 
noticed by users as it seems fairly fundamental. Does anyone else see this 
behaviour? If I remove the DOCTYPE then I can access the attributes via 
any of the get methods.

I believe that you are correct in thinking that the default attrs should
be available through the getAttrs methods. Spec says

"The Attr value as a string, or the empty string if that attribute does 
not have a specified or default value."

All the removing stuff is dealt with properly inside of DOMAttrMap but the 
get stuff is not overridden. If it is agreed that this is the correct 
behaviour then perhaps we should put the code in there. 


Gareth


On Fri, 20 Sep 2002, Erik Rydgren wrote:

> I did some serious debugging and have tracked my problem down to the
> document cloning process. Everything looks dandy until then except that I
> can not access the default attributes but at least they are there in
> DOMElementImpl::fDefaultAttributes.
> So I modified some fuctions to be able to access the default values.
> 
> *************************************************************************
> const XMLCh * DOMElementImpl::getAttribute(const XMLCh *nam) const
> {
>     static const XMLCh emptyString[]  = {0};
>     DOMNode * attr=0;
> 
>     attr=fAttributes->getNamedItem(nam);
> 
>     if (!attr && fAttributes->hasDefaults())
>       attr=fDefaultAttributes->getNamedItem(nam);
> 
>     const XMLCh *retString = emptyString;
>     if (attr != 0)
>         retString = attr->getNodeValue();
> 
>     return retString;
> };
> *************************************************************************
> DOMAttr *DOMElementImpl::getAttributeNode(const XMLCh *nam) const
> {
>     DOMNode * attr=0;
>     attr=fAttributes->getNamedItem(nam);
>     if (!attr && fAttributes->hasDefaults())
>       attr=fDefaultAttributes->getNamedItem(nam);
>     return  (DOMAttr*) attr;
> };
> *************************************************************************
> 
> I'm not sure how the DOM API is supposed to work with default values.
> Should getAttributes also return default value attributes?
> If it should, then the solution needs to be modified a bit.
> 
> I came to realize that a document clone totally removes all default values.
> How it is supposed to work?
> Personally I found the new handy function adoptDocument() in the parser so I
> do not sweat about the cloning problem anymore ( plus that I saved tons of
> CPU cykles. YES! :o) )
> 
> Regards
> Erik Rydgren
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
> 
> 

-- 
Gareth Reakes, Head of Product Development  
DecisionSoft Ltd.            http://www.decisionsoft.com
Office: +44 (0) 1865 203192



---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


Re: bug in AbstractDOMParser::resetPool()

Posted by Tinny Ng <tn...@ca.ibm.com>.
Erik,

You are right.   Will fix.  Or if you like, please open a bugzilla bug for
better tracking.   Thanks!

Tinny
----- Original Message -----
From: "Erik Rydgren" <er...@mandarinen.se>
To: <xe...@xml.apache.org>; <er...@mandarinen.se>
Sent: Friday, September 20, 2002 1:26 PM
Subject: bug in AbstractDOMParser::resetPool()


> Upps! Found a bug in AbstractDOMParser::resetPool().
>
> void AbstractDOMParser::resetPool()
> {
>     //  We cannot enter here while a regular parse is in progress.
>     if (fParseInProgress)
>         ThrowXML(IOException, XMLExcepts::Gen_ParseInProgress);
>
>     if (fDocumentVector)
>         fDocumentVector->removeAllElements();
>
>     delete fDocument;
>     fDocument = 0;
> }
>
> should be
>
> void AbstractDOMParser::resetPool()
> {
>     //  We cannot enter here while a regular parse is in progress.
>     if (fParseInProgress)
>         ThrowXML(IOException, XMLExcepts::Gen_ParseInProgress);
>
>     if (fDocumentVector)
>         fDocumentVector->removeAllElements();
>
>     if (!fDocumentAdoptedByUser)   <--- NOTICE!
>       delete fDocument;
>
>     fDocument = 0;
> }
>
> Regards
> Erik Rydgren
> Mandarin IT
> Sweden
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


bug in AbstractDOMParser::resetPool()

Posted by Erik Rydgren <er...@mandarinen.se>.
Upps! Found a bug in AbstractDOMParser::resetPool().

void AbstractDOMParser::resetPool()
{
    //  We cannot enter here while a regular parse is in progress.
    if (fParseInProgress)
        ThrowXML(IOException, XMLExcepts::Gen_ParseInProgress);

    if (fDocumentVector)
        fDocumentVector->removeAllElements();

    delete fDocument;
    fDocument = 0;
}

should be

void AbstractDOMParser::resetPool()
{
    //  We cannot enter here while a regular parse is in progress.
    if (fParseInProgress)
        ThrowXML(IOException, XMLExcepts::Gen_ParseInProgress);

    if (fDocumentVector)
        fDocumentVector->removeAllElements();

    if (!fDocumentAdoptedByUser)   <--- NOTICE!
      delete fDocument;

    fDocument = 0;
}

Regards
Erik Rydgren
Mandarin IT
Sweden


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


RE: Attribute default values in DTD is not available in the DOMDocument.

Posted by Erik Rydgren <er...@mandarinen.se>.
I did some serious debugging and have tracked my problem down to the
document cloning process. Everything looks dandy until then except that I
can not access the default attributes but at least they are there in
DOMElementImpl::fDefaultAttributes.
So I modified some fuctions to be able to access the default values.

*************************************************************************
const XMLCh * DOMElementImpl::getAttribute(const XMLCh *nam) const
{
    static const XMLCh emptyString[]  = {0};
    DOMNode * attr=0;

    attr=fAttributes->getNamedItem(nam);

    if (!attr && fAttributes->hasDefaults())
      attr=fDefaultAttributes->getNamedItem(nam);

    const XMLCh *retString = emptyString;
    if (attr != 0)
        retString = attr->getNodeValue();

    return retString;
};
*************************************************************************
DOMAttr *DOMElementImpl::getAttributeNode(const XMLCh *nam) const
{
    DOMNode * attr=0;
    attr=fAttributes->getNamedItem(nam);
    if (!attr && fAttributes->hasDefaults())
      attr=fDefaultAttributes->getNamedItem(nam);
    return  (DOMAttr*) attr;
};
*************************************************************************

I'm not sure how the DOM API is supposed to work with default values.
Should getAttributes also return default value attributes?
If it should, then the solution needs to be modified a bit.

I came to realize that a document clone totally removes all default values.
How it is supposed to work?
Personally I found the new handy function adoptDocument() in the parser so I
do not sweat about the cloning problem anymore ( plus that I saved tons of
CPU cykles. YES! :o) )

Regards
Erik Rydgren


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


Re: Attribute default values in DTD is not available in the DOMDocument.

Posted by Gareth Reakes <ga...@decisionsoft.com>.
Hi,
	Ive had a quick look and it seems to be a little bit broken. Look 
at the following XML and DTD files

<!DOCTYPE greeting SYSTEM "foo.dtd"><greeting xmlns="foo" ls="ping" />



<!ELEMENT greeting EMPTY>
<!ATTLIST greeting
   ls CDATA #IMPLIED
   xmlns CDATA #IMPLIED
   pointless (yes|no) 'yes'>



selecting the attributes from greeting now returns a null DOMNamedNodeMap. 
If you remove the DOCTYPE from the XML you get the expected 2 attributes! 
I don't currently have a completely clean tree so if someone could confirm 
this then I would appreciate it. I have to go and get drunk now :)


Gareth


On Fri, 20 Sep 2002, Erik Rydgren wrote:

> Hi all!
> 
> Thanks for a great product. Although I'm currently having problems.
> We have a HUGE dtd which defines elements with tons of attributes (with
> default values).
> I need to use the default values as we are trying to reduce the actual
> document size by only sending changed values.
> But the catch is that Xerces doesn't work as the documentation says.
> 
> -- From the documentation --
> 
> const XMLCh * DOMElement::getAttribute (  const XMLCh * name ) const [pure
> virtual]
> 
>    Retrieves an attribute value by name.
> 
>  Parameters:
>    name   The name of the attribute to retrieve.
> 
>  Returns:
>    The DOMAttr value as a string, or the empty string if that attribute does
> not have a specified or default value.
> 
> -- End documentation --
> 
> According to this I will get the default value if the value is not specified
> in the document, but I don't.
> The default values is not available in the DOMElement. I have even tried to
> find them in DOMElementImpl::fDefaultAttributes (which is not used in the
> standard implementation) but to no luck.
> 
> Am I missing something or is this a bug? If it is. How do I fix it? I'll be
> glad to help but I need some direction as I do not have time to grasp the
> whole Xerces source code right now :)
> 
> Best regards
> Erik Rydgren
> Mandarin IT
> Sweden
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
> 
> 

-- 
Gareth Reakes, Head of Product Development  
DecisionSoft Ltd.            http://www.decisionsoft.com
Office: +44 (0) 1865 203192



---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


Attribute default values in DTD is not available in the DOMDocument.

Posted by Erik Rydgren <er...@mandarinen.se>.
Hi all!

Thanks for a great product. Although I'm currently having problems.
We have a HUGE dtd which defines elements with tons of attributes (with
default values).
I need to use the default values as we are trying to reduce the actual
document size by only sending changed values.
But the catch is that Xerces doesn't work as the documentation says.

-- From the documentation --

const XMLCh * DOMElement::getAttribute (  const XMLCh * name ) const [pure
virtual]

   Retrieves an attribute value by name.

 Parameters:
   name   The name of the attribute to retrieve.

 Returns:
   The DOMAttr value as a string, or the empty string if that attribute does
not have a specified or default value.

-- End documentation --

According to this I will get the default value if the value is not specified
in the document, but I don't.
The default values is not available in the DOMElement. I have even tried to
find them in DOMElementImpl::fDefaultAttributes (which is not used in the
standard implementation) but to no luck.

Am I missing something or is this a bug? If it is. How do I fix it? I'll be
glad to help but I need some direction as I do not have time to grasp the
whole Xerces source code right now :)

Best regards
Erik Rydgren
Mandarin IT
Sweden



---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


Re: Doctype in DOM

Posted by Tinny Ng <tn...@ca.ibm.com>.
Bjoern,

You found a bug!   There is a typo in DOMDocumentTypeImpl::setOwnerDocument,
I've just checked in the fix.  FYI here is the diff:

   RCS file:
/home/cvs/xml-xerces/c/src/xercesc/dom/impl/DOMDocumentTypeImpl.cpp,v
   retrieving revision 1.13

   diff -r1.13 DOMDocumentTypeImpl.cpp
   236c236
   < systemId = docImpl->cloneString(internalSubset);
   ---
   > internalSubset = docImpl->cloneString(internalSubset);


Thanks for reporting.

Tinny


----- Original Message -----
From: <sp...@gmx.net>
To: <xe...@xml.apache.org>
Sent: Monday, September 02, 2002 10:11 AM
Subject: Doctype in DOM


> Hi all,
>
> I'm using xerces-c 2.1.0 on Windows and I want to construct a DOM-tree
> and write it into a file. Everything looks fine, but the doctype element
> isn't correct. It should look like this:
>
>  <!DOCTYPE root SYSTEM "file.dtd">
>
>
> But I'm getting the following output:
>
>  <!DOCTYPE root>
>
>
> I also did some testing:
>
>  DOMImplementation* impl =
>
DOMImplementationRegistry::getDOMImplementation(XMLString::transcode("Core")
);
>  DOMDocumentType* dtd =
> impl->createDocumentType(XMLString::transcode("root"),
>                                                  0,
>
> XMLString::transcode("file.dtd"));
>  DOMDocument* doc = impl->createDocument(0, XMLString::transcode("root"),
> dtd);
>
>
>  // for testing only
>  cout << XMLString::transcode((doc->getDoctype())->getName()) << "\n";
> // output: "root"
>  cout << XMLString::transcode((doc->getDoctype())->getSystemId()) << "\n";
> // output: ""
>
> I don't know, why the getSystemId method doesn't return "file.dtd".
> What am I doing wrong? Is the argument for getDOMImplementation correct
> (what
> other values are possible - I only found "Core" in the sample files).
>
>
>
> Thanks in advance,
> Bjoern Lechmann
>
> --
> GMX - Die Kommunikationsplattform im Internet.
> http://www.gmx.net
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org