XML 模式 - “此上下文中不支持元素" [英] XML schema - "Element not supported in this context"

查看:40
本文介绍了XML 模式 - “此上下文中不支持元素"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的代码中的最后一个内容有问题.它说:

<块引用>

"

<xs:element name="Ansökan"><xs:complexType><xs:序列><xs:element name="hejsanförskolan"><xs:complexType><xs:序列><xs:element maxOccurs="2" name="vårdnadstagare"><xs:complexType><xs:序列><xs:element name="personnummer" type="datatypPersonnummer"minOccurs="1"/><xs:element name="förnamn" type="xs:string" minOccurs="1"/><xs:element name="efternamn" type="xs:string" minOccurs="1"/><xs:element name="Adress" type="xs:string" minOccurs="1"/><xs:element name="Telefonnummer" type="xs:unsignedInt" minOccurs="1"/></xs:sequence></xs:complexType></xs:element><xs:element name="ömmandeskäl"><xs:complexType><xs:序列><xs:element name="allergi" type="xs:string"/></xs:sequence></xs:complexType></xs:element></xs:sequence></xs:complexType></xs:element><xs:simpleType name="datatypPersonnummer"><xs:restriction base="xs:string"><xs:pattern value="[0-9]{10}"/></xs:restriction></xs:simpleType></xs:sequence></xs:complexType></xs:element></xs:schema>

解决方案

查看另一个内联类型(对于元素 vårdnadstagare):您的序列包含一个包含该类型的元素.

>

但在出现错误的情况下,您已将简单类型 direct 放入序列中.

你需要一个元素.

例如

…<xs:element name="datatypPersonnummer"><xs:simpleType><xs:restriction base="xs:string"><xs:pattern value="[0-9]{10}"/></xs:restriction></xs:simpleType></xs:element>

即.将现有的 包装在新的 中,将 name 属性移动到到新元素.

I'm having a problem with my last content in my code. It says that:

"http://www.w3.org/2001/XMLSchema" is not supported in this context.

How do I solve this?

Screenshot of the problem:

<?xml version="1.0" encoding="utf-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified"   
xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="Ansökan">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="hejsanförskolan">
          <xs:complexType>
            <xs:sequence>   
              <xs:element maxOccurs="2" name="vårdnadstagare">
                <xs:complexType>
                  <xs:sequence>
                    <xs:element name="personnummer" type="datatypPersonnummer"minOccurs="1" />
                    <xs:element name="förnamn" type="xs:string" minOccurs="1" />
                    <xs:element name="efternamn" type="xs:string" minOccurs="1" />
                    <xs:element name="Adress" type="xs:string" minOccurs="1" />
                    <xs:element name="Telefonnummer" type="xs:unsignedInt" minOccurs="1" />
                  </xs:sequence>
                </xs:complexType>
              </xs:element>                 
              <xs:element name="ömmandeskäl">
                <xs:complexType>
                  <xs:sequence>
                    <xs:element name="allergi" type="xs:string" />
                  </xs:sequence>
                </xs:complexType>
              </xs:element>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
        <xs:simpleType name="datatypPersonnummer">
          <xs:restriction base="xs:string">
            <xs:pattern value="[0-9]{10}"/>
          </xs:restriction>
        </xs:simpleType>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>

解决方案

Look at the other inline type (for element vårdnadstagare): you have the sequence containing an element which contains the type.

But in the case with the error you've put the simple type direct in the sequence.

You need an element there.

Eg.

<xs:sequence>
  …
  <xs:element name="datatypPersonnummer">
     <xs:simpleType>
       <xs:restriction base="xs:string">
         <xs:pattern value="[0-9]{10}"/>
       </xs:restriction>
     </xs:simpleType>
   </xs:element>

Ie. wrap existing <xs:simpleType name="datatypPersonnummer"> in a new <xs:element>, moving the name attribute on to the new element.

这篇关于XML 模式 - “此上下文中不支持元素"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆