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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T18:57:40+00:00 2026-06-04T18:57:40+00:00

What is the proper format to define a schema for an xml element which

  • 0

What is the proper format to define a schema for an xml element which contains Attribute,Sub-elements and Subelements also contains SUB-ELEMENTS
For eg: My xml

<element1 attribute1="hello">
 <element-sub1>
       <element-sub-sub1 attribute-sub-1="hi"/>
 <elementsubsub1>
</element1>

I tried with the following schema

         <xs:element name="element1">
         <xs:complexType>
         <xs:sequence>
         <xs:element name="element-sub1" type="xs:anyType" maxOccurs="unbounded"/>
          <xs:complexType> 
          <xs:sequence>
      <xs:element name="element-sub-sub1" type="xs:anyType" maxOccurs="unbounded"/>
      </xs:sequence>
    <xs:attribute name="attribute-sub-1" type="xs:string"/>
      </xs:complexType>

          </xs:sequence>
      <xs:attribute name="attribute1" type="xs:string"/>
      </xs:complexType>
       </xs:element>

But I am getting the following error

The content of 'sequence' must match (annotation?, (element | group | choice | sequence | any)*). A problem was found st
arting at: complexType.

Why am I getting this error? What is the right format to write schema for my requirement?
NOTE
Element “element-sub-sub1” may have text also.
UPDATE 1

<element1 URI="">
 <element-sub1>
 <element-sub-sub1 Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/>
 <element-sub-sub1 Algorithm="http://www.w3.org/TR/1999/REC-xslt-19991116">
 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
 <xsl:output method="text"/>
<xsl:template match="/">
Pan : <xsl:copy-of select="//Pp"/>

MobileNo : <xsl:copy-of select="//Mm"/>

TotalAmount : <xsl:copy-of select="//Total"/>
</xsl:template>
</xsl:stylesheet>
 element-sub-sub1
 </element-sub1>
 </element1>
  • 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-04T18:57:42+00:00Added an answer on June 4, 2026 at 6:57 pm

    Firs of all, you can’t have a type="xs:anyType" attribute and an <xs:complexType> element on the same <xs:element>

    Secondly, a definition of <xs:complexType> may only appear immediately inside an <xs:element> or as a global type as a child of <schema>

    Last, but not least. If you want an element to contain attributes, make its type complex.

        <xs:element name="element1">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="element-sub1" maxOccurs="unbounded">
                    <xs:complexType>
                        <xs:sequence>
                            <xs:element name="element-sub-sub1" maxOccurs="unbounded">
                                <xs:complexType mixed="true">
                                    <xs:any minOccurs="0" maxOccurs="1"/>
                                    <xs:attribute name="attribute-sub-1" type="xs:string" />
                                </xs:complexType>
                            </xs:element>
                        </xs:sequence>
                    </xs:complexType>
                </xs:element>
            </xs:sequence>
            <xs:attribute name="attribute1" type="xs:string" />
        </xs:complexType>
    </xs:element>
    

    As mentioned in the comments, the element allows you to insert any xml element on that position. The validation will pass, no matter if the element is actually valid according to some standard or not. It just has to be well-formed.

    If you want to validate the entire stylesheet, use an xs:import to gain access to the namespace, where xsl stylesheets are defined: http://www.w3.org/XML/2000/04schema-hacking/xslt.xsd and reference the stylesheet or transform element in your xsd.
    Inside <xs:element name="sub-sub1> :

                                <xs:complexType mixed="true">
                                    <xs:choice minOccurs="0" maxOccurs="1">
                                        <xs:element ref="xsl:stylesheet"/>
                                        <xs:element ref="xsl:transform"/>
                                    <xs:choice>
                                    <!-- You'll have to define a prefix for the xslt namespace imported -->
                                    <xs:attribute name="attribute-sub-1" type="xs:string" />
                                </xs:complexType>
    

    The choice element allows you to use one of two accepted top tags for an XSL stylesheet, <stylesheet> or <transform>

    UPDATE: added the minOccurs, maxOccurs attributes for optional stylesheets/transforms

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

Sidebar

Related Questions

How can I convert an Excel date (in a number format) to a proper
I'm unclear on the proper format for passing a QueryString Value using FlashVars, this
I get date in proper format from the database but i get time in
I'm a little confused on the proper format for the solr date fieldtype. When
I have an array of strings in which the % symbol is used. Proper
I'm parsing this date format from XML:=> 2011-12-06T07:41:14.016+00:00 , and I'm getting this error:
What is the proper date format for this date instance .. 10/10/2011 2:36:00 PM
EDIT : proper solution: void add(Student s) { if(root == null) root = new
Having trouble with proper regex for RewriteCond RewriteCond %{REQUEST_URI} !^/foo/ Works as expected, that
What is the proper (browser agnostic) way to disable page caching in ASP.NET MVC?

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.