import java.io.*; import com.fatdog.textengine.xmlengine; import com.fatdog.textengine.exceptions.*; import com.fatdog.textengine.query.xqlresultlistener; public class search implements xqlresultlistener { public static void main( string[] args ) { xmlengine engine = new xmlengine(); string searchfile = args[0]; string searchtype = args[1]; string query = args[2]; try { file://配置引擎 engine.setsaxparsername( "org.apache.xerces.parsers.saxparser"); engine.setminindexablewordlength( 3 ); engine.setdoindexnumbers( false ); engine.setdocument( searchfile ); if (searchtype.equals("1")) { engine.setlistenertype( xmlengine.standard_listener); } else if (searchtype.equals("2")) { engine.setlistenertype( xmlengine.summary_listener); } else { engine.setlistenertype( xmlengine.csv_listener); } } catch( missingorinvalidsaxparserexception e ){ system.out.println( "缺少或不可用的 sax解析器" ); return; } catch( filenotfoundexception e ) { system.out.println( "不能找到 xml 文件: "); return; } catch( cantparsedocumentexception e ) { system.out.println( "不能解析 xml 文件: "); return; } // engine.printsessionstats(); engine.addxqlresultlistener( new search() ); try { engine.setquery( query ); } catch( invalidqueryexception e ) { system.out.println( "不可用的查询请求: " + e.getmessage() ); return; } } public void results( string xqlresults ) { system.out.println( xqlresults ); } } |
<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> </welcome-file> <welcome-file> index.htm </welcome-file> </xql:result> |
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> |
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 |
如对本文有疑问, 点击进行留言回复!!
javascript xml xsl取值及数据修改第1/2页
网友评论