Hi,
with the DOM_Document function createElement, i am trying to create an
element that has an attribute of type ID as defined in the DTD.
When I set this attribute, it is supposed to be added in the ID table of
the document, but it does not work with Xerces 1.5. Is this feature not
implemented yet or
is this a bug???
Here is a code example...
The DTD file (test.dtd):
<!ELEMENT root (foo)*>
<!ELEMENT foo EMPTY>
<!ATTLIST foo
name ID #REQUIRED
>
the XML file(test1.xml):
<!DOCTYPE root SYSTEM "test.dtd">
<root>
<foo name="first"/>
</root>
and the source file:
#include "parsers/DOMParser.hpp"
#include "util/PlatformUtils.hpp"
#include "dom/DOM.hpp"
#include <iostream>
using namespace std;
int main(int argc, char **argv)
{
try
{
XMLPlatformUtils::Initialize();
}
catch(...)
{
cout<<"Initialisation exception..."<<endl;
exit(1);
}
DOMParser *parser1 = new DOMParser;
parser1->setDoValidation(true);
parser1->parse("test1.xml");
DOM_Document document1 = parser1->getDocument();
DOM_Element element1 = document1.getDocumentElement();
DOM_Element newElement= document1.createElement("foo");
newElement.setAttribute("name", "second"); // This is the ID attribute...
element1.appendChild(newElement);
DOM_Node searched= document1.getElementById("second"); // Not supposed to
be NULL...
cout<<(searched.isNull()?"Null":"Not Null")<<endl; // it is NULL...
return 0;
}
Thanks, Francois
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]