Reputation: 33
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>
Upvotes: 3
Views: 23761
Reputation: 86
Type datatypPersonnummer is in the wrong location. This works:
</xs:complexType>
</xs:element>
<xs:simpleType name="datatypPersonnummer">
<xs:restriction base="xs:string">
<xs:pattern value="[0-9]{10}"/>
</xs:restriction>
</xs:simpleType>
</xs:schema>
Upvotes: 0
Reputation: 109180
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.
Upvotes: 3