如何从XML文件创建XSD架构文件?

时间:2010-08-08 00:05:19

标签: xml xsd

我正在尝试从现有的XML文件创建XSD架构文件,但是我遇到了错误。目前我正在尝试使用XSD命令提示符工具生成XSD文件。有关我的XML文件错误的任何建议吗?或者我应该尝试的任何其他工具?这是我的XML文件:

<xml xmlns:s='uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882'
    xmlns:dt='uuid:C2F41010-65B3-11d1-A29F-00AA00C14882'
    xmlns:rs='urn:schemas-microsoft-com:rowset'
    xmlns:z='#RowsetSchema'>
<s:Schema id='RowsetSchema'>
    <s:ElementType name='row' content='eltOnly'>
        <s:AttributeType name="c0" rs:name="FIRST_NAME" rs:number="1" rs:nullable="true">
            <s:datatype dt:type="string" rs:dbtype="str" dt:maxLength="30"/>
        </s:AttributeType>
        <s:AttributeType name="c1" rs:name="MIDDLE_NAME" rs:number="2" rs:nullable="true">
            <s:datatype dt:type="string" rs:dbtype="str" dt:maxLength="30"/>
        </s:AttributeType>
        <s:AttributeType name="c2" rs:name="LAST_NAME" rs:number="3">
            <s:datatype dt:type="string" rs:dbtype="str" dt:maxLength="60" rs:maybenull="false"/>
        </s:AttributeType>
        <s:AttributeType name="c3" rs:name="OTHER_ID" rs:number="4" rs:nullable="true">
            <s:datatype dt:type="string" rs:dbtype="str" dt:maxLength="24"/>
        </s:AttributeType>
        <s:AttributeType name="c4" rs:name="FS_LUN_CODE_ID" rs:number="5" rs:nullable="true">
            <s:datatype dt:type="string" rs:dbtype="str" dt:maxLength="2"/>
        </s:AttributeType>
        <s:AttributeType name="c5" rs:name="FS_NAME_ID_PAYOR" rs:number="6" rs:nullable="true">
            <s:datatype dt:type="int" dt:maxLength="4" rs:precision="10" rs:fixedlength="true"/>
        </s:AttributeType>
        <s:AttributeType name="c6" rs:name="FS_TRAN_TIME" rs:number="7" rs:nullable="true">
            <s:datatype dt:type="int" dt:maxLength="4" rs:precision="10" rs:fixedlength="true"/>
        </s:AttributeType>
        <s:AttributeType name="c7" rs:name="NAME_ID" rs:number="8">
            <s:datatype dt:type="int" dt:maxLength="4" rs:precision="10" rs:fixedlength="true" rs:maybenull="false"/>
        </s:AttributeType>
        <s:AttributeType name="c8" rs:name="FS_TRAN_DATE" rs:number="9" rs:nullable="true">
            <s:datatype dt:type="date" dt:maxLength="6" rs:fixedlength="true"/>
        </s:AttributeType>
        <s:extends type="rs:rowbase"/>
</s:ElementType>
</s:Schema>
<rs:data>
    <z:row c0='SHELLI' c1='A' c2='AANENSON' c3='671590' c4='N' c5='0' c6='32885' c7='12' c8='2007-09-11'/>
    <z:row c0='SHELLI' c1='A' c2='AANENSON' c3='671590' c4='N' c5='0' c6='32885' c7='12' c8='2007-09-11'/>
    <z:row c0='SHELLI' c1='A' c2='AANENSON' c3='671590' c4='N' c5='0' c6='32885' c7='12' c8='2007-09-11'/>
    <z:row c0='SHELLI' c1='A' c2='AANENSON' c3='671590' c4='N' c5='0' c6='32885' c7='12' c8='2007-09-11'/>
    <z:row c0='WILLIAM' c1='' c2='AASEN' c3='916031' c4='N' c5='0' c6='55833' c7='13' c8='2007-07-27'/>
    <z:row c0='WILLIAM' c1='' c2='AASEN' c3='916031' c4='N' c5='0' c6='55833' c7='13' c8='2007-07-27'/>
    <z:row c0='WILLIAM' c1='' c2='AASEN' c3='916031' c4='N' c5='0' c6='55833' c7='13' c8='2007-07-27'/>
</rs:data>
</xml>

3 个答案:

答案 0 :(得分:1)

据我了解,XSDL架构文档只能描述一个命名空间。您的XML文档使用多个名称空间,因此您需要为每个名称空间(即dt.xsd,rs.xsd z.xsd等)提供XSD文件。

不熟悉SSIS,但我认为如果它支持多个XML命名空间并且可以针对模式验证每个命名空间,那么它应该支持每个命名空间的XSD。

答案 1 :(得分:0)

它看起来像是由NOTE-XML-Data定义的文档,W3C Note(不是Rec),而不是XML Schema Document。您的工具是否具有文档输出类型的选项?

答案 2 :(得分:0)

实现此目的的一个非常简单的方法是下载Altova XML Spy的30天试用版。它有一个非常好的XML到XSD功能,您可以完全自定义。

相关问题