如何删除XSD模式中的所有引用

如何删除XSD模式中的所有引用,xsd,schema,Xsd,Schema,例如,我有这样一个模式: <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:pref="http://someaddr.com" elementFormDefault="qualified" targetNamespace="http://otheraddr.com"> <xs:element name="rootElem"> <xs:complexType>

例如,我有这样一个模式:

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:pref="http://someaddr.com" elementFormDefault="qualified" targetNamespace="http://otheraddr.com">
   <xs:element name="rootElem">
     <xs:complexType>
       <xs:sequence>
         <xs:element ref="pref:elem1" minoccurs="1" and maxoccurs="2"/>
         <xs:element ref="pref:elem2" minoccurs="1" and maxoccurs="2"/>
       </xs:sequence>
     </xs:complexType>
   </xs:element>
   <xs:element name="elem1" type="xs:string"/>
   <xs:element name="elem2" type="xs:date"/>
</xs:schema>

我想转换并保留所有全局元素声明和最小最大发生率细节

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:pref="http://someaddr.com" elementFormDefault="qualified" targetNamespace="http://otheraddr.com">
           <xs:element name="rootElem">
             <xs:complexType>
               <xs:sequence>
                 <xs:element name="elem1" type="xs:string" minoccurs="1" and maxoccurs="2"/>
                 <xs:element name="elem2" type="xs:string" minoccurs="1" and maxoccurs="2" />
               </xs:sequence>
             </xs:complexType>
           </xs:element>
        <xs:element name="elem1" type="xs:string"/>
           <xs:element name="elem2" type="xs:date"/>
        </xs:schema


我想你有几个选择

  • 最简单的方法可能是用记事本++之类的东西打开xsd,然后进行简单的查找和替换-例如,您可以替换
  • 作为替代方案,您可以创建xml文档的简单版本,并通过XSD()运行它来创建新的XSD,然后修改它以满足您的需要

在这两种情况下,我都建议通过验证器运行它—W3C验证器非常好。

谢谢您的回答,但我希望使用XSLT脚本进行修改,以便将其用作流程流的一部分