Schema 小结

对下面的schema :

<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://data.library.j2c.test" xmlns:data="http://data.library.j2c.test">
<element name="getAuthorRequest" type="data:BookName"></element>
<complexType name="BookName">
 <sequence minOccurs="1" maxOccurs="1">
  <element name="Name" type="string"></element>
 </sequence>
</complexType>

<element name="getAuthorResponse" type="data:AuthorName"></element>
<complexType name="AuthorName">
 <sequence minOccurs="1" maxOccurs="1">
  <element name="Name" type="string"></element>
 </sequence>
</complexType>
</schema>

xmlns="http://www.w3.org/2001/XMLSchema" 表示默认的命名空间,element,complexType,sequence,schema属于此命名空间。

targetNamespace="http://data.library.j2c.test" 表示schema定义的元素的命名空间,包括BookName,AuthorName,这里,xmlns:data="http://data.library.j2c.test" 和targetNamespace相同,所以,当引用schema定义的元素时,使用data来标志命令空间。

对如下schema

<?xml version="1.0"?><note xmlns="http://www.w3schools.com"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://www.w3schools.com note.xsd">
<to>Tove</to><from>Jani</from><heading>Reminder</heading><body>Don't forget me this weekend!</body></note>

默认命名空间为xmlns=http://www.w3schools.com,to、from、heading、body、note来自该命令空间,这里,  xsi:schemaLocation=http://www.w3schools.com note.xsd 指明了该命名空间来自note.xsd文件


include 用同一目标名称空间把多项schema添加到文件

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:bo="http://data.library.j2c.test" xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://data.library.j2c.test">
  <xsd:annotation>
    <xsd:appinfo source="wid.federated.schema"/>
  </xsd:annotation>
  <xsd:include schemaLocation="../test/j2c/library/TestName.xsd"/>
  <xsd:include schemaLocation="../test/j2c/library/library.xsd"/>
</xsd:schema>

import  用不同的目标名称空间把多项schema添加到一份文件

    <xsd:schema targetNamespace="http://tempuri.org/library/" xmlns:bons1="http://data.library.j2c.test" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
            <xsd:import namespace="http://data.library.j2c.test" schemaLocation="../../../xsd-includes/http.data.library.j2c.test.xsd"/>
            <xsd:element name="getAuthorResponse" type="bons1:AuthorName"/>
      <xsd:element name="getAuthorRequest" type="bons1:BookName"/>
    </xsd:schema>

 

参考:

http://www.w3pop.com/tech/school/schema/schema_elements_ref.asp

http://www.w3pop.com/tech/school/wsdl/default.asp

http://www-128.ibm.com/developerworks/cn/xml/theme/x-schema.html 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值