<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<TITLE>Nachricht</TITLE>
<META content="MSHTML 5.50.4134.600" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><SPAN class=387165607-18072002><FONT face="Courier New" color=#0000ff
size=2>Hi,</FONT></SPAN></DIV>
<DIV><SPAN class=387165607-18072002><FONT face="Courier New" color=#0000ff
size=2>werken.xpath is an older version of jaxen.</FONT></SPAN></DIV>
<DIV><SPAN class=387165607-18072002><FONT face="Courier New" color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=387165607-18072002><FONT face="Courier New" color=#0000ff
size=2>I use the following method to count elements according to a certain xpath
expression:</FONT></SPAN></DIV>
<DIV><SPAN class=387165607-18072002><FONT face="Courier New" color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=387165607-18072002><FONT face="Courier New" color=#0000ff
size=2> public static int getJDOMCount( Document doc, String xpath
)<BR> {<BR> int ret = -1;<BR>
try<BR> {<BR> Number num = new
XPath( xpath ).numberValueOf( doc );<BR> ret =
num.intValue();<BR> }<BR> catch (
SAXPathException spx )<BR> {<BR>
out(" getJDOMElement->ERROR ");<BR> logError(
spx );<BR> }<BR> return ret;<BR>
}</FONT></SPAN></DIV>
<DIV><SPAN class=387165607-18072002><FONT face="Courier New" color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=387165607-18072002><FONT face="Courier New" color=#0000ff
size=2>An example for an xpath expression:</FONT></SPAN></DIV>
<DIV><SPAN class=387165607-18072002><FONT face="Courier New" color=#0000ff
size=2>"count(items/item[name='"+something+"']/value/entities/entity)"</FONT></SPAN></DIV>
<DIV><SPAN class=387165607-18072002><FONT face="Courier New" color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=387165607-18072002><FONT face="Courier New" color=#0000ff
size=2>Jaxen unfortunately does not contain good examples.</FONT></SPAN></DIV>
<DIV><SPAN class=387165607-18072002><FONT face="Courier New" color=#0000ff
size=2>Some good links:</FONT></SPAN></DIV>
<DIV><SPAN class=387165607-18072002><FONT face="Courier New" color=#0000ff
size=2><A
href="http://www.zvon.org/xxl/XPathTutorial/General/examples.html">http://www.zvon.org/xxl/XPathTutorial/General/examples.html</A></FONT></SPAN></DIV>
<DIV><SPAN class=387165607-18072002><FONT face="Courier New" color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=387165607-18072002><FONT face="Courier New" color=#0000ff
size=2>Elliotte Rusty Harold has an excellent introduction to xml and (amongst
other things) xpath:</FONT></SPAN></DIV>
<DIV><SPAN class=387165607-18072002><FONT face="Courier New" color=#0000ff
size=2><A
href="http://cafeconleche.org/books/xmljava/chapters/">http://cafeconleche.org/books/xmljava/chapters/</A></FONT></SPAN></DIV>
<DIV><SPAN class=387165607-18072002><FONT face="Courier New" color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=387165607-18072002><FONT face="Courier New" color=#0000ff
size=2>The latest (cvs?) version of jdom has jaxen built in.</FONT></SPAN></DIV>
<DIV><SPAN class=387165607-18072002><FONT face="Courier New" color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=387165607-18072002><FONT face="Courier New" color=#0000ff
size=2>Greetings,</FONT></SPAN></DIV>
<DIV><SPAN class=387165607-18072002><FONT face="Courier New" color=#0000ff
size=2>Mark</FONT></SPAN></DIV>
<BLOCKQUOTE dir=ltr
style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #0000ff 2px solid; MARGIN-RIGHT: 0px">
<DIV></DIV>
<DIV class=OutlookMessageHeader lang=de dir=ltr align=left><FONT face=Tahoma
size=2>-----Original Message-----<BR><B>From:</B> Adrian Jetzer
[mailto:wwwaci@tic.ch] <BR><B>Sent:</B> Thursday, July 18, 2002 9:38
AM<BR><B>To:</B> MarkW<BR><B>Subject:</B> Re: [jdom-interest] (no
subject)<BR><BR></FONT></DIV>
<DIV><FONT face=Courier size=2>Hi. Thanks for you mail.</FONT></DIV>
<DIV><FONT face=Courier size=2></FONT> </DIV>
<DIV><FONT face=Courier size=2>Which XPath-thing do you use with JDOM for this
'count()' function ?</FONT></DIV>
<DIV><FONT face=Courier size=2></FONT> </DIV>
<DIV><FONT face=Courier size=2>- werken.xpath</FONT></DIV>
<DIV><FONT face=Courier size=2>or </FONT></DIV>
<DIV><FONT face=Courier size=2>- jaxen-xpath</FONT></DIV>
<DIV><FONT face=Courier size=2></FONT> </DIV>
<DIV><FONT face=Courier size=2>And in which Class is this count method
?</FONT></DIV>
<DIV><FONT face=Courier size=2></FONT> </DIV>
<DIV><FONT face=Courier size=2>Thanks,</FONT></DIV>
<DIV><FONT face=Courier size=2>Adrian</FONT></DIV>
<BLOCKQUOTE dir=ltr
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV style="FONT: 10pt arial">----- Original Message ----- </DIV>
<DIV
style="BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: black"><B>From:</B>
<A title=mark.wilson@wilsoncom.de
href="mailto:mark.wilson@wilsoncom.de">MarkW</A> </DIV>
<DIV style="FONT: 10pt arial"><B>To:</B> <A title=jdom-interest@jdom.org
href="mailto:jdom-interest@jdom.org">Jdom-Interest</A> </DIV>
<DIV style="FONT: 10pt arial"><B>Sent:</B> Wednesday, July 17, 2002 3:19
PM</DIV>
<DIV style="FONT: 10pt arial"><B>Subject:</B> RE: [jdom-interest] (no
subject)</DIV>
<DIV><FONT face="Courier New" color=#0000ff size=2></FONT><BR></DIV>
<DIV><SPAN class=575061813-17072002><FONT face="Courier New" color=#0000ff
size=2>Hi,</FONT></SPAN></DIV>
<DIV><SPAN class=575061813-17072002><FONT face="Courier New" color=#0000ff
size=2>you could use the count() function in xpath in order to program a
progress bar.</FONT></SPAN></DIV>
<DIV><SPAN class=575061813-17072002><FONT face="Courier New" color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=575061813-17072002><FONT face="Courier New" color=#0000ff
size=2>Mark</FONT></SPAN></DIV>
<BLOCKQUOTE dir=ltr
style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #0000ff 2px solid; MARGIN-RIGHT: 0px">
<DIV></DIV>
<DIV class=OutlookMessageHeader lang=de dir=ltr align=left><FONT
face=Tahoma size=2>-----Original Message-----<BR><B>From:</B> <A
href="mailto:jdom-interest-admin@jdom.org">jdom-interest-admin@jdom.org</A>
[mailto:jdom-interest-admin@jdom.org] <B>On Behalf Of </B>Adrian
Jetzer<BR><B>Sent:</B> Wednesday, July 17, 2002 2:27 PM<BR><B>To:</B> <A
href="mailto:jdom-interest@jdom.org">jdom-interest@jdom.org</A><BR><B>Subject:</B>
[jdom-interest] (no subject)<BR><BR></FONT></DIV>
<DIV><FONT face=Courier size=2>Hi there!</FONT></DIV>
<DIV><FONT face=Courier size=2></FONT> </DIV>
<DIV><FONT face=Courier size=2></FONT> </DIV>
<DIV><FONT face=Courier size=2>I'm parsing a xml-file. The file has a
specific amount</FONT></DIV>
<DIV><FONT face=Courier size=2>of elements. </FONT></DIV>
<DIV><FONT face=Courier size=2></FONT> </DIV>
<DIV><FONT face=Courier size=2>Is there a way to know, on which line of
the file </FONT></DIV>
<DIV><FONT face=Courier size=2>the parser in a </FONT><FONT
face=Courier size=2>particular moment is?</FONT></DIV>
<DIV><FONT face=Courier size=2></FONT> </DIV>
<DIV><FONT face=Courier size=2>For example. After I read (parsed) several
elements of</FONT></DIV>
<DIV><FONT face=Courier size=2>the xml file, I would like to know, on
which line</FONT></DIV>
<DIV><FONT face=Courier size=2>of the file the "actual-file-pointer"
is.</FONT></DIV>
<DIV><FONT face=Courier size=2></FONT> </DIV>
<DIV><FONT face=Courier size=2>I don't want to know the line-number for
every element.</FONT></DIV>
<DIV><FONT face=Courier size=2>Just sometimes I want to check, on which
line the</FONT></DIV>
<DIV><FONT face=Courier size=2>parser is.</FONT></DIV>
<DIV><FONT face=Courier size=2></FONT> </DIV>
<DIV><FONT face=Courier size=2></FONT> </DIV>
<DIV><FONT face=Courier size=2>For what do I use this?</FONT></DIV>
<DIV><FONT face=Courier size=2></FONT> </DIV>
<DIV><FONT face=Courier size=2>I want to use it for a progress bar. I want
to show the</FONT></DIV>
<DIV><FONT face=Courier size=2>user how far the parsing process is. I know
the total</FONT></DIV>
<DIV><FONT face=Courier size=2>amount of lines in the file. So with
some checkpoints</FONT></DIV>
<DIV><FONT face=Courier size=2>(hey parser, on which line
are you now?) I can </FONT> <FONT face=Courier
size=2>realise</FONT></DIV>
<DIV><FONT face=Courier size=2>a progress bar ....</FONT></DIV>
<DIV><FONT face=Courier size=2></FONT> </DIV>
<DIV><FONT face=Courier size=2></FONT> </DIV>
<DIV><FONT face=Courier size=2>Adrian</FONT></DIV>
<DIV><FONT face=Courier
size=2></FONT> </DIV></BLOCKQUOTE></BLOCKQUOTE></BLOCKQUOTE></BODY></HTML>