[jdom-interest] DTD-aware document building

Mani Doraisamy 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

mani

-----Original Message-----
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


Hi,

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
Frank

-----Ursprüngliche Nachricht-----
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


Hi, 
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
following: 
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)
would simply: 
Element child = new Element(name); 
child.setText(value); 
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
essential. 
Any comments/clarifications? 
Thanks, 
Proneel. 
proneel at dset.com 

<<<<<<<<<<<<<<<<<<<<<<<<<<<
sitewaerts GmbH
Hebelstraße 15
D-76133 Karlsruhe

Tel: +49 (721) 920 918 0
Fax: +49 (721) 920 918 29
http://www.sitewaerts.de
>>>>>>>>>>>>>>>>>>>>>>>>>>>


_______________________________________________
To control your jdom-interest membership:
http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhos
t.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://jdom.org/pipermail/jdom-interest/attachments/20020102/42c867a3/attachment.htm


More information about the jdom-interest mailing list