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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T15:28:50+00:00 2026-05-20T15:28:50+00:00

I have an XML schema with my video element and youtube element inside: <xs:element

  • 0

I have an XML schema with my “video” element and “youtube” element inside:

<xs:element name="video">
  <xs:complexType>            
    <xs:sequence>     
      <xs:element ref="youtube" minOccurs="0" maxOccurs="1"/>
    </xs:sequence>    
    <xs:attribute name="file" type="xs:string"/>
  </xs:complexType>  
</xs:element>

and I want to add to available video types another element “param”:

<xs:element name="param">
   <xs:complexType>
     <xs:attribute name="name" type="xs:string" use="required"/>
     <xs:attribute name="value" type="xs:string" use="required"/>
   </xs:complexType>
</xs:element>    

I would have “param” element inside next to “youtube”.

Restrictions:

  • youtube can occur only one time in my xml
  • param – can occur many times in my xml

like this:

<video>
<youtube file = "aaa"/>
<param name="a1" value"b1"/>
<param name="a2" value"b2"/>
</video>

How to maintain this restrictions in this schema?

If I do something like this:

<xs:sequence>     
      <xs:element ref="youtube" minOccurs="0" maxOccurs="1"/>
      <xs:element ref="param" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>    

if the sequence is specified like this

<xs:sequence>     
      <xs:element ref="youtube" minOccurs="0" maxOccurs="1"/>
      <xs:element ref="param" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>    

it determines that param has to be after youtube – but I don’t want to specify the sequence

  • 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-20T15:28:51+00:00Added an answer on May 20, 2026 at 3:28 pm

    Here is XSD schema:

    <?xml version="1.0" encoding="UTF-8"?>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
        <xs:element name="video">
            <xs:complexType>
                <xs:choice minOccurs="1" maxOccurs="2">
                    <xs:element ref="youtube"/>
                    <xs:element ref="param" minOccurs="1" maxOccurs="unbounded"/>
                </xs:choice>
            </xs:complexType>
        </xs:element>
    
        <xs:element name="youtube">
            <xs:complexType>
                <xs:attribute name="file" type="xs:string" use="required"/>
            </xs:complexType>
        </xs:element>
    
        <xs:element name="param">
            <xs:complexType>
                <xs:attribute name="name" type="xs:string" use="required"/>
                <xs:attribute name="value" type="xs:string" use="required"/>
            </xs:complexType>
        </xs:element>
    </xs:schema>
    

    Example (well-formed and valid) XML:

    <?xml version="1.0" encoding="UTF-8"?>
    <video>
        <youtube file="aaa"/>
        <param name="a1" value="b1"/>
        <param name="a2" value="b2"/>
    </video>
    

    There is one issue with above solution. xs:choice allows two youtube elements. There is xs:all element, which solve that, but unfortunately it’s impossible to get param’s maxOccurs more than one with it (xs:all limitation).

    In other words there is no 100% solution using XML Schema 1.0. If above is not sufficient you can use another schema language such as RELAX NG or Schematron.

    edit:

    In XML Schema 1.1 (superset of XML Schema 1.0) you can write video element as:

    <xs:element name="video">
        <xs:complexType>
            <xs:all>
                <xs:element ref="youtube"/>
                <xs:element ref="param" minOccurs="0" maxOccurs="unbounded"/>
            </xs:all>
        </xs:complexType>
    </xs:element>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an XML schema: <xsd:element name=Person> <xsd:complexType> <xsd:sequence> <xsd:element name=name type=xsd:string /> <xsd:element
I have an XML schema that includes multiple addresses: <xs:element name=personal_address maxOccurs=1> <!-- address
I have group definitions in an XML schema. Like so: <attributeGroup name=my_attributes> <attribute ref=ns:foo
I have an XML Schema that looks like this: <xs:schema xmlns:xs=http://www.w3.org/2001/XMLSchema> <xs:element name=root> <xs:complexType>
I have an XML schema, where element Calling1 is defined like this: <xsd:element name=Calling1
I have seen XML Schema element with attributes containing only text but I have
I have an XML Schema Definition file .XSD who's elements are in Spanish. I
I have an XML file and an XML schema in another file and I'd
I have some XML and an XML Schema in a local xsd file. The
I have an XML schema file which references a urn based location. Is there

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.