Svar: Re: [xml] Problem adding DTD at runtime
- From: "Erik F. Andersen" <ea ascott dk>
- To: xml gnome org
- Subject: Svar: Re: [xml] Problem adding DTD at runtime
- Date: Tue, 19 Oct 2004 12:34:56 +0200
Thanks,
all this mixing Delphi and C sometimes confuses me. A call to xmlStrDup solved my problem.
Regarding the wsu:Id attribute in the DTD then my problem is that I have to speak to a WebService that I have
no control over. This is already giving me headaches because XMLSec also have problems with it.
Regards,
Erik
Daniel Veillard<veillard redhat com> 19-10-2004 11:41:30 >>>
On Tue, Oct 19, 2004 at 11:29:30AM +0200, Erik F. Andersen wrote:
Hello,
I'm trying to add a DTD at runtine to my XML. I use the following code (I hope you can read the Delphi
syntax)
dtd := XMLParseDTD(nil, 'mydtd.dtd');
if (rootNode^.ns=nil) or (rootNode^.ns^.prefix=nil) then
dtd^.name := rootNode^.name
else
dtd^.name := PChar(rootNode^.ns^.prefix+':'+rootNode^.name);
xmlDoc^.intSubset := dtd;
if (xmlDoc^.children=nil) then
xmlAddChild(xmlNodePtr(xmlDoc), xmlNodePtr(dtd))
else
xmlAddPrevSibling(xmlDoc^.children, xmlNodePtr(dtd));
My problem is that I get an Access Violation in XMLFreeDoc(xmlDoc) after the DTD has been added. Am I
missing something? The DTD is added allright because it shows up in a call to xmlDocMemoryDump.
Seems to me the semantic of your dtd^.name := code doesn't make the
string allocated via xmlMalloc or the document dictionnary so it is likely
to generate big problems when freeing the DTD node.
I have another question as well. Is it possible to add a DTD from memory (<!ATTLIST SOAP-ENV:Body wsu:Id ID
#IMPLIED>)?
Not that I can think of. Anyway I *strongly* suggest using xml:id instead
of trying to fool the parser into using an inexistent DTD.
http://www.w3.org/TR/xml-id/
Get the right tool for the job, messing around with DTD added on-the-fly
which basically does not match anything in the XML recommendation is non
portable, hackish and will be a maintainance headache !
Daniel
--
Daniel Veillard | Red Hat Desktop team http://redhat.com/
veillard redhat com | libxml GNOME XML XSLT toolkit http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]