[jdom-interest] DTD-aware document building
MDoraisamy at SELECTICA.com
Wed Jan 2 09:29:46 PST 2002
i do the same with xml schema. But it's a pain parsing
and creating document which confirms to the schema.
Is there anything that can build the document based on
the schema ?
Also everytime i need to get the element and set the
value for the same.
I am just wondering if hastable would be much faster
when compared to the list implementation we presently
have in jdom
From: Frank Spychalski [mailto:psycho at sitewaerts.de]
Sent: Wednesday, January 02, 2002 10:05 PM
To: 'jdom-interest at jdom.org'
Subject: AW: [jdom-interest] DTD-aware document building
AFAIK there's no such method.
But how about adding all required children (your 'attributes') in the
correct order after creating the Router element (and setting them to some
default value) and changing these in your setRouterAttribute method.
just my 2 cents
Von: Proneel Guptan [mailto:proneel at dset.com]
Gesendet: Mittwoch, 2. Januar 2002 17:08
An: 'jdom-interest at jdom.org'
Betreff: [jdom-interest] DTD-aware document building
I couldnt find anything in the archives which answers the following question
I have, hence the posting.
I have a DTD with a type defined as follows:
<!ELEMENT Router (id , type , routerId , routerName .... )
When I want to construct a brand new document of type Router, I do the
doc = new Document(new Element("Router"));
After which, I get values from the client for id, type, routerId etc. I may
not get it in the order defined in the DTD.
For eg: my generic method setRouterAttribute(String name, String value)
Element child = new Element(name);
rootElement.addContent(child); // where rootElement is the root of the
"Router" document I created
Depending on the order the client calls the setRouterAttribute() to set the
id, type etc, that is the order in which
the document would be created and if this doesnt match the DTD, the document
would be invalid. I do not want to
hard-code into my client the order in which the calls should be made, I'd
much rather want the document builder to
do that automatically, so that if I change the order of fields in the DTD, I
dont need to change my client program also.
Is there any JDOM method, which when I add a child to a node, adds it in the
correct position as defined by the DTD?
Before JDOM, I used a home grown tool which did that and which I found very
convenient. However, from reading up on
various Java&XML tools, I get the impression I belong to (probably) a
minority among XML users who think that DTD
or schema aware document manipulation (as shown by the above example) is
proneel at dset.com
Tel: +49 (721) 920 918 0
Fax: +49 (721) 920 918 29
To control your jdom-interest membership:
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the jdom-interest