Thanks James. Is this something in TODO for dom4j (i.e. is there a need for XPath support in ElementHandlers)?
Best regards
Ben
On Fri, 2002-11-15 at 07:27, James Strachan wrote:
Unfortunately true XPath (or XSLT-patterns) style matching hasn't been added yet to the ElementHandlers.
Though you could always split your XPath into 2 and register the ElementHandler for ("/table/metaData/record") then when you get each Element evaluate the XPath expression "field[@fID=':1']"
Another approach, if you don't want to splitup your XPaths, is to just register an ElementHandler and on each Element perform an XPath test. Though the previous suggestion will be a bit more efficient, since most of the XPath has already been evaluated for you.
James
-------
http://radio.weblogs.com/0112098/
----- Original Message -----
From: Benjamin Kopic
To: [EMAIL PROTECTED]
Sent: Thursday, November 14, 2002 1:15 PM
Subject: [dom4j-user] ElementPath to use XPath expression
Hi
I am trying to use XPath expression as the path value when registering ElementHandler, and it seems that ElementPath is not an equivalent to XPath (which makes sense).
However, I need to get the below test to work:
public void testXPath() {
SAXReader saxReader = new SAXReader();
FieldMetaDataHandler fmdh0 = new FieldMetaDataHandler();
saxReader.addHandler("/table/metaData/record/field[@fID=':1']", fmdh);
try {
saxReader.read(TEST_DOC_URL);
} catch(DocumentException de) {
System.out.println("Problem reading: " + TEST_DOC_URL);
throw de;
}
assertTrue("ID read ("+fmdh.getFId()+") does not match expected (:1)", ":1".equals(fmdh.getFId()));
}
Unfortunately, the files manipulated are huge and hence we need to process them only when a particular element is reached.
Has anyone done anything similar? (BTW: This is along the lines to James Strachan's message @: http://www.mail-archive.com/jaxen-interest@lists.sourceforge.net/msg00793.html)
Best regards --
benjamin kopic
m: +44 (0)780 154 7643
t: +44 (0)20 7794 3090
e: [EMAIL PROTECTED]
w: http://www.panContext.com/
--
benjamin kopic
m: +44 (0)780 154 7643
t: +44 (0)20 7794 3090
e: [EMAIL PROTECTED]
w: http://www.panContext.com/
|
|