English 中文(简体)
Xsd.exe架构错误:未定义的complexTypehttp://www.w3.org/2001/XMLSchema:string用作复杂类型限制的基础
原标题:Xsd.exe schema error: Undefined complexType http://www.w3.org/2001/XMLSchema:string is used as a base for complex type restriction

如何解决这个问题?

警告2未定义的complexTypehttp://www.w3.org/2001/XMLSchema:string用作复杂类型限制的基础。

这是因为<;xs:simpleContent><;xs:restriction-base=xs:string>

<xs:element name= TO >
    <xs:complexType>
      <xs:simpleContent>
        <xs:restriction base= xs:string >
          <xs:maxLength value= 15 />
          <xs:attribute name= PROVID >
            <xs:simpleType>
              <xs:restriction base= xs:int >
                <xs:enumeration value= 1 />
                <xs:enumeration value= 2 />
                <xs:enumeration value= 3 />
                <xs:enumeration value= 5 />
                <xs:enumeration value= 6 />
                <xs:enumeration value= 7 />
              </xs:restriction>
            </xs:simpleType>
          </xs:attribute>
          <xs:attribute name= TYPE >
            <xs:simpleType>
              <xs:restriction base= xs:string >
                <xs:enumeration value= NPM />
                <xs:enumeration value= EMS />
              </xs:restriction>
            </xs:simpleType>
          </xs:attribute>
        </xs:restriction>
      </xs:simpleContent>
    </xs:complexType>
  </xs:element>
</xs:schema>

查看W3schools参考这看起来不错,但根据VS2010和Xsd.exe

我真正想做的就是为元素to定义一个可以具有上述两个属性的元素,并且它的元素文本应该限制在15个字符以内。

最佳回答

不能将字符串限制为15个字符,并且同时将其扩展为具有属性的复杂类型。如果您首先定义一个受限制的字符串类型,然后对其进行扩展,则不会出现问题:

<xs:simpleType name="RestrictedString">
    <xs:restriction base="xs:string">
        <xs:maxLength value="15"/>
    </xs:restriction>   
</xs:simpleType>
<xs:element name="TO">
    <xs:complexType>
        <xs:simpleContent>
            <xs:extension base="RestrictedString">
                <xs:attribute name="PROVID">
                    <xs:simpleType>
                        <xs:restriction base="xs:int">
                            <xs:enumeration value="1"/>
                            <xs:enumeration value="2"/>
                            <xs:enumeration value="3"/>
                            <xs:enumeration value="5"/>
                            <xs:enumeration value="6"/>
                            <xs:enumeration value="7"/>
                        </xs:restriction>
                    </xs:simpleType>
                </xs:attribute>
                <xs:attribute name="TYPE">
                    <xs:simpleType>
                        <xs:restriction base="xs:string">
                            <xs:enumeration value="NPM"/>
                            <xs:enumeration value="EMS"/>
                        </xs:restriction>
                    </xs:simpleType>
                </xs:attribute>
            </xs:extension>
        </xs:simpleContent>
    </xs:complexType>
</xs:element>
问题回答

暂无回答




相关问题
Manually implementing high performance algorithms in .NET

As a learning experience I recently tried implementing Quicksort with 3 way partitioning in C#. Apart from needing to add an extra range check on the left/right variables before the recursive call, ...

Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How do I compare two decimals to 10 decimal places?

I m using decimal type (.net), and I want to see if two numbers are equal. But I only want to be accurate to 10 decimal places. For example take these three numbers. I want them all to be equal. 0....

Exception practices when creating a SynchronizationContext?

I m creating an STA version of the SynchronizationContext for use in Windows Workflow 4.0. I m wondering what to do about exceptions when Post-ing callbacks. The SynchronizationContext can be used ...

Show running instance in single instance application

I am building an application with C#. I managed to turn this into a single instance application by checking if the same process is already running. Process[] pname = Process.GetProcessesByName("...

How to combine DataTrigger and EventTrigger?

NOTE I have asked the related question (with an accepted answer): How to combine DataTrigger and Trigger? I think I need to combine an EventTrigger and a DataTrigger to achieve what I m after: when ...