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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T03:07:59+00:00 2026-05-22T03:07:59+00:00

Say I don’t know what an element’s name will be, but I do know

  • 0

Say I don’t know what an element’s name will be, but I do know what it’s children will be. For example, the names “foo” and “bar” are not prescribed but “A”, “B” & “C” are.

<example>
    <foo>
        <A>A</A>
        <B>B</B>
        <C>C</C>
    </foo>
    <bar>
        <A>A</A>
        <B>B</B>
        <C>C</C>
    </bar>
</example>

I cannot leave the name attribute out because that’s a violation. I would expect to be able to do this instead:

<xs:element name="example">
    <xs:complexType>
        <xs:sequence maxOccurs="unbounded">
            <xs:any>
                <xs:complexType>
                    <xs:sequence>
                        <xs:element name="A" type="xs:string"/>
                        <xs:element name="B" type="xs:string"/>
                        <xs:element name="C" type="xs:string"/>
                    </xs:sequence>
                </xs:complexType>
            </xs:any>
        </xs:sequence>
    </xs:complexType>
</xs:element>

This does not work either, <xs:any> can only contain annotations and refuses a type.

Is there something I can do with namespaces that will work with unknown element names? Should I give up, not attempt to validate the children and just document what the contents must be?

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

    You cannot quite achieve what you want to do there in XML Schema. There is a close solution, but not quite what you want:

    <xs:element name="example">
        <xs:complexType>
            <xs:sequence maxOccurs="unbounded">
                <xs:any namespace="##other" processContents="lax"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
    

    Now you could provide separate schemas for the elements that can occur in there, e.g. one for foo, under a separate namespace and in a separate schema file:

    <xs:element name="foo">
        <xs:complexType>
            ....
        </xs:complexType>
    </xs:element>
    

    That’s about all you can do (it’s your “multiple namespaces” solution). You can’t avoid listing the elements entirely. If that’s not good enough, then <xsd:any> with processContents set to skip is your only solution, followed by external validation (code, Schematron, etc)

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

Sidebar

Related Questions

Say you have a string, but you don't know what it contains. And you
We know some escape sequence '\n' - new line but say we don't know
I can say I don't know what I'm asking for help,because I don't know
I don't know if this has been discussed. Let's say you are in a
first off I'm going to say I don't know a whole lot about theory
First, let's say I don't want to use duplex channel and this is not
In java they say don't concatenate Strings, instead you should make a stringbuffer and
Say I don't have mod_deflate compiled into apache, and I don't feel like recompiling
Let's say you don't want other sites to frame your site in an <iframe>
MVC/OOP design patterns say you don't set a property, per se, you ask an

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.