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

  • Home
  • SEARCH
  • 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 4251786
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T04:42:28+00:00 2026-05-21T04:42:28+00:00

I have the following XML: <?xml version=1.0?> <coll xmlns=http://www.example.org/coll xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance xsi:schemaLocation=http://www.example.org/coll coll.xsd> <collection> <item

  • 0

I have the following XML:

<?xml version="1.0"?>

<coll xmlns="http://www.example.org/coll" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.example.org/coll coll.xsd">

    <collection>
        <item action="remove">1</item>
        <item action="add">2</item>
        <item action="add">3</item>
    </collection>

    <collection>
        <item action="add">2</item>
        <item action="remove">1</item>
        <item action="add">3</item>
    </collection>

</coll>   

And an XSD:

<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.org/coll"
    xmlns:tns="http://www.example.org/coll" elementFormDefault="qualified">

    <element name="coll" type="tns:coll">
    </element>

    <complexType name="coll">
        <sequence>
            <element name="collection" type="tns:collection" minOccurs="0" maxOccurs="unbounded"></element>
        </sequence>
    </complexType>

    <complexType name="collection">
        <sequence>
            <element name="item" type="tns:item" minOccurs="0" maxOccurs="unbounded"></element>
        </sequence>
    </complexType>

    <complexType name="item">
        <simpleContent>
            <extension base="string">
                <attribute name="action">
                    <simpleType>
                        <restriction base="string">
                            <enumeration value="add"></enumeration>
                            <enumeration value="remove"></enumeration>
                        </restriction>
                    </simpleType>
                </attribute>
            </extension>
        </simpleContent>
    </complexType>

</schema>

I would like to restrict the order of the item elements such that the removes always comes before the adds.
I.e. the first collection is valid but the second one is invalid.

I’ve tried with two item elements, one with an add_item type and one with remove_item. But this fails to validate the XSD with the error that I can not have two elements of the same name with different types.

Any ideas? Or is it even possible?

  • 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-21T04:42:29+00:00Added an answer on May 21, 2026 at 4:42 am

    The only way this is possible (with XSD) would be by refactoring your schema to use the action as the element name instead of an attribute:

    <collection>
        <remove>1</remove>
        <add>2</add>
        <add>3</add>
    </collection>
    

    That way, you can use a sequence in your schema to determine the order.

    On a more general note: Your schema design looks a bit mixed up. Your element names seem to describe a state (collection, item), yet your attributes on item seem to carry the actual information about an action your code is (presumably) to take. If you have a choice about the design, you might want to think about a slight redesign.

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

Sidebar

Related Questions

I have following XML schema: <?xml version=1.0 encoding=UTF-8 standalone=no?> <xs:schema xmlns:xs=http://www.w3.org/2001/XMLSchema> <xs:element name=content type=contentType/>
i have following xml file as input .... <?xml version=1.0 encoding=ISO-8859-1?> <T0020 xsi:schemaLocation=http://www.safersys.org/namespaces/T0020V1 T0020V1.xsd
I have the following XML structure: <?xml version=1.0 ?> <course xml:lang=nl> <body> <item id=787900813228567
I have the following xml I'd like to deserialize into a class <?xml version=1.0
Say I have the following web.config: <?xml version=1.0 encoding=utf-8?> <configuration> <system.web> <authentication mode=Windows></authentication> </system.web>
Suppose I have the following XML file, and I want to use PowerShell (version
I have the following XML <?xml version=1.0 encoding=ISO-8859-1 ?> - <DEVICEMESSAGES> <VERSION xml=1 checksum=
Let's say I have following Spring config (version of Spring is 3.0.3): <?xml version=1.0
I have the following XML document: <projects> <project> <name>Shockwave</name> <language>Ruby</language> <owner>Brian May</owner> <state>New</state> <startDate>31/10/2008
I have the following xml that's sent to me from a web service. I'm

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.