锘??xml version="1.0" encoding="utf-8" standalone="yes"?>
渚嬪瀵逛簬
<requestHierarchySelectResult xmlns=http://www.lightcc.com/ns xmlns:cs="http://www.customsolids.com">
聽聽聽 <request>
聽聽聽聽聽聽聽 <created_dt>05/05/2000 00:00:00</created_dt>
聽聽聽聽聽聽聽 <created_tm>01/01/1900 14:02:46</created_tm>
聽聽聽聽聽聽聽 <cs:request_id>100002</cs:request_id>
聽聽聽 </request>
</requestHierarchySelectResult>
搴旂敤
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"聽
聽聽聽xmlns="http://www.lightcc.com/ns"
聽聽聽xmlns:cs="http://www.customsolids.com">
聽聽聽<xsl:template match="/">
聽聽聽聽聽聽<root><xsl:apply-templates聽 select="/*/request"/></root>
聽聽聽</xsl:template>
聽聽聽<xsl:template聽 match="*|@*|node()"/>
聽聽聽<xsl:template聽 match="request">
聽聽聽聽聽聽<gotHere><xsl:value-of聽 select="."/></gotHere>
聽聽聽</xsl:template>
</xsl:stylesheet>
鏄病鏈夋晥鏋滅殑.
闇瑕佺粰榛樿鐨勫悕縐扮┖闂存寚瀹氫竴涓墠緙
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"聽
聽聽聽xmlns:lc="http://www.lightcc.com/ns"
聽聽聽xmlns:cs="http://www.customsolids.com">
聽聽聽<xsl:template match="/">
聽聽聽聽聽聽聽<root><xsl:apply-templates聽 select="/*/lc:request"/></root>
聽聽聽</xsl:template>
聽聽聽<xsl:template聽 match="*|@*|node()"/>
聽聽聽<xsl:template聽 match="lc:request">
聽聽聽聽聽聽<gotHere><xsl:value-of聽 select="."/></gotHere>
聽聽聽</xsl:template>
</xsl:stylesheet>
鎹XSLT2鍜孹PATH2浼氳В鍐寵繖涓棶棰?br />
鍙傝?
聽聽聽http://www.edankert.com/defaultnamespaces.html
聽聽聽http://www.topxml.com/people/bosley/defaultns.asp
]]>
XMLBeans2.2鐗堟槸鍜宻axon鐨?.6.1鐗堜竴璧峰伐浣滅殑銆傛渶鍒濈殑8.7鍜孏OOGLE鍒扮殑瑙e喅鏂規涓負2.0鐗堝噯澶囩殑8.1閮戒笉琛?br />XMLBeans2.2:
http://mirror.vmmatrix.net/apache/xmlbeans/binaries/
saxon 8.6.1:
http://jaist.dl.sourceforge.net/sourceforge/saxon/saxonb8-6-1.zip
xpath鏌ヨ鑷沖皯闇瑕?saxon8.jar saxon8-dom.jar saxon8-xpath.jar鎵嶈兘姝e父宸ヤ綔
緙哄皯saxon8.jar浼氭姤濡備笅閿欒
java.lang.RuntimeException:聽 Trying XBeans path engine... Trying XQRL... Trying Saxon... FAILED on $this/data[@name='data2']
聽at org.apache.xmlbeans.impl.store.Path.getCompiledPath(Path.java:131)
聽at org.apache.xmlbeans.impl.store.Path.getCompiledPath(Path.java:91)
聽at org.apache.xmlbeans.impl.store.Cursor._selectPath(Cursor.java:902)
聽at org.apache.xmlbeans.impl.store.Cursor.selectPath(Cursor.java:2634)
聽at org.apache.xmlbeans.impl.values.XmlObjectBase.selectPath(XmlObjectBase.java:431)
聽at org.apache.xmlbeans.impl.values.XmlObjectBase.selectPath(XmlObjectBase.java:415)
聽at test.main(test.java:16)
Exception in thread "main"
鍙斁saxon8.jar涔熸槸涓嶆紜殑.緙哄皯鍏朵粬2涓猨ar鏌ヨ緇撴灉浼氫笉姝g‘
綆鍗曟祴璇?
SCHEMA:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="聽<xs:element name="root" type="rootType">
聽聽<xs:annotation>
聽聽聽<xs:documentation>rootcomment</xs:documentation>
聽聽</xs:annotation>
聽</xs:element>
聽<xs:complexType name="dataType">
聽聽<xs:attribute name="name" use="required"/>
聽</xs:complexType>
聽<xs:complexType name="datasType">
聽聽<xs:sequence>
聽聽聽<xs:element name="data" minOccurs="0" maxOccurs="unbounded">
聽聽聽聽<xs:complexType>
聽聽聽聽聽<xs:simpleContent>
聽聽聽聽聽聽<xs:extension base="xs:string">
聽聽聽聽聽聽聽<xs:attribute name="name" use="required"/>
聽聽聽聽聽聽</xs:extension>
聽聽聽聽聽</xs:simpleContent>
聽聽聽聽</xs:complexType>
聽聽聽</xs:element>
聽聽</xs:sequence>
聽</xs:complexType>
聽<xs:complexType name="rootType">
聽聽<xs:sequence>
聽聽聽<xs:element name="datas" type="datasType"/>
聽聽</xs:sequence>
聽</xs:complexType>
</xs:schema>
XML:
<?xml version="1.0" encoding="UTF-8"?>
<root xmlns:xsi="聽<datas>
聽聽<data name="data1">value1</data>
聽聽<data name="data2">value2</data>
聽聽<data name="data3">value3</data>
聽</datas>
</root>
jest.java
import java.io.File;
import noNamespace.DatasType;
import noNamespace.RootDocument;
import org.apache.xmlbeans.XmlObject;
public class test {
聽final static String NS_DECLEAR = "";
聽public static void main(String[] args) throws Exception {
聽聽RootDocument doc = RootDocument.Factory.parse(new File("z:\\test.xml"));
聽聽
聽聽DatasType datas = doc.getRoot().getDatas();
聽聽
聽聽XmlObject[] objs = datas.selectPath("$this/data[@name='data2']");
聽聽
聽聽for (int i = 0; i < objs.length; i++) {
聽聽聽System.out.println(objs[i]);
聽聽}
聽}
}
杈撳嚭:
<xml-fragment name="data2" xmlns:xsi=">
聽