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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:52:55+00:00 2026-05-26T23:52:55+00:00

I am creating an XML schema in which I would like to restrict node

  • 0

I am creating an XML schema in which I would like to restrict node values by the types or values of their parent nodes. The thing is, I don’t know the restrictions at the time of schema authoring, because the schema must be valid for more than one such application. So I would like to keep the value types in an external document (that will probably be created automatically before the document is edited).

My main purpose is to make editing the XML files easy with XML-savvy tools (preferably Eclipse), with auto-completion of allowed values.

Here’s a fictional example. Let’s say I want to create a group of characters from the same comic / cartoon.

<team ref="marvel-heros">
    <member ref="spiderman" />
    <member ref="hulk" />
    <member ref="batman" /><!-- illegal, not in marvel-heros -->
</team>
<team ref="pacman-ghosts">
    <member ref="blinky" />
    <member ref="inky" />
    <member ref="pinky" />
    <member ref="clyde" />
    <member ref="qbert" /><!-- illegal, not in pacman-ghosts -->
</team>

Other possible markups would be

<marvel-heroes>
    <spiderman />
    <hulk />
</marvel-heroes>
<pacman-ghosts>
    <inky />
    <pinky />
</pacman-ghosts>

Of course the markup can be changed, and namespaces could be used as well (although I’d rather not use one namespace per cartoon / comic as there are many).

Note that the marvel team and the pacman ghosts can appear multiple times in the same document.

Is there a sensible way I can do this? Do I have to create an external schema for the values? Or is there a way to solve this using entities or xml includes?

  • 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-26T23:52:55+00:00Added an answer on May 26, 2026 at 11:52 pm

    If you use XML Schema, you better use the second kind of markup (<marvel-team>...). Only RelaxNG allows such validation mechanism given specific attribute values.
    For your concern about external documents, maybe be you can consider the include mechanism in XML Schema :

    <?xml version="1.0" encoding="UTF-8"?>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
        <xs:include schemaLocation="type.xsd"/>
        <xs:element name="marvel-team" type="marvel-teamType"/>
        <xs:element name="pacman-ghosts" type="pacman-ghostsType"/>
    </xs:schema>
    

    And for the type.xsd :

    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
        <xs:complexType name="marvel-teamType">
            <xs:sequence>
                <xs:element name="spiderman" />
                <xs:element name="hulk" />
            </xs:sequence>
        </xs:complexType>
        <xs:complexType name="pacman-ghostsType">
            <xs:sequence>
                <xs:element name="inky" />
                <xs:element name="pinky" />
            </xs:sequence>
        </xs:complexType>
    </xs:schema>
    

    Only type.xsd has to change when you add or remove elements.

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

Sidebar

Related Questions

I've inherited the task of creating a schema for some XML which already exists
I am creating an xml schema, and I want to make sure that the
I am in the process of creating an XML Schema and one of my
I am creating an XML file in C# using a XSD Schema of an
I am creating some xsl to transform my xml into text (which will be
I am creating an application which requires to convert c# object to XML. I
I'm creating a xml-file for display in Excel using _di_IXMLDocument. But for some tags
I'm creating an XML document and I want to store URLs inside the a
I am creating serialized XML for a LINQ to SQL project using the DataContractSerializer
I'm creating an XML file using Perl and XML::Simple module. I successfully create the

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.