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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T20:28:58+00:00 2026-05-11T20:28:58+00:00

I am trying to create an element in an XML schema such that only

  • 0

I am trying to create an element in an XML schema such that only standard (X)HTML elements can be used as children. What I’ve tried is this:

<xs:element name="description">
    <xs:complexType>
        <xs:sequence minOccurs="0" maxOccurs="unbounded">
            <xs:any namespace="http://www.w3.org/1999/xhtml" />
        </xs:sequence>
    </xs:complexType>
</xs:element>

Of course, this doesn’t work, as the following XML doesn’t explicitly specify the namespace:

<description>
    <p>this is a test</p>
    <p>this is a <b>bold</b> test</p>
    <h1>Those were the tests</h1>
</description>

Do I need to specify the namespace somewhere in the document, or can I get it in the schema?

  • 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-11T20:28:58+00:00Added an answer on May 11, 2026 at 8:28 pm

    Your schema looks ok. Note that the default value for xs:any/@processContents is strict, which means your XHTML elements will be also validated so you will need to have also an XHTML schema and import it from your schema. You can use processContents=”lax” inside xs:any to specify that the validation will be applied only if there is a schema for those elements.

    Your problem is in the instance where you should specify the namespace for the XHTML element. You can declare the XHTML namespace as default namespace on each element, for example

    <p xmlns="http://www.w3.org/1999/xhtml">this is a test</p>
    

    or you can declare it bound to a prefix, h for instance and then use that prefix to qualify your XHTML elements:

    <description xmlns:h="http://www.w3.org/1999/xhtml">
      <h:p>this is a test</h:p>
      <h:p>this is a <b>bold</b> test</h:p>
      <h:h1>Those were the tests</h:h1>
    </description>
    

    DTDs are not namespace aware and there namepsace declarations are just attributes, thus it is possible to declare a fixed xmlns attribute on an element to put it in a specific namespace automatically. XML Schemas are namespace aware and you cannot have a namespace declaration as a fixed attribute.

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

Sidebar

Ask A Question

Stats

  • Questions 142k
  • Answers 142k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I think you want (//div[@class="title"])[1]/a This: //div[@class="title"][1]/a selects all (<a>… May 12, 2026 at 8:16 am
  • Editorial Team
    Editorial Team added an answer Mozilla Active X Control has largely compatible interface. (IWebBrowser/IWebBrowser2/...) Of… May 12, 2026 at 8:16 am
  • Editorial Team
    Editorial Team added an answer Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) May 12, 2026 at 8:16 am

Related Questions

I have an XML feed (which I don't control) and I am trying to
I am trying to deserialize a Xml Fragment. I am nearly there but it
This is probably a naive question about XmlReader , but I haven't turned up
I am trying something very simple, but for some reason it does not work.

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.