Java做XML解析入庫,用Schema校驗(yàn)XML格式,在Windows環(huán)境下的Websphere6部署進(jìn)行校驗(yàn)和解析都沒問題,但在AIX上Websphere6上解析就出錯(cuò),本人聯(lián)系方式,MSN:chentao_1983_7@hotmail.com QQ:278555390,請高手指點(diǎn)一下,謝謝。
在共享庫中已經(jīng)加入jdom-1.0.jar、dom4j-1.6.1.jar和xerces.jar,校驗(yàn)XML格式報(bào)錯(cuò)信息如下:
第2行 第8列:General Schema Error: Can't get back Schema document's root element
:/usr/IBM/WebSphere/AppServer/profiles/App2Pro2/installedApps/operapp1Cell01/oper_amlmis_ear.ear/oper_amlmis.war
xml/validateYear.xsd.
第2行 第8列:Element type 'banks' must be declared.
第3行 第8列:Element type 'bank' must be declared.
第4行 第9列:Element type 'head' must be declared.
............//中間出錯(cuò)信息省略
第71行 第18列:Element type 'sjxmmcjzynr' must be declared.
第72行 第16列:Element type 'sjfxdzywt' must be declared.
第73行 第13列:Element type 'wtzgqk' must be declared.
--------------------------------
用Schema校驗(yàn)XML格式的程序如下:(附件中有Schema和XML文件)
SAXReader reader = new SAXReader();
Document document = null;
//數(shù)據(jù)校驗(yàn)
String schema = Config.getInstance().getRealPath() + "/xml/validateYear.xsd";
reader.setValidation(true);
reader.setProperty("http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation",schema);
XMLErrorHandler errorHandler = new XMLErrorHandler();
reader.setErrorHandler(errorHandler);