alfresco用到了大量的第三方的工具或者项目。本文列举并介绍这些项目和工具,以便在使用和分析alfresco的时候能够有一些帮助。
1、XPP3 也叫MXP1
XPP —— XML Pull Parser,XPP3是一个非常快的XML解析器,是第三版的XPP。
XPP2是XPP的第二版。
XPP3是XPP2的继承者,实现了http://www.xmlpull.org定义的XmlPull API 。
看到有人做的对比测试,XPP3 比DOM4J 快6倍,也就是使用了1/6时间。
XPP3使用的是Apache 1.1 variant License 协议。
http://www.extreme.indiana.edu/xgws/xsoap/xpp/mxp1/index.html
http://mvnrepository.com/artifact/xpp3/xpp3
使用举例:http://www.xmlpull.org/v1/download/unpacked/doc/quick_intro.html
MyXmlPull.java
============
- importjava.io.FileReader;
- importjava.io.IOException;
- importjava.io.StringReader;
- importorg.xmlpull.v1.XmlPullParser;
- importorg.xmlpull.v1.XmlPullParserException;
- importorg.xmlpull.v1.XmlPullParserFactory;
- /**
- *AnexampleofanapplicationthatusesXMLPULLV1API.
- *
- *@author<ahref="http://www.extreme.indiana.edu/~aslom/">AleksanderSlominski</a>
- */
- publicclassMyXmlPullApp
- {
- finalstaticStringSAMPLE_XML=
- "<?xmlversion=\"1.0\"?>\n"+
- "\n"+
- "<poemxmlns=\"http://www.megginson.com/ns/exp/poetry\">\n"+
- "<title>RosesareRed</title>\n"+
- "<l>Rosesarered,</l>\n"+
- "<l>Violetsareblue;</l>\n"+
- "<l>Sugarissweet,108); list-style:decimal-leading-zero outside; color:inherit; line-height:18px; margin:0px!important; padding:0px 3px 0px 10px!important"> "<l>AndIloveyou.</l>\n"+
- "</poem>";
- staticvoidmain(Stringargs[])
- throwsXmlPullParserException,IOException
- {
- XmlPullParserFactoryfactory=XmlPullParserFactory.newInstance();
- factory.setNamespaceAware(true);
- XmlPullParserxpp=factory.newPullParser();
- System.out.println("parserimplementationclassis"+xpp.getClass());
- MyXmlPullAppapp=newMyXmlPullApp();
- if(args.length==0){
- System.out.println("ParsingsimplesampleXML");//:\n"+SAMPLE_XML);
- xpp.setInput(newStringReader(SAMPLE_XML));
- app.processDocument(xpp);
- }else{
- for(inti=0;i<args.length;i++){
- System.out.println("Parsingfile:"+args[i]);
- xpp.setInput(newFileReader(args[i]));
- app.processDocument(xpp);
- }
- }
- voidprocessDocument(XmlPullParserxpp)
- inteventType=xpp.getEventType();
- do{
- if(eventType==xpp.START_DOCUMENT){
- System.out.println("Startdocument");
- }elseif(eventType==xpp.END_DOCUMENT){
- System.out.println("Enddocument");
- if(eventType==xpp.START_TAG){
- processStartElement(xpp);
- if(eventType==xpp.END_TAG){
- processEndElement(xpp);
- if(eventType==xpp.TEXT){
- processText(xpp);
- eventType=xpp.next();
- while(eventType!=xpp.END_DOCUMENT);
- voidprocessStartElement(XmlPullParserxpp)
- Stringname=xpp.getName();
- Stringuri=xpp.getNamespace();
- if("".equals(uri)){
- System.out.println("Startelement:"+name);
- else{
- System.out.println("Startelement:{"+uri+"}"+name);
- voidprocessEndElement(XmlPullParserxpp)
- if("".equals(uri))
- System.out.println("Endelement:"+name);
- else
- System.out.println("Endelement:{"+uri+"}"+name);
- intholderForStartAndLength[]=newint[2];
- voidprocessText(XmlPullParserxpp)throwsXmlPullParserException
- charch[]=xpp.getTextCharacters(holderForStartAndLength);
- intstart=holderForStartAndLength[0];
- intlength=holderForStartAndLength[1];
- System.out.print("Characters:\"");
- inti=start;i<start+length;i++){
- switch(ch[i]){
- case'\\':
- System.out.print("\\\\");
- break;
- case'"':
- System.out.print("\\\"");
- break;
- case'\n':
- System.out.print("\\n");
- case'\r':
- System.out.print("\\r");
- case'\t':
- System.out.print("\\t");
- default:
- System.out.print(ch[i]);
- System.out.print("\"\n");
- }
原文链接:/xml/296568.html