Skip to Content.
Sympa Menu

xom-interest - Re: [XOM-interest] Re: relevant to the discussion we were havingtheother day

xom-interest AT lists.ibiblio.org

Subject: XOM API for Processing XML with Java

List archive

Chronological Thread  
  • From: Wolfgang Hoschek <whoschek AT lbl.gov>
  • To: xom-interest AT lists.ibiblio.org
  • Subject: Re: [XOM-interest] Re: relevant to the discussion we were havingtheother day
  • Date: Thu, 23 Sep 2004 14:50:03 -0700

To remove or replace DTD declarations you can use DoctypeChanger or EntityResolver2
http://doctypechanger.sourceforge.net

It's a complication, but it works.

Wolfgang.


On Sep 23, 2004, at 2:39 PM, passani AT eunet.no wrote:


Please correct me if I'm wrong. This still assumes that the XML file
is valid (not only well-formed), right?

to me that's the core of the issue. I want something that
ignores validation altogether even if there is a DTD.

RegExps are not powerful enough to parse XML?
then, give me something that is, but which won't try to
hit a resource outside of my control behind my back!

RegExps won't blow up if they find a chinese CHAR in the middle
of the file. They just won't match.
Why can't I get something similar from an XML tool?

Apparently, even SAX tries to open up a connection
and go for a DTD...

Luca


You can do such kind of things with XQuery. Since XQuery is a superset
of XPath 2.0, it can also be used with plain XPath expressions as
queries. Also note that XPath 2.0 supports regular expressions via the
matches, replace, and tokenize functions.

For example:
// find the links of all images in a XHTML-like document
XQuery xquery = new XQuery("//img/@src", null);

// find the links of all JPG images in a XHTML-like document
// XQuery xquery = new XQuery("//img/@src[fn:matches(string(.),
'.jpg')]", null);

Nodes nodes = xquery.evaluate(doc);
for (int i=0; i < nodes.size(); i++) {
System.out.println("node "+i+": "+nodes.get(i).toXML());
}

I'm working on XOM extensions for that. A working prototype is at

http://dsd.lbl.gov/~hoschek/xom-contrib-download

and javadoc is here:

http://dsd.lbl.gov/~hoschek/xom-contrib/

One can query some hundreds of 10K documents per second with that
approach,
but in terms of performance it certainly cannot compete with a
NodeFactory filter.
Rather, the primary motivation here is power with simplicity.

Wolfgang.

Elliotte, be brave and put some ideas down for us to see.
With your understanding of XML *and* developers, you
are one of the best positioned to do this.
It might be what makes XOM rock even more one day.
Add regexps to XPATH? or callbacks?
a new way to analyse XML which is more powerful
than regexps alone, but which doesn't turn entities
into landmines? be creative! go nuts!

Luca






Archive powered by MHonArc 2.6.24.

Top of Page