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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:04:34+00:00 2026-05-26T07:04:34+00:00

I am trying to read an XSD file using Nokogiri Ruby parser and it

  • 0

I am trying to read an XSD file using Nokogiri Ruby parser and it throws following error
Nokogiri::XML::SyntaxError (Element ‘{http://www.w3.org/2001/XMLSchema}element’: The content is not valid. Expected is (annotation?, ((simpleType | complexType)?, (unique | key | keyref)*)).):

Does any one know what is wrong with the xsd?

<?xml version="1.0" encoding="utf-8"?>
<xsd:schema elementFormDefault="qualified" version="1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <xsd:element name="company_donation_request" type="company_donation_requestType" />
  <xsd:complexType name="company_donation_requestType">
    <xsd:sequence>
      <xsd:element name="order" type="orderType"></xsd:element> 
      <xsd:element name="donation" type="donationType"></xsd:element>
    </xsd:sequence>
  </xsd:complexType>
  <xsd:complexType name="donationType">
    <xsd:sequence>
      <xsd:element name="campaign_key" type="xsd:string" minOccurs="1" maxOccurs="1" >
        <xsd:restriction base="xsd:string">
            <xsd:minLength value="2"/>
            <xsd:maxLength value="255"/>
        </xsd:restriction>
      </xsd:element>
      <xsd:element name="amount" type="xsd:decimal" minOccurs="1" maxOccurs="1" ></xsd:element>
    </xsd:sequence>
  </xsd:complexType>
  <xsd:complexType name="orderType">
    <xsd:sequence>
      <xsd:element name="id" type="xsd:string" minOccurs="1" maxOccurs="1" >
        <xsd:restriction base="xsd:string">
            <xsd:minLength value="2"/>
            <xsd:maxLength value="255"/>
        </xsd:restriction>
      </xsd:element>
      <xsd:element name="fulfillment_date" type="xsd:dateTime" minOccurs="1" maxOccurs="1" >
        <xsd:restriction base="xsd:string">
            <xsd:minLength value="2"/>
            <xsd:maxLength value="255"/>
        </xsd:restriction>
      </xsd:element>
    </xsd:sequence>
  </xsd:complexType>
</xsd: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-26T07:04:35+00:00Added an answer on May 26, 2026 at 7:04 am

    You’re getting the error because xsd:restriction is not allowed as a child of xsd:element. Try adding your xsd:restriction to an xsd:simpleType and then specifying that type in your xsd:element.

    You could add the xsd:simpleType directly to the xsd:element, but since you’re using the same restriction 3 times, it makes more sense to put it in a simpleType outside of the elements.

    Here’s an example. I named the simpleType “stackOverflowTest”:

    <xsd:schema elementFormDefault="qualified" version="1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
      <xsd:element name="company_donation_request" type="company_donation_requestType" />
      <xsd:complexType name="company_donation_requestType">
        <xsd:sequence>
          <xsd:element name="order" type="orderType"></xsd:element> 
          <xsd:element name="donation" type="donationType"></xsd:element>
        </xsd:sequence>
      </xsd:complexType>
      <xsd:complexType name="donationType">
        <xsd:sequence>
          <xsd:element name="campaign_key" type="stackOverflowTest" minOccurs="1" maxOccurs="1"/>
          <xsd:element name="amount" type="xsd:decimal" minOccurs="1" maxOccurs="1"/>
        </xsd:sequence>
      </xsd:complexType>
      <xsd:complexType name="orderType">
        <xsd:sequence>
          <xsd:element name="id" type="stackOverflowTest" minOccurs="1" maxOccurs="1"/>      
          <xsd:element name="fulfillment_date" type="stackOverflowTest" minOccurs="1" maxOccurs="1"/>      
        </xsd:sequence>
      </xsd:complexType>
      <xsd:simpleType name="stackOverflowTest">
        <xsd:restriction base="xsd:string">
          <xsd:minLength value="2"/>
          <xsd:maxLength value="255"/>
        </xsd:restriction>  
      </xsd:simpleType>
    </xsd:schema>
    

    Hope this helps.

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

Sidebar

Related Questions

I am tring to load an xsd file using XmlSchema.Read. It runs without error,
I m trying read XML data using XML parser from Url( https://....etc ). But
I'm currently trying to read in an XML file, make some minor changes (alter
I am trying to read an Http response stream twice via the following: HttpWebResponse
I am trying to read enum from a XSD file. The schema is as
I've uploaded a ZIP file containing both the XML file I'm trying to read
I'm trying to read XML file, ex : <entry> <title>FEED TITLE</title> <id>5467sdad98787ad3149878sasda</id> <tempi type="application/xml">
I'm trying to validate an XML file with XSD, but I get a Could
I am trying read rss feed of stack overflow using Linq to xml. I
When trying to read a RSA private key from a file using the method

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.