Vivek,
It is easy enough to display the nodes - create a class that implements DTDHandler and LexicalHandler and this will get called for each declaration, so you can build your tree nodes here.
The catch is, a tree view showing the nesting of these nodes is non-trivial, since a DTD doesn't have to have a root node and elements do not have to be declared before they're used in a content model. Plus, it gets even uglier when you have recursion. You cannot simply "walk" a DTD.
There may be hooks into Xerces where you can get some kind of validation tree but I've never really looked for it. For every element declaration, you need to parse the content model yourself and work out which of the other elements go under it. I suspect the easiest way to do it is parse the DTD to get all of the elements and put them in a stack (with their associated attributes and content models) and create a tree node for each one. Then you should parse the content model and resolve it to elements on your stack at the moment they are expanded by a user action.
Regards,
John
-----Original Message-----
From: vivek bodhraj [mailto:[EMAIL PROTECTED]]
Sent: 27 November 2001 18:47
To: [EMAIL PROTECTED]; Igor PARTL
Subject: Re: disaplying dtd using swing.
Thank you Igor for yur reply,
let me eloborate what I intend to do:)
I HAVE TO READ THE DTD,
DISPLAY THE NODES OF DTD(JUST LIKE TREEWALKER DOES IN
THE SAMPLES) BUT THERE IS NO XML INSTANCE IT IS JUST
THE DTD.
In other words, when I parse the dtd I get the
document, how do I access the elements in the DTD and
display them?
I tried the samples(IteratorView.java with the
personal.dtd, it just displays the root
element(document).
Regards,
Vivek
--- Igor PARTL <[EMAIL PROTECTED]>
wrote:
> Hi!
>
>
> On Mon, Nov 26, 2001 at 04:06:07PM -0800, vivek
> bodhraj wrote:
>
> > Is there a way to display dtd on the scrollpane
> using
> > swing? I have to manipulate the nodes on the dtd.
>
> Thinking about your problem I suggest:
> - For each element of your dtd a jtree with thew
> possible elements.
> The several cardinalities (+, *, ?...) you can
> represent through
> different icons.
> - All element-trees are child of one root-jtree,
> which stands for the
> complete dtd.
>
> So you can display all element in one jtree.
>
> I hope, I have understood you question in the right
> way.
>
>
> Igor PARTL
>
>
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> [EMAIL PROTECTED]
> For additional commands, e-mail:
> [EMAIL PROTECTED]
>
__________________________________________________
Do You Yahoo!?
Yahoo! GeoCities - quick and easy web site hosting, just $8.95/month.
http://geocities.yahoo.com/ps/info1
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
