[jdom-interest] jdom from xni

rpcee rpcee at operamail.com
Tue Nov 6 18:34:28 PST 2001


here's a jython (sorry) prototype that appears to build some sort of JDOM 
document from xerces 2b3 XNI.

Caveats: almost certainly buggy, I did it because I'm learning jython, jdom, 
XML and it seemed a good way to combine the 3, but most likely my jython is 
terrible, the JDOM document will be wrong etc etc. I used the SAX stuff to 
help.

One day I might java-ise it, but I guess jythonc would work on it.

It is also possible to get DTD information, for example attribute type 
information, by adding appropriate methods to XNIBuilder(), I just copied the 
xerces DocumentTracer sample. The current one provides access to the <?xml 
...> declaration, but rather oddly via the parser object, because I didn't 
change any JDOM code.

rich

example usage from jython:

      parser = XNIBuilder(processIgnorableWhitespace = 1, validate = 1)
      parser.parse(xni.parser.XMLInputSource(None, sys.argv[1], None))
      di = parser.documentInfo
      print "Document encoding was:", di.encoding
      output.XMLOutputter().output(parser.document, java.lang.System.out)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: XNIBuilder.zip
Type: application/x-zip-compressed
Size: 1525 bytes
Desc: not available
Url : http://jdom.org/pipermail/jdom-interest/attachments/20011106/6a1c690c/XNIBuilder.bin


More information about the jdom-interest mailing list