not supported (error)

C

csharpula csharp

Hello I keep getting such error:

The 'http://www.w3.org/2001/XMLSchema:restriction' element is not
supported in this context.

for the following xsd element:

<xs:element name="Name" type="xs:NCName">
<xs:restriction base="xs:string">
<xs:enumeration value="Audi"/>
<xs:enumeration value="Golf"/>
<xs:enumeration value="BMW"/>
</xs:restriction>
</xs:element>

Why is that? Thank you
 
A

Alex Meleta

Hi csharpula,

Meens that having xs:element as a parent for xs:restriction is not a good
choice. Only simpleType, simpleContent and complexContent are allowed to
be parent of xs:restriction. Put something like following instead:

<xs:element name="Name">
<xs:simpleType>
<xs:restriction></xs:restriction>
</xs:simpleType>

Regards, Alex
[TechBlog] http://devkids.blogspot.com

cc> Hello I keep getting such error:
cc>
cc> The 'http://www.w3.org/2001/XMLSchema:restriction' element is not
cc> supported in this context.
cc>
cc> for the following xsd element:
cc>
cc> <xs:element name="Name" type="xs:NCName">
cc> <xs:restriction base="xs:string">
cc> <xs:enumeration value="Audi"/>
cc> <xs:enumeration value="Golf"/>
cc> <xs:enumeration value="BMW"/>
cc> </xs:restriction>
cc> </xs:element>
cc> Why is that? Thank you
cc>
cc>
cc>
 
M

Martin Honnen

csharpula said:
Hello I keep getting such error:

The 'http://www.w3.org/2001/XMLSchema:restriction' element is not
supported in this context.

for the following xsd element:

<xs:element name="Name" type="xs:NCName">
<xs:restriction base="xs:string">
<xs:enumeration value="Audi"/>
<xs:enumeration value="Golf"/>
<xs:enumeration value="BMW"/>
</xs:restriction>
</xs:element>

Why is that?

What does that have to do with C#? Note that followup-to is set to
microsoft.public.dotnet.xml.

If you want to define the type of an element as an enumeration then the
proper schema syntax is
<xs:element name="Name">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="Audi"/>
<xs:enumeration value="Golf"/>
<xs:enumeration value="BMW"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
 
C

csharpula csharp

Another question more related to c# and to xsd is how to do it without
planting the restriction tags into xsd but do it inside c# with
attributes. Is it possible? Thank u very much!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top