The Dunce Baron

Greenhorn
+ Follow
since Apr 19, 2007
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by The Dunce Baron

Hi,

There is a SAX parser example in Sun's XML tutorial at http://java.sun.com/webservices/jaxp/dist/1.1/docs/tutorial/sax/index.html which should help get you started. It demonstrates the basics of implementing a org.xml.sax.ContentHandler to capture and display XML data as it is encountered by the SAX parser. Hope this helps. Warren
Hi Michael,

I feel your pain! I'm new to XML to.

Please see the static fields defined in: http://java.sun.com/j2se/1.4.2/docs/api/org/w3c/dom/package-frame.html

The Node.DOCUMENT_NODE represents the "root" node of the document. Node.ELEMENT_NODE are the "elements" contained within the Node.DOCUMENT_NODE (or something like that).

The Javadocs list all of the different Node types. Besides Sun's on-line XML tutorial, I have also found the explanation of DOM in O'Reilly's "Java and XML" book to be quite helpful in learning some of the basics.

Hope this helps. Warren
Hi Stuart,

Yours in an interesting question and one that I'd like to be able to help with. But there's one thing that confuses me (which is not that hard to do since I'm quite new to XML).

Since both the xerces SAX and DOM parsers can validate an XML document instance against a DTD (to the extent that DTDs allow), is this not adequate for your application? What I mean to ask is: what further specific validation to you require that the SAX and DOM validating parsers do not provide?

Thanks, Warren.
Hello Group,

I have an iteresting problem I'd like to solve. It involves XML which I am pretty new to. So I thought I'd pose the question here.

I need to compare/diff two trees and report their differences in a web app. The tree structures (nodes and leafs) are represented by instances of java classes using the Composite design pattern. Writing my own compare/diff algorithm to compare any two instances of these tree structures and report on all of their differences would be difficult and error prone.

Being trees, thought that the world of XML might provide a solution. I thought I might create (somehow) a DOM representation of my Java trees, then use some(?) XML utility to compare them and provide a report/DOM/whatever as to their differences. Has anyone here ever done this? Any suggestions would be greatly appreciated.

Aside from the general question posed above, I have some more specific related questions:

1.) are there tools which can take a Java class file (ex: a node/leaf in a tree) and generate an XML schema from it?

2.) are there Java tools which will let me take an instance of a Java class (like the root node of a composite tree structure) and "automatically" create a DOM from it? I've read the JAXB tutorial. JAXB allows the in-memory the creation of the document content using Java, but it seems that this must be done rather "manually". Am I wrong here? I'd love to be able to pass a utility the root node of my tree and have it automatically give me back a DOM representation of the entire structure. Is this possible?

Thanks in advance.
Hi Kalyani,
I'm pretty new to XML myself. But what you are describing sounds like it might be an appropriate application for "DOM" (Document Object Model).

Check out the Java API for the org.w3c.dom and org.w3c.dom.ls packages. Though I've never used the org.w3c.dom.ls.LSSerializer to output XML, it seems like a good candidate. Besided this, there are lots and lots of other ways to take an in-memory representation of XML data (a DOM) and serialize it to disk.
Hi Ugender,

You might also take a quick look at JAXB (http://java.sun.com/developer/technicalArticles/WebServices/jaxb/). It allows you to take a schema and build an in-memory Java representation of the schema and set values on it. You may then marshal the XML to any one of a number of different sources. Hope this helps.
Warren
Hello Group,

I need to use a regular expression to find and replace double-quotes (") in an SQL string, but I need to limit the replacement to only one part of the string. I need this for an Ant task I'm working on (hey, ant is Java), but if the only good solution I can find is straight up Java, that is fine also. For example, if I have the String:

Some "arbitrary text" says INSERT INTO foo VALUES( "bar1", "bar2", "bar3");

I only want to replace the double quotes (") inside the VALUES clause, not the "arbitrary text" part. Is there a way to anchor the parttern matching so that it only matches and replaces inside of the VALUES clause?

Thanks for any advice.

Cheers,
Warren
18 years ago
Hello Paul. I've updated my display name. Sorry about that. Thanks, Warren.
Hello! After many years of avoiding the topic, I am now being dragged, kicking and screaming, into the world of XML. I purchased the O'Reilly book "Java and XML, Third Edition" in an attempt to educate myself. It introduces a tool called "relaxer" for doing such things as creating a DTD or schema definition from an existing XML document. But the tool seems to be no longer available at the provided URL: http://www.relaxer.org/download/index.html. Their entire web site is gone! The book was published in late 2006 so its not that old. What has become of "relaxer"?

Is there another tool I should use? I have a Linux pc. Thanks in advance for any info/advice.

Cheers, The Dunce Baron.