External DTDs

BlitzMax Forums/Brucey's Modules/External DTDs

Czar Flavius(Posted 2010) [#1]
The system for loading external DTDs is very inconsistant.

All my DTDs are located in Data/XML/DTD/

This file is located in Data/Worlds/ and must use
<!DOCTYPE world SYSTEM "Data/XML/DTD/World.dtd">

This file is located in Data/Objects/Rat/ and must use
<!DOCTYPE object SYSTEM "../../../Data/XML/DTD/Object.dtd">

Why? There is so much trial and error involved it is really frustrating.


Czar Flavius(Posted 2010) [#2]
Seperate issue, getAttribute does not read a default value from the DTD. Caused me a ton of unexpected bugs. Unless I put the attribute in the file (which defeats the point of a default value) it reads as blank.

Here is a small test program. I want rgb to return "1.0,1.0,1.0" if no value is provided on the stats node.

Strict
Import bah.libxml
Local doc:TxmlDoc = TxmlDoc.parseFile("blahblah\Data.xml")
Local node:TxmlNode = doc.getRootElement()
For Local dnode:TxmlNode = EachIn node.getChildren()
	For Local snode:TxmlNode = EachIn dnode.getChildren()
		Print snode.getName() + " " + snode.getAttribute("rgb")
	Next
Next
doc.free()


Here is a real data file I am reading


Here is the DTD



Brucey(Posted 2010) [#3]
You could try using the option XML_PARSE_DTDATTR with TxmlDoc.readFile(), which I believe should enable default attributes.

The system for loading external DTDs is very inconsistent.

It's possible that using the catalog system might allow you to set a base path from which to find dtds. But dtds, referenced relative to the file (rather than absolute) should always work.


Czar Flavius(Posted 2010) [#4]
I can't find readFile, I am using TxmlDoc.parseFile(docname)


Brucey(Posted 2010) [#5]
I've released the latest version which includes that new functionality. :-)


Czar Flavius(Posted 2010) [#6]
Thanks Brucey, you're the best!