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 4239828
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T03:05:10+00:00 2026-05-21T03:05:10+00:00

Lets say I have a schema that defines the following XML: <Values> <Add Key=Key1>Value

  • 0

Lets say I have a schema that defines the following XML:

<Values>
    <Add Key="Key1">Value 1</Add>
    <Add Key="Key2">Value 2</Add>
    <Add Key="Key3">Value 3</Add>
    <Add Key="Key4">Value 4</Add>
</Values>

I would like, at a schema level, to be able to enforce that the values for the Key attribute are unique, i.e. the example above is valid, but the following example would be invalid:

<Values>
    <Add Key="Key1">Value 1</Add>
    <Add Key="Key2">Value 2</Add>
    <Add Key="Key2">Value 3</Add>
    <Add Key="Key3">Value 4</Add>
</Values>

Notice that there are two Add elements with a Key of Key2

For reference here is the simple schema:

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
    <xs:element name="Values">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="Add" maxOccurs="unbounded">
                    <xs:complexType>
                        <xs:simpleContent>
                            <xs:extension base="xs:string">
                                <xs:attribute name="Key" type="xs:token" use="required"/>
                            </xs:extension>
                        </xs:simpleContent>
                    </xs:complexType>
                </xs:element>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
</xs:schema>

I am under the impression that this is not possible at a schema level, however I am all ears.

  • 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-21T03:05:11+00:00Added an answer on May 21, 2026 at 3:05 am

    @BatteryBackupUnit has the right idea, but the syntax is more like:

    <xs:element name="Values">
      <xs:complexType>
        <xs:sequence>
          <xs:element ref="Add" maxOccurs="unbounded"/>
        </xs:sequence>
      </xs:complexType>
      <xs:unique name="UniqueAddKey">
        <xs:selector xpath="Add" /> 
        <xs:field xpath="@Key" /> 
      </xs:unique>
    </xs:element>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Lets Say i have a table like this WEB_LIST_TABLE KEY Value ---------------------------------------- 134 google.com
Lets say I have the following xml. <root> <data> <a>ATTITUDE_ANNOYED</a> <b>ATTITUDE_CAUTIOUS</b> <c>25</c> <d>30</d> </data>
Lets say we have a table here, populated with the following data: acc_id1 acc_id2
Lets say I have a class A that is fairly simple like this -
Let's say I have following Spring config (version of Spring is 3.0.3): <?xml version=1.0
Let's say I have the following two pieces of XML in my database <!--
Let's say we have the following schema: root/ application/ -public/ index.php css/ img/ javascript/
Lets say I have a component using a set schema, and this component is
I have a mongoose setup which involves an embedded-schema, lets say: A Blogpost with
Lets say that i have to make 5 tables which need a number as

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.