Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7668693
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T15:25:29+00:00 2026-05-31T15:25:29+00:00

Visual Studio gave me an error I can’t see is really against the XML

  • 0

Visual Studio gave me an error I can’t see is really against the XML schema definition.

When I have a unique constraint on a collection which element I Ref to it says

When the ref attribute is present, the type attribute and complexType, simpleType, key, keyref, and unique elements cannot be present. 

Is this correct and if so am I forced to declare the child element within it’s parent?

<?xml version="1.0" encoding="utf-8"?>
<xs:schema  targetNamespace="http://mysticwarlords.kaa/XMLSchema"
            xmlns="http://mysticwarlords.kaa/XMLSchema"
            xmlns:xs="http://www.w3.org/2001/XMLSchema">

    <xs:simpleType name="titletype">
        <xs:restriction base="xs:string">
            <xs:enumeration value="Warlord"/>
            <xs:enumeration value="FirstMate"/>
            <xs:enumeration value="Jester"/>
        </xs:restriction>
    </xs:simpleType>

    <xs:element name="warlord">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="warlordName" type="xs:string"/>
            </xs:sequence>
            <xs:attribute name="title" type="titletype" />
        </xs:complexType>
    </xs:element>

    <xs:element name="warband">
        <xs:complexType>
          <xs:sequence>
            <xs:element name="warbandName" type="xs:string" />
            <xs:element name="warlords">
              <xs:complexType>
                <xs:sequence>
                  <xs:element ref="warlord" minOccurs="1" maxOccurs="unbounded">
                    <xs:unique name="eachTitleOnlyOnce">
                        <xs:selector xpath="warlord"/>
                        <xs:field xpath="@title"/>
                    </xs:unique>
                  </xs:element>
                </xs:sequence>
              </xs:complexType>
            </xs:element>
          </xs:sequence>
        </xs:complexType>
    </xs:element>

</xs:schema>

Am I using the Unique correct?

EDIT

What about this:

<xs:complexType  name="warlordtype">
    <xs:simpleContent>
      <xs:extension base="xs:string">
          <xs:attribute name="title" type="titletype" />
      </xs:extension>
    </xs:simpleContent>
</xs:complexType>

    <xs:element name="warband">
        <xs:complexType>
          <xs:sequence>
            <xs:element name="warbandName" type="xs:string" />
            <xs:element name="warlords">
              <xs:complexType>
                <xs:sequence>
                  <xs:element name="warlord" type="warlordtype" minOccurs="1" maxOccurs="unbounded">
                    <xs:unique name="eachTitleOnlyOnce">
                        <xs:selector xpath="warlord"/>
                        <xs:field xpath="@title"/>
                    </xs:unique>
                  </xs:element>
                </xs:sequence>
              </xs:complexType>
            </xs:element>
          </xs:sequence>
        </xs:complexType>
    </xs:element>

Why wouldn’t this work?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T15:25:31+00:00Added an answer on May 31, 2026 at 3:25 pm

    Unique element can’t be in ref element. Check element definition.

    Can you use this:

    <xs:schema xmlns="http://mysticwarlords.kaa/XMLSchema" xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://mysticwarlords.kaa/XMLSchema">
    <xs:simpleType name="titletype">
        <xs:restriction base="xs:string">
            <xs:enumeration value="Warlord"/>
            <xs:enumeration value="FirstMate"/>
            <xs:enumeration value="Jester"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:element name="warlord">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="warlordName" type="xs:string"/>
            </xs:sequence>
            <xs:attribute name="title" type="titletype"/>
        </xs:complexType>
        <xs:unique name="eachTitleOnlyOnce">
            <xs:selector xpath="warlord"/>
            <xs:field xpath="@title"/>
        </xs:unique>
    </xs:element>
    <xs:element name="warband">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="warbandName" type="xs:string"/>
                <xs:element name="warlords">
                    <xs:complexType>
                        <xs:sequence>
                            <xs:element ref="warlord" minOccurs="1" maxOccurs="unbounded"/>
                        </xs:sequence>
                    </xs:complexType>
                </xs:element>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
    

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Visual Studio Test can check for expected exceptions using the ExpectedException attribute. You can
I'm using visual studio to program this small TcpServer. It's really specific. The server
Here is my scenario: I have a windows form designed in Visual Studio 2010.
I expected Visual Studio to give me an error or at the very least
I have published a WinForms application from Visual Studio 2010. It uses .NET 4.0.
I have been using the embedded server that visual studio has to test my
I'm using Visual Studio to build my wix file. So far I have one
I am using visual studio 2010. It seems that out of nowhere, I can't
Visual Studio 2003 and 2005 (and perhaps 2008 for all I know) require the
Visual Studio Solution files contain two GUID's per project entry. I figure one of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.