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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T22:41:03+00:00 2026-05-13T22:41:03+00:00

I’ll admit, I’m an XML newbie. I’m having trouble validating some xml against a

  • 0

I’ll admit, I’m an XML newbie. I’m having trouble validating some xml against a schema. Here is the relevant part of my schema:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns="http://www.me.com/orpm/kpi/automation/report"
    targetNamespace="http://www.me.com/orpm/kpi/automation/report">
    <xs:attribute name="Pattern">
        <xs:simpleType>
            <xs:restriction base="xs:string">
                <xs:enumeration value="Exact"/>
                <xs:enumeration value="Replace"/>
                <xs:enumeration value="Regex"/>
            </xs:restriction>
        </xs:simpleType>
    </xs:attribute>
    <xs:complexType name="NameValue">
        <xs:all>
            <xs:element name="Value" type="xs:string"/>
        </xs:all>
        <xs:attribute ref="Pattern"/>
    </xs:complexType>
    <xs:element name="KpiReport">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="Name" type="NameValue"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
</xs:schema>

Here is the failed xml:

<?xml version="1.0"?>
<KpiReport xmlns="http://www.me.com/orpm/kpi/automation/report"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="http://www.me.com/orpm/kpi/automation/report filename.xsd">
    <Name Pattern="Exact">
        <Value>Test</Value>
    </Name>
</KpiReport>

It fails with this error:

Description: cvc-complex-type.2.4.a: Invalid content was found starting with element 'Name'. One of '{Name}' is expected.

I am lost on this. Please help.

  • 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-13T22:41:04+00:00Added an answer on May 13, 2026 at 10:41 pm

    There are a couple of things going on, and a couple of possible solutions to your issue.

    The solution that you can use will depend on whether you can change the XML, the XSD or both.

    Below is some XML that passes your schema validation:

    <?xml version="1.0"?> 
    <ns0:KpiReport xmlns:ns0="http://www.me.com/orpm/kpi/automation/report" 
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xsi:schemaLocation="http://www.me.com/orpm/kpi/automation/report filename.xsd"> 
        <Name ns0:Pattern="Exact"> 
            <Value>Test</Value> 
        </Name> 
    </ns0:KpiReport>
    

    The key difference is that in your xsd you have not defined the Name element within the http://www.me.com/orpm/kpi/automation/report namespace. I’m not entirely sure what is happening but think that having the Pattern attribute at the schema level has confused things. By assing the namespace prefix ns0: are telling the validator that KpiReport and Pattern are both in that namespace, but Name is not.

    This solution may not fit, so the other option is to tweak your schema to accept your example XML. Below is a schema that works:

    <?xml version="1.0" encoding="utf-16"?>
    <xs:schema xmlns:b="http://schemas.microsoft.com/BizTalk/2003" xmlns="http://www.me.com/orpm/kpi/automation/report" targetNamespace="http://www.me.com/orpm/kpi/automation/report" xmlns:xs="http://www.w3.org/2001/XMLSchema">
      <xs:complexType name="NameValue">
        <xs:all>
          <xs:element form="qualified" name="Value" type="xs:string" />
        </xs:all>
        <xs:attribute name="Pattern">
          <xs:simpleType>
            <xs:restriction base="xs:string">
              <xs:enumeration value="Exact" />
              <xs:enumeration value="Replace" />
              <xs:enumeration value="Regex" />
            </xs:restriction>
          </xs:simpleType>
        </xs:attribute>
      </xs:complexType>
      <xs:element name="KpiReport">
        <xs:complexType>
          <xs:sequence>
            <xs:element form="qualified" name="Name" type="NameValue" />
          </xs:sequence>
        </xs:complexType>
      </xs:element>
    </xs:schema>
    

    Things to note are that the Pattern attribute is now moved into the NameValue complexType, and that Name and Value are now specified as form=”qualified”. Qualified means that these elements require namespace prefixes (in this case, the prefix is the default, or none).

    I’m not 100% sure why this is required – my XSD knowledge is good enough to get to this point, but not know quite what is going on. I usually use tools to generate my schemas and then tweak until I’ve got things right.

    Hopefully this helps you, or that someone with sharper XSD chops can fill in the gaps.

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

Sidebar

Related Questions

No related questions found

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.