手机站
网通分站
电信主站
密 码:
用户名:
当前位置 : 主页>网络编程>Xml编程>列表

学习使用XML引擎XQEngine

来源:互联网 作者:west263.com 时间:2008-02-23
西部数码-全国虚拟主机10强!40余项虚拟主机管理功能,全国领先!双线多线虚拟主机南北访问畅通无阻!免费赠送企业邮局,.CN域名,自助建站480元起,免费试用7天,满意再付款! P4主机租用799元/月.月付免压金!


<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
以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!