<?xml version="1.0" encoding="utf-8"?> <testCases > <Node icon="images/icons/fam/folder_go.png" testCaseId="1002" parent_id="849" node_type_id="2" node_order="1" node_table="testsuites" name="testcaseA" > </Node> </testCases>
以上带属性的XML格式
下面为他的XSD文件
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="testCases"> <xs:complexType> <xs:sequence> <xs:element name="Node" type="Node" maxOccurs="unbounded"/> </xs:sequence> </xs:complexType> </xs:element> <xs:complexType name="Node"> <xs:attribute name="icon" type="xs:string"/> <xs:attribute name="testCaseId" type="xs:string"/> <xs:attribute name="parent_id" type="xs:string"/> <xs:attribute name="node_type_id" type="xs:string"/> <xs:attribute name="node_order" type="xs:string"/> <xs:attribute name="node_table" type="xs:string"/> <xs:attribute name="name" type="xs:string"/> </xs:complexType> </xs:schema>
带元素的XML格式
<Project>
<Task>
<pID>1</pID>
<pName>Tsk1</pName>
<pStart>7/1/2003</pStart>
<pEnd>7/1/2003</pEnd>
<pMile>0</pMile>
<pRes>1</pRes>
<pParent>0</pParent>
<pDepend>1</pDepend>
<pNote>1</pNote>
</Task>
<Task>
<pID>2</pID>
<pName>Tsk1</pName>
<pStart>7/1/2003</pStart>
<pEnd>7/1/2003</pEnd>
<pMile>0</pMile>
<pRes>1</pRes>
<pParent>0</pParent>
<pDepend>1</pDepend>
<pNote>1</pNote>
</Task>
</Project>
下面为他的XSD文件
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="Project"> <xs:complexType> <xs:sequence> <xs:element name="Task" type="Task" maxOccurs="unbounded"/> </xs:sequence> </xs:complexType> </xs:element> <xs:complexType name="Task"> <xs:sequence> <xs:element name="pID" type="xs:string"/> <xs:element name="pName" type="xs:string"/> <xs:element name="pStart" type="xs:string"/> <xs:element name="pEnd" type="xs:string"/> <xs:element name="pMile" type="xs:string"/> <xs:element name="pRes" type="xs:string"/> <xs:element name="pParent" type="xs:string"/> <xs:element name="pDepend" type="xs:string"/> <xs:element name="pNote" type="xs:string"/> </xs:sequence> </xs:complexType> </xs:schema>
用JAXB是需要C:\Program Files\Java\jdk1.6.0\jre\lib\endorsed,lib文件夹下建立新的文件夹endorsed,并将jaxb-api.jar考入内,否则会报错。
生成JAVA CODE
CMD
到C:\jaxb-ri\bin目录下
敲入命令
即可。