以文本方式查看主题

-  中文XML论坛 - 专业的XML技术讨论区  (http://bbs.xml.org.cn/index.asp)
--  『 DTD/XML Schema 』  (http://bbs.xml.org.cn/list.asp?boardid=23)
----  用xmlspy生成的三个schema文件,能否合并?  (http://bbs.xml.org.cn/dispbbs.asp?boardid=23&rootid=&id=53568)


--  作者:lgn21st
--  发布时间:10/10/2007 12:23:00 AM

--  用xmlspy生成的三个schema文件,能否合并?
我通过xmlspy针对一个指定的xml文件生成三个.xsd的schema文件
第一个xsd文件improt第二个xsd文件,第二个xsd文件import第三个xsd文件
每个文件的targetNamespace不同,在linux终端用xmllint作xml的schema验证通过
但是需要用ruby写一个自动验证的脚本,其中schema验证功能采用第三方lib由libxml-ruby来实现的
我现在碰到的问题是,ruby程序载入第一个xsd文件作为string载入后,无法识别xsd文件中的import节
点里指向第二个xsd文件的路径,我理解是ruby程序有自己的load path,不能直接从xml文件内容中解析
想到的办法是有没有什么途径可以将三个xsd文件合并成一个,消除文件中的import?

下面我贴上三个xsd文件:
文件一(create_customer_response.xsd):
<?xml version="1.0" encoding="UTF-8"?>

<xs:schema

  xmlns:xs="http://www.w3.org/2001/XMLSchema"

  targetNamespace="http://www.w3.org/2003/05/soap-envelope"

  xmlns="http://schemas.microsoft.com/dynamics/2006/02/documents/Customers"

  xmlns:soap="http://www.w3.org/2003/05/soap-envelope"

  elementFormDefault="qualified">

  

  <xs:import

    namespace="http://schemas.microsoft.com/dynamics/2006/02/documents/Customers"

    schemaLocation="create_customer_response1.xsd"/>

  

  <xs:element name="Body">

    <xs:complexType>

      <xs:sequence>

        <xs:element ref="createCustomersResponse"/>

      </xs:sequence>

    </xs:complexType>

  </xs:element>

  

  <xs:element name="Envelope">

    <xs:complexType>

      <xs:sequence>

        <xs:element ref="soap:Body"/>

      </xs:sequence>

    </xs:complexType>

  </xs:element>

  

</xs:schema>


文件二(create_customer_response1.xsd):
<?xml version="1.0" encoding="UTF-8"?>

<xs:schema

  xmlns:xs="http://www.w3.org/2001/XMLSchema"

  targetNamespace="http://schemas.microsoft.com/dynamics/2006/02/documents/Customers"

  xmlns="http://schemas.microsoft.com/dynamics/2006/02/documents/EntityKey"

  elementFormDefault="qualified">

  <xs:import

    namespace="http://schemas.microsoft.com/dynamics/2006/02/documents/EntityKey"

    schemaLocation="create_customer_response2.xsd"/>

 <xs:element name="createCustomersResponse">

  <xs:complexType>

   <xs:sequence>

    <xs:element ref="EntityKey"/>

   </xs:sequence>

  </xs:complexType>

 </xs:element>

</xs:schema>


文件三(create_customer_response2.xsd):
<?xml version="1.0" encoding="UTF-8"?>

<xs:schema

  xmlns:xs="http://www.w3.org/2001/XMLSchema"

  targetNamespace="http://schemas.microsoft.com/dynamics/2006/02/documents/EntityKey"

  xmlns="http://schemas.microsoft.com/dynamics/2006/02/documents/EntityKey"

  elementFormDefault="qualified">

 <xs:element name="EntityKey">

  <xs:complexType>

   <xs:sequence>

    <xs:element ref="KeyData"/>

   </xs:sequence>

  </xs:complexType>

 </xs:element>

 <xs:element name="Field">

  <xs:simpleType>

   <xs:restriction base="xs:string">

    <xs:enumeration value="AccountNum"/>

   </xs:restriction>

  </xs:simpleType>

 </xs:element>

 <xs:element name="KeyData">

  <xs:complexType>

   <xs:sequence>

    <xs:element ref="KeyField"/>

   </xs:sequence>

  </xs:complexType>

 </xs:element>

 <xs:element name="KeyField">

  <xs:complexType>

   <xs:sequence>

    <xs:element ref="Field"/>

    <xs:element ref="Value"/>

   </xs:sequence>

  </xs:complexType>

 </xs:element>

 <xs:element name="Value">

  <xs:simpleType>

   <xs:restriction base="xs:string">

    <xs:enumeration value="CU 0101757"/>

   </xs:restriction>

  </xs:simpleType>

 </xs:element>

</xs:schema>


W 3 C h i n a ( since 2003 ) 旗 下 站 点
苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
45.898ms