XML Schema定義
XML Schema定義
XML Schema定義(XML Schema Definition,XSD)是一套W3C標準,用於基於XML的稱為XML Schema的型別系統。用於定義的語言是一種稱為XML模式定義語言(XML Schema Definition Language)的XML語法。Web 服務使用XML作為表示訊息和資料的底層格式。因此,XSD成為Web服務型別系統的自然選擇。
關於XSD的更多資訊,請訪問下面的網址:
http://www.w3.org/2001/XMLSchema
本附錄提供了XSD在以下檔案中的應用,這些檔案用於開發JAX-RPC Web服務和客戶端:
XML Schema用於wscompile 配置檔案
以下程式碼是用於建立wscompile配置檔案的XML Schema:
<?xml version="1.0" encoding="UTF-8"?>
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:tns="http://java.sun.com/xml/ns/jax-rpc/ri/config"
targetNamespace="http://java.sun.com/xml/ns/jax-rpc/ri/config"
elementFormDefault="qualified"
attributeFormDefault="unqualified"
version="1.0">
唯一允許的頂層元素是“configuration”。
所謂頂層元素,它必須包含3種可能的元素中的一種,相應地也會有3種不同的方式來為這種工具提供資訊服務。
元素: (互斥的)
"service" —— 基於一組服務端介面的服務描述;
"modelfile" —— 預先儲存好的模型檔案 (wscompile中的-model選項)。
<xsd:element name="service" type="tns:serviceType"/>
<xsd:element name="wsdl" type="tns:wsdlType"/>
<xsd:element name="modelfile" type="tns:modelfileType"/>
屬性:
"targetNamespace" ——用於生成WSDL 文件的目標名稱空間;
"typeMappingRegistry"? ——用於該服務的型別對映登錄檔;
"handlerChains"? ——服務端的預設處理程式鏈;
"namespaceMappingRegistry"? —— 到Java包對映資訊的XML名稱空間。
</xsd:documentation>
<xsd:element name=3D"interface" type=3D"tns:interfaceType" minOccurs=3D"0" maxOccurs=3D"unbounded"/>
<xsd:element name=3D"typeMappingRegistry" type=3D"tns:typeMappingRegistryType" minOccurs=3D"0"/>
<xsd:element name=3D"handlerChains" type=3D"tns:handlerChainsType" minOccurs=3D"0"/>
<xsd:element name=3D"namespaceMappingRegistry" type=3D"tns:namespaceMappingRegistryType" minOccurs=3D"0"/>
<xsd:attribute name=3D"name" type=3D"xsd:string" use=3D"required"/>
<xsd:attribute name=3D"targetNamespace" type=3D"xsd:anyURI" use=3D"required"/>
<xsd:attribute name=3D"typeNamespace" type=3D"xsd:anyURI" use=3D"required"/>
<xsd:attribute name=3D"packageName" type=3D"xsd:string" use=3D"required"/>
"servantName" (可選)—— 服務端實現類的名稱;
"soapAction" (可選)—— 用於介面中所有操作的SOAPAction字串;
"soapActionBase" (可選) —— 基於SOAPAction字串的URI;給定操作的SOAPAction可以通過向這裡提供的值中新增操作名稱來獲取;這個屬性是“soapAction”專有的。
"handlerChains" ——指定該端點的處理程式鏈。
<xsd:element name=3D"handlerChains" type=3D"tns:handlerChainsType" minOccurs=3D"0"/>
</xsd:sequence>
<xsd:attribute name=3D"name" type=3D"xsd:string" use=3D"required"/>
<xsd:attribute name=3D"servantName" type=3D"xsd:string"/>
<xsd:attribute name=3D"soapAction" type=3D"xsd:string"/>
<xsd:attribute name=3D"soapActionBase" type=3D"xsd:string"/>
</xsd:complexType>
"typeMappingRegistry"? ——用於該服務的型別對映登錄檔;
"handlerChains"? —— 用於該服務端點的預設處理程式鏈;
"namespaceMappingRegistry"? —— 到Java包的對映資訊的XML名稱空間。
</xsd:documentation>
<xsd:element name=3D"typeMappingRegistry" type=3D"tns:typeMappingRegistryType" minOccurs=3D"0"/>
<xsd:element name=3D"handlerChains" type=3D"tns:handlerChainsType" minOccurs=3D"0"/>
<xsd:element name=3D"namespaceMappingRegistry" type=3D"tns:namespaceMappingRegistryType" minOccurs=3D"0"/>
<xsd:attribute name=3D"location" type=3D"xsd:anyURI" use=3D"required"/>
<xsd:attribute name=3D"packageName" type=3D"xsd:string" use=3D"required"/>
</xsd:complexType>
屬性:
"location" —— 模型檔案的URL (通常以.xml.gz結尾);
<xsd:attribute name=3D"location" type=3D"xsd:anyURI" use=3D"required"/>
屬性:
"runAt" ——指定該鏈是執行在客戶端還是伺服器上。
"roles" ——該鏈的SOAP角色。
元素:
"handler"* ——形成該鏈的處理程式序列。
<xsd:element name=3D"chain" type=3D"tns:chainType" minOccurs=3D"0" maxOccurs=3D"unbounded"/>
</xsd:sequence>
<xsd:list itemType=3D"xsd:anyURI"/>
屬性:
"property"* ——該處理程式的初始化特性(property)。
<xsd:element name=3D"property" type=3D"tns:propertyType" minOccurs=3D"0" maxOccurs=3D"unbounded"/>
<xsd:attribute name=3D"className" type=3D"xsd:string" use=3D"required"/>
<xsd:attribute name=3D"headers" type=3D"tns:headerListType"/>
<xsd:simpleType name=3D"headerListType">
<xsd:documentation>
<xsd:list itemType=3D"xsd:QName"/>
<xsd:complexType name=3D"propertyType">
<xsd:documentation>
<xsd:sequence>
</xsd:sequence>
<xsd:attribute name=3D"name" type=3D"xsd:string" use=3D"required"/>
<xsd:attribute name=3D"value" type=3D"xsd:string" use=3D"required"/>
<xsd:simpleType name =3D"runAtType">
<xsd:documentation>
</xsd:documentation>
<xsd:restriction base=3D"xsd:string">
<xsd:enumeration value=3D"client"/>
<xsd:enumeration value=3D"server"/>
<xsd:complexType name=3D"typeMappingRegistryType">
<xsd:documentation>
元素:
"import"? —— XML Schema文件的列表,描述了使用者定義的型別。
"typeMapping"* ——型別對映序列,每編碼一個。
"additionalTypes"? ——即使不出現在服務介面上,也應該進行處理的附加Java型別的列表。
<xsd:sequence>
<xsd:element name=3D"import" type=3D"tns:importType" minOccurs=3D"0"/>
<xsd:element name=3D"typeMapping" type=3D"tns:typeMappingType" minOccurs=3D"0" maxOccurs=3D"unbounded"/>
<xsd:element name=3D"additionalTypes" type=3D"tns:additionalTypesType" minOccurs=3D"0"/>
</xsd:complexType>
<xsd:complexType name=3D"importType">
<xsd:documentation>
需要匯入的模式文件的列表,通常描述被可插入式序列化器使用的模式型別。
<xsd:sequence>
<xsd:element name=3D"schema" type=3D"tns:schemaType" minOccurs=3D"0" maxOccurs=3D"unbounded"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name=3D"schemaType">
<xsd:documentation>
屬性:
"location" —— 指向模式文件的 URL。
</xsd:sequence>
<xsd:attribute name=3D"namespace" type=3D"xsd:anyURI" use=3D"required"/>
<xsd:attribute name=3D"location" type=3D"xsd:anyURI" use=3D"required"/>
<xsd:complexType name=3D"typeMappingType">
<xsd:documentation>
<xsd:element name=3D"entry" type=3D"tns:entryType" minOccurs=3D"0" maxOccurs=3D"unbounded"/>
<xsd:attribute name=3D"encodingStyle" type=3D"xsd:anyURI" use=3D"required"/>
</xsd:complexType>
<xsd:complexType name=3D"entryType">
<xsd:documentation>
屬性:
"serializerFactory" —— 用於該型別的序列化器工廠類的名稱;
"deserializerFactory" —— 用於該型別的反序列化器工廠類的名稱。
</xsd:sequence>
<xsd:attribute name=3D"schemaType" type=3D"xsd:QName" use=3D"required"/>
<xsd:attribute name=3D"javaType" type=3D"xsd:string" use=3D"required"/>
<xsd:attribute name=3D"serializerFactory" type=3D"xsd:string" use=3D"required"/>
<xsd:attribute name=3D"deserializerFactory" type=3D"xsd:string" use=3D"required"/>
</xsd:complexType>
<xsd:complexType name=3D"additionalTypesType">
<xsd:documentation>
元素:
<xsd:sequence>
<xsd:element name=3D"class" type=3D"tns:classType" minOccurs=3D"0" maxOccurs=3D"unbounded"/>
</xsd:complexType>
<xsd:complexType name=3D"classType">
<xsd:documentation>
<xsd:sequence> </xsd:sequence>
<xsd:attribute name=3D"name" type=3D"xsd:string" use=3D"required"/>
<xsd:complexType name=3D"namespaceMappingRegistryType">
<xsd:annotation>
將XML名稱空間對映到Java包(以及從Java包對映到XML名稱空間)的登錄檔。
<xsd:sequence>
<xsd:element name=3D"namespaceMapping" type=3D"tns:namespaceMappingType" minOccurs=3D"0" maxOccurs=3D"unbounded"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name=3D"namespaceMappingType">
<xsd:documentation>
<xsd:sequence>
</xsd:sequence>
<xsd:attribute name=3D"namespace" type=3D"xsd:anyURI" use=3D"required"/>
<xsd:attribute name=3D"packageName" type=3D"xsd:string" use=3D"required"/>
</xsd:schema>
XML Schema用於部署描述檔案
下面的程式碼是用於建立Web service 部署描述檔案的XML模式:
<?xml version=3D"1.0" encoding=3D"UTF-8"?>
xmlns:xsd=3D"http://www.w3.org/2001/XMLSchema"
xmlns:tns=3D"http://java.sun.com/xml/ns/jax-rpc/ri/dd"
targetNamespace=3D"http://java.sun.com/xml/ns/jax-rpc/ri= /dd"
elementFormDefault=3D"qualified"
attributeFormDefault=3D"unqualified"
<xsd:annotation>
<xsd:documentation>
<xsd:element name=3D"webServices">
<xsd:documentation>
"targetNamespaceBase"? ——WSDL文件的thetargetNamespace的基礎URI,該WSDL文件是為那些沒有自己的模型檔案的端點而生成的;
"typeNamespaceBase"? ——類似於"targetNamespaceBase",但是用於嵌 入在已生成的WSDL 文件中的XML Schema文件;
"urlPatternBase"? ——用於所有端點的基礎 URL式樣(pattern);通過使用和"endpointMapping(端點對映)",它能夠被過載 (見下文)。
對於所有這些基礎特性,用於特定端點的值可以由帶有追加到它的端點名的基礎值來指定。
<xsd:sequence>
<xsd:element name=3D"endpoint" type=3D"tns:endpointType"minOccurs=3D"0" maxOccurs=3D"unbounded"/>
<xsd:element name=3D"endpointMapping"type=3D"tns:endpointMappingType" minOccurs=3D"0" maxOccurs=3D"unbounded"/>
</xsd:sequence>
<xsd:attribute name=3D"version" type=3D"xsd:string"use=3D"required"/>
<xsd:attribute name=3D"targetNamespaceBase" type=3D"xsd:string"/>
<xsd:attribute name=3D"typeNamespaceBase" type=3D"xsd:string"/>
<xsd:attribute name=3D"urlPatternBase" type=3D"xsd:string"/>
</xsd:element>
<xsd:complexType name=3D"endpointType">
<xsd:documentation>
元素:
<xsd:sequence>
<xsd:element name=3D"handlerChains" type=3D"tns:handlerChainsType" minOccurs=3D"0"/>
<xsd:attribute name=3D"name" type=3D"xsd:string" use=3D"required"/>
<xsd:attribute name=3D"displayName" type=3D"xsd:string"/>
<xsd:attribute name=3D"description" type=3D"xsd:string"/>
<xsd:attribute name=3D"interface" type=3D"xsd:string"/>
<xsd:attribute name=3D"implementation" type=3D"xsd:string"/>
<xsd:attribute name=3D"model" type=3D"xsd:anyURI"/>
<xsd:complexType name=3D"endpointMappingType">
<xsd:documentation>
屬性:
"urlPattern" —— 端點的URL式樣(pattern)。
<xsd:sequence>
</xsd:sequence>
<xsd:attribute name=3D"endpointName" type=3D"xsd:string" use=3D"required"/>
<xsd:attribute name=3D"urlPattern" type=3D"xsd:string" use=3D"required"/>
<xsd:complexType name=3D"handlerChainsType">
<xsd:documentation>
一組handlerChains。在部署描述檔案中,只有server端的處理程式鏈能夠識別。
<xsd:sequence>
<xsd:element name=3D"chain" type=3D"tns:chainType" minOccurs=3D"0" maxOccurs=3D"unbounded"/>
</xsd:complexType>
<xsd:complexType name=3D"chainType">
xsd:documentation>
<xsd:sequence>
<xsd:element name=3D"handler" type=3D"tns:handlerType" minOccurs=3D"0" maxOccurs=3D"unbounded"/>
</xsd:sequence>
<xsd:attribute name=3D"runAt" type=3D"tns:runAtType" use=3D"required"/>
<xsd:attribute name=3D"roles" type=3D"tns:roleListType"/>
<xsd:simpleType name=3D"roleListType">
<xsd:documentation>
<xsd:list itemType=3D"xsd:anyURI"/>
<xsd:complexType name=3D"handlerType">
<xsd:documentation>
<xsd:sequence>
<xsd:element name=3D"property" type=3D"tns:propertyType" minOccurs=3D"0" maxOccurs=3D"unbounded"/>
</xsd:sequence>
<xsd:attribute name=3D"className" type=3D"xsd:string" use=3D"required"/>
<xsd:attribute name=3D"headers" type=3D"tns:headerListType"/>
<xsd:simpleType name=3D"headerListType">
<xsd:documentation>
<xsd:list itemType=3D"xsd:QName"/>
<xsd:complexType name=3D"propertyType">
<xsd:documentation>
<xsd:sequence>
</xsd:sequence>
<xsd:attribute name=3D"name" type=3D"xsd:string" use=3D"required"/>
<xsd:attribute name=3D"value" type=3D"xsd:string" use=3D"required"/>
<xsd:simpleType name =3D"runAtType">
<xsd:documentation>
</xsd:documentation>
<xsd:restriction base=3D"xsd:string">
<xsd:enumeration value=3D"client"/>
<xsd:enumeration value=3D"server"/>
</xsd:simpleType>
XML Schema用於已匯出的的wscompile模型檔案
下面程式碼是已匯出的的wscompile模型檔案的XML模式:
<?xml version=3D"1.0" encoding=3D"UTF-8"?>
xmlns:xsd=3D"http://www.w3.org/2001/XMLSchema"
xmlns:tns=3D"http://java.sun.com/xml/ns/jax-rpc/ri/model= "
targetNamespace=3D"http://java.sun.com/xml/ns/jax-rpc/ri= /model"
elementFormDefault=3D"unqualified"
attributeFormDefault=3D"unqualified" version=3D"1.0">
<xsd:documentation>
這是已匯出的的wscompile模型檔案的XML模式。已匯出的模型是物件的圖表表示,其中有些是“直接的(immediate)”(比如整型、字串型),“直接的”物件有一個實際的值。
非直接的物件有一組物件-賦值(object-valued)特性。
<xsd:element name=3D"model" form=3D"qualified">
<xsd:documentation>
</xsd:documentation>
<xsd:complexType>
<xsd:sequence minOccurs=3D"0" maxOccurs=3D"unbounded">
<xsd:element name=3D"object" type=3D"tns:objectType"/>
<xsd:element name=3D"iobject" type=3D"tns:iobjectType"/>
<xsd:element name=3D"property" type=3D"tns:propertyType"/>
</xsd:choice>
</xsd:sequence>
<xsd:attribute name=3D"version" type=3D"xsd:string" use=3D"required"/>
</xsd:element>
<xsd:complexType name=3D"objectType">
<xsd:documentation>
</xsd:documentation>
<xsd:sequence/>
<xsd:attribute name=3D"id" type=3D"xsd:string" use=3D"required"/>
<xsd:attribute name=3D"type" type=3D"xsd:string" use=3D"required"/>
</xsd:documentation>
<xsd:sequence/>
<xsd:attribute name=3D"id" type=3D"xsd:string" use=3D"required"/>
<xsd:attribute name=3D"type" type=3D"xsd:string" use=3D"required"/>
<xsd:attribute name=3D"value" type=3D"xsd:string" use=3D"required"/>
特性定義。也就是說“主題”(由id來識別)有一個稱為“name”的特性,將id為“value”的物件作為它的值。
</xsd:documentation>
<xsd:attribute name=3D"name" type=3D"xsd:string" use=3D"required"/>
<xsd:attribute name=3D"subject" type=3D"xsd:string" use=3D"required"/>
<xsd:attribute name=3D"value" type=3D"xsd:string" use=3D"required"/>
</xsd:schema>
XML Schema 用於執行時描述檔案
<?xml version=3D"1.0" encoding=3D"UTF-8"?>
xmlns:xsd=3D"http://www.w3.org/2001/XMLSchema"
xmlns:tns=3D"http://java.sun.com/xml/ns/jax-rpc/ri/runti= me"
targetNamespace=3D"http://java.sun.com/xml/ns/jax-rpc/ri= /runtime"
elementFormDefault=3D"qualified"
attributeFormDefault=3D"unqualified"
<xsd:annotation>
這是執行時描述檔案 (jaxrpc-ri-runtime.xml)的模式。
</xsd:documentation>
<xsd:element name=3D"endpoints">
<xsd:complexType>
<xsd:sequence>
<xsd:element name=3D"endpoint" type=3D"tns:endpointType" minOccurs=3D"0" maxOccurs=3D"unbounded"/>
</xsd:sequence>
<xsd:attribute name=3D"version" type=3D"xsd:string" use=3D"required"/>
</xsd:element>
<xsd:complexType name=3D"endpointType">
<xsd:documentation>
"interface" ——端點的Java介面名稱 (專業上稱為“服務端點介面”);
"service"? —— 屬於端點的WSDL服務的QName ;
<xsd:sequence>
</xsd:sequence>
<xsd:attribute name=3D"name" type=3D"xsd:string" use=3D"required"/>
<xsd:attribute name=3D"interface" type=3D"xsd:string" use=3D"required"/>
<xsd:attribute name=3D"implementation" type=3D"xsd:string" use=3D"required"/>
<xsd:attribute name=3D"tie" type=3D"xsd:string" use=3D"required"/>
<xsd:attribute name=3D"model" type=3D"xsd:string"/>
<xsd:attribute name=3D"wsdl" type=3D"xsd:anyURI"/>
<xsd:attribute name=3D"service" type=3D"xsd:anyURI"/>
<xsd:attribute name=3D"port" type=3D"xsd:anyURI"/>
<xsd:attribute name=3D"urlpattern" type=3D"xsd:anyURI" use=3D"required"/>
</xsd:schema>
相關文章
- XML Schema(XSD)詳解:定義 XML 文件結構合法性的完整指南XML
- XML Schema 複雜元素型別詳解:定義及示例解析XML型別
- 給XML檔案定義DTDXML
- 《甘十九妹》 ent 實現之 Schema 定義
- 用IBM Data Studio定義Schema Annotations標記BMIBM
- 如何給XML Schema增加Annotations標記BHXML
- Spring系列-XML schema擴充套件機制SpringXML套件
- activiti7 獲取流程定義的xmlXML
- Spring 定時器的使用—Xml、Annotation、自定義Spring定時器XML
- Spring 定時器的使用---Xml、Annotation、自定義Spring定時器XML
- 面向切面的Spring(二) xml中定義aopSpringXML
- Spring 中的 XML schema 擴充套件機制SpringXML套件
- SVG XML 格式定義圖形入門介紹SVGXML
- Spring基礎使用(三)-------XML定義AOP的使用SpringXML
- Spring系列第四講 xml中bean定義詳解SpringXMLBean
- XML Schema 字串資料型別及約束詳解XML字串資料型別
- 緣起 Dubbo ,講講 Spring XML Schema 擴充套件機制SpringXML套件
- 聊聊 Spring 的 XML Schema 擴充套件機制的使用方式SpringXML套件
- RadioGroup 在TS schema 中的設定
- spring中bean.xml的http://www.springframework.org/schema/bean報錯SpringBeanXMLHTTPFramework
- No grammar constraints (DTD or XML Schema) referenced in the document.的兩種解決辦法AIXML
- 探索 DTD 在 XML 中的作用及解析:深入理解文件型別定義XML型別
- Java Spring Beans.xml裡的Bean定義是如何被解析出來的JavaSpringBeanXML
- XML Query, 語義Web今年運勢XMLWeb
- Mybatis xml特殊符號轉義寫法MyBatisXML符號
- 需求定義
- Springbean定義SpringBean
- 巨集定義
- 如何提取SAP UI5 XML view裡定義的欄位元素繫結資訊(binding path)UIXMLView
- Json Schema簡介和Json Schema的.net實現庫 LateApexEarlySpeed.Json.SchemaJSON
- DOM4J 解析 XML 之忽略轉義字元XML字元
- 定義製造業操作(定義 MES/MOM 系統)
- 育種定義
- 類的定義
- 類定義介面
- 成功的定義
- 程式的定義
- Linus 定義 LinuxLinux