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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T21:29:21+00:00 2026-05-18T21:29:21+00:00

Suppose I have a XML schema and want to support some extensions at several

  • 0

Suppose I have a XML schema and want to support some extensions at several nodes. An extension should be valid XML within these nodes.

I know this might be implemented with the <any> element in you schema. However In my XML that uses my schema I want this extension to only use nodes from an other XSD. So specifying the Schema of the extension at runtime and then being able to validate this extension against the extension schema.

The following example uses a static extension schema:


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

Now I want to specify this schema in my XML, for example (I’am a newbie), like this:


<foo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  xsi:noNamespaceSchemaLocation="myschema.xsd">
  <bar>
    <extension>
       <html namespace="http://www.w3.org/1999/xhtml">
         <body>Hello, World!</body>
       </html>
    </extension>
  </bar>
</foo>

What is the best approach for this? Ideally I want to have a list in my XML of the schema’s I use in the extension nodes of my XML.

Thanks!

== Edited, more detailed explanation: ==

I want to support user defined XML data within specific nodes. I don’t know the schema of these extension during the writing of my “master” schema.

I have specified the following fragment in my XSD:


<xs:element name="extension">
    <xs:complexType>
        <xs:sequence>
            <xs:any namespace="##other" processContents="strict"/>
        </xs:sequence>
    </xs:complexType>
</xs:element>

And want to use the following XML:


<foo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="test.xsd" >
    <bar>
        <extension>
            <html xmlns="http://www.w3.org/1999/xhtml">
                <body2>Hello, world!</body2>
            </html>
        </extension>
    </bar>
</foo>

Now I do want an parser error because <body2 is not an valid XHTML element. However the XMLSpy parser is already complaining about the <html> element that is not valid.

  • 1 1 Answer
  • 3 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-18T21:29:21+00:00Added an answer on May 18, 2026 at 9:29 pm

    Use “strict” processing to mandate that the contents of the any element is validated against its schema, i.e.

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

    Validation of your document should then fail, since the processor is likely unable to obtain a schema for XHTML. You would need to specify this in the instance document also, like so:

    <foo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
         xsi:noNamespaceSchemaLocation="test.xsd">
     <extension>
      <html xmlns="http://www.w3.org/1999/xhtml" 
        xsi:schemaLocation="http://www.w3.org/1999/xhtml 
                            http://www.w3.org/2002/08/xhtml/xhtml1-strict.xsd">
       <body2>Hello, world!</body2>
      </html>
     </extension>
    </foo>
    

    Now, many XSD validator will still choke on this, since they don’t consider the schemaLocation attribute on the html element (although they ought to, per spec).
    Moving the schemaLocation attribute into the root element might (or might not)
    improve things: if the validator complains about the html element, it’s broken.

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

Sidebar

Related Questions

Suppose I have the following XML, how should I update my XSD schema (described
Let's suppose I have xml like this one: <Server Active=No> <Url>http://some.url</Url> </Server> C# class
Suppose we have some .xml files containing, amongst other things, MIDI note data. Since
Suppose I have this (outrageously) simplified XML schema: <xsd:complexType name=Person> <xsd:sequence> <xsd:element ref=FirstName/> <xsd:element
Suppose that... I have a complex XML schema, one that imports/includes other schema files,
Suppose I have two XML files. First XML File: <?xml version=1.0?> <AccessRequest xml:lang=en-US> <AccessLicenseNumber>Your_License</AccessLicenseNumber>
Suppose I have this XML as a string: <calles> <calle> <nombre>CALLAO AV.</nombre> <altura>1500</altura> <longitud>-58.3918617027</longitud>
Suppose you have 2 different ASP.NET applications in IIS. Also, you have some ASCX
Suppose I have the following XML (which is the embedding of TEI annotation scheme
Suppose I have such elements in my XML document: <xs:appinfo> <CustomXML> <Something>something</Something> </CustomXML> </xs:appinfo>

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.