| <org.apache.xerces.parsers.SAXParser> installed successfully 1: indexing web.xml Query: ( // ( / welcome-file-list welcome-file ) ) 3 hit(s) for file://welcome-file-list/welcome-file <?xml version="1.0"?> <xql:result query="//welcome-file-list/welcome-file" hitCount="3" elemCount="3" docCount="1" xmlns:xql="http://www.fatdog.com/ Standard_Listener.html"> <welcome-file> index.jsp </welcome-file> <welcome-file> index.html </welcome-file> <welcome-file> index.htm </welcome-file> </xql:result> |
上面的例子中,查询项要求找到任何"welcome-file-list"元素的所有的"welcome-file"子元素。请注意,搜索的结果基本上是从原XML文档中摘录出来的,不能够建立搜索结果和原文档之间的关系。SUMMARY_LISTENER(2)返回类型则有些不同,它包括一个"docID"号和一个"elemlx"号,这样就能够把结果和原文档联系起来了。
如下是返回结果的示例:
C:\xql\xql1>java Search web.xml 2 "//welcome-file-list/welcome-file" Parser.installSaxParser: <org.apache.xerces.parsers.SAXParser> installed successfully 1: indexing web.xml Query: ( // ( / welcome-file-list welcome-file ) ) 3 hit(s) for file://welcome-file-list/welcome-file <?xml version="1.0"?> <xql:result query="//welcome-file-list/welcome-file" hitCount="3" elemCount="3" docCount="1" xmlns:xql="http://www.fatdog.com/ Summary_Listener.html"> <welcome-file xql:docID="0" xql:elemIx="270"/> <welcome-file xql:docID="0" xql:elemIx="271"/> <welcome-file xql:docID="0" xql:elemIx="272"/> </xql:result> |
我前面也说过,对于我的应用程序来说,最重要的是返回使用逗号隔开的返回结果,所以CSV_LISTENER(3)就很有用了,它能够返回一个使用使用逗号隔开的结果,如下:
| C:\xql\xql1>java Search web.xml 3 "//welcome-file-list/welcome-file" Parser.installSaxParser: <org.apache.xerces.parsers.SAXParser> installed successfully 1: indexing web.xml Query: ( // ( / welcome-file-list welcome-file ) ) 3 hit(s) for file://welcome-file-list/welcome-file 3,3,1,0 0,270,welcome-file 0,271,welcome-file 0,272,welcome-file |
当然,XQEngine还有很多很强大的功能,在此我不可能一一介绍,它所附带的文档中有丰富的源程序和使用方法,你可以对照着自己学习使用,当然,如果你愿意的话你甚至还可以开发出一个GUI程序,文档中就自带了一个基于GUI的搜索程序:SwingQueryDemo,你可以看一看研究研究。
文章整理:西部数码--专业提供域名注册、虚拟主机服务
http://www.west263.com
以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!



