Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

XMLViewer

843805Feb 1 2007 — edited Feb 2 2007
Hi all

I am trying to make an XMLViewer. Easiest way to do that I figured would be to grab an XML parser, parse the xml into a DOM Document, and convert the Document into a TreeModel.

I found a lot of code for this on the internet. First, I downloaded the latest version of Xerces, the apache XML parser. Then I scanned the web some more and found the DOMTreeWalkerTreeModel code

http://www.java2s.com/Code/Java/XML/DOMTreeWalkerTreeModel.htm

voila. I've got a treemodel.

Now, my only problem is that I want the tree to look a little different.

My XML looks like
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:a="http://www.provenir.com/schemas">
	<xsd:element name="a" type="b"/>
	<xsd:complexType name="c">
		<xsd:all>
			<xsd:element name="d" type="e" minOccurs="1" maxOccurs="1"/>
		</xsd:all>
		<xsd:attribute name="Org" type="xsd:string"/>
		<xsd:attribute name="sessionID" type="xsd:string"/>
		<xsd:attribute name="stack" type="xsd:string"/>
		<xsd:attribute name="Version" type="xsd:string" use="optional"/>
		<xsd:attribute name="ProductType" type="xsd:string" use="optional"/>
but when I install it in a JTree and view it I see branches like
[xsd:schema: null]
  [xsd:element: null]
  [xsd:complexType:null]
...
I'd like to see the actual attributes in the nodes - the name and type fields at the very least.

Anyone know how I can get the TreeWalker to display these nodes differently?

Comments

Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Mar 2 2007
Added on Feb 1 2007
7 comments
461 views