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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T11:23:17+00:00 2026-06-17T11:23:17+00:00

I have an xml schema that defines the basic fields for a car: <xs:simpleType

  • 0

I have an xml schema that defines the basic fields for a car:

<xs:simpleType name="FuelType">
    <xs:restriction base="xs:string">
        <xs:enumeration value="Regular Unleaded"/>
        <xs:enumeration value="High Octane"/>
        <xs:enumeration value="Leaded"/>
    </xs:restriction>
</xs:simpleType>
<xs:complexType name="CarType">
    <xs:sequence>
        <xs:element name="Make" type="xs:string"/>
        <xs:element name="Model" type="xs:string"/>
        <xs:element name="Cylinders" type="xs:int"/>
        <xs:element name="Fuel" type="FuelType"/>
    </xs:sequence>
</xs:complexType>

Now let’s say I want to define a Honda car type that extends from CarType but has it’s own definition for Fuel:

<xs:simpleType name="HondaFuelType">
    <xs:restriction base="xs:string">
        <xs:enumeration value="85"/>
        <xs:enumeration value="87"/>
        <xs:enumeration value="89"/>
        <xs:enumeration value="91"/>
        <xs:enumeration value="93"/>
        <xs:enumeration value="95"/>
    </xs:restriction>
</xs:simpleType>
<xs:complexType name="HondaCarType">
    <xs:complexContent>
        <xs:extension base="car:CarType">
            <xs:sequence>
                <xs:element name="Fuel" type="HondaFuelType"/>
            </xs:sequence>
        </xs:extension>
    </xs:complexContent>
</xs:complexType>

Extending CarType gets me everything I want however the schema now allows for two elements named Fuel (in different namespaces). Here is a sample Xml instance:

<HondaCar xmlns="HondaNS" xmlns:car="CarNS" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="HondaNS D:\Development\Temp\honda.xsd">
    <car:Make/>
    <car:Model/>
    <car:Cylinders>4</car:Cylinders>
    <car:Fuel>High Octane</car:Fuel>
    <Fuel>87</Fuel>
</HondaCar>

Although this is perfectly valid Xml it doesn’t make logical sense (to me at least). My intention was to extend the base type then override *Fuel* to only allow the values defined in HondaFuelType.

Is there a way I can override or mask the base Fuel element in my extended type?

  • 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-06-17T11:23:18+00:00Added an answer on June 17, 2026 at 11:23 am

    You can do things very similar to what you describe, but it is not possible in XSD to do precisely what you describe. The ‘base’ declaration of complex type CarType makes a number of commitments to the data consumer, which must be obeyed by all types derived from it, whether by restriction or extension. Among these are:

    • Instances of CarType will have children named Make, Model, Cylinders, and Fuel, with the types indicated.
    • The values of the Make and Model elements will be strings.
    • The value of the Cylinders element will be an xs:int.
    • The value of the Fuel element will be drawn from the set of strings {“Regular Unleaded”, “Leaded”, “High Octane”}.

    It’s the last of these commitments you are running intro trouble with.

    When you extend a type, you add new children at the end of its content model; for XSD 1.0 it will always be true that for any element valid against an extension, it’s possible to drop zero or more children from the end and produce an element which would be valid against the base type. That’s why your extension ends up with two Fuel elements.

    If you only want one Fuel element, then what you want to do is restrict, not extend, CarType. But the restriction you have in mind isn’t a legal restriction of the base type’s Fuel element. So restriction won’t work for you here, either.

    One possibility, of course, is to generalize CarType so that its Fuel element to accept xs:string, and then restrict it twice, once to produce something like the existing CarType, and once to produce the Honda variation you have in mind.

    I hope this helps.

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

Sidebar

Related Questions

I have an XML document and associated schema that defines several attributes as having
Lets say I have a schema that defines the following XML: <Values> <Add Key=Key1>Value
I have a gigantic QuickBooks SDK .XSD schema file which defines XML requests/responses that
I have a schema that defines the following type: <xsd:complexType name=Payload> <xsd:sequence> <xsd:any namespace=##any
I have an xml message that is in the older schema (xsd) format. My
I have an xml with an xml-schema. The xml-schema defines an abstract complex type
I have two XML examples that I want to write a schema for: Example
The basic problem I have here is that I have one xml file that
I have an XML document snippet that matches this XSD: <xs:complexType name=QuestionType> <xs:sequence> <xs:element
I have an XML schema, where element Calling1 is defined like this: <xsd:element name=Calling1

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.