[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

XSD Problem:  SaxParseException - cannot find declaration of element 'people'

Posted on 2005-05-16
3
Medium Priority
?
1,123 Views
Last Modified: 2013-11-19
I am trying to teach myself XML and XML Schema and am having trouble validating a simple xml file

Here it is...

<people>
     <person>
              <name>Bob</name>
              <address>123 Wilson ST</address>
              <phone>412-312-5555</phone>
     </person>
    <person>
               <name>Ted</name>
               <address>530 W. 5th St</address>
               <phone>111-133-2145</phone>
    </person>
</people>

---------------------------------------------------------------

I don't know what I'm doing wrong in my xsd file, but it doesn't seem to be able to see the root element?

Can anyone help me with the schema code for this?

Thanks
0
Comment
Question by:fbk2000
  • 2
3 Comments
 
LVL 19

Expert Comment

by:ramazanyich
ID: 14016849
what is your xsd schema file so far ? could you send it ?
0
 
LVL 60

Accepted Solution

by:
Geert Bormans earned 2000 total points
ID: 14040984
Hi,

I guess this is a possible schema you could use.I took the most straightforward approach,
in order for you to get started
I defined all elements globaly, so you can use any element as a root.
Have a look at the schema and contact us if you have further questions

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
      <xs:element name="people">
            <xs:complexType>
                  <xs:sequence>
                        <xs:element ref="person" maxOccurs="unbounded"/>
                  </xs:sequence>
            </xs:complexType>
      </xs:element>
      <xs:element name="person">
            <xs:complexType>
                  <xs:sequence>
                        <xs:element ref="name"/>
                        <xs:element ref="address"/>
                        <xs:element ref="phone"/>
                  </xs:sequence>
            </xs:complexType>
      </xs:element>
      <xs:element name="address"/>
      <xs:element name="name"/>
      <xs:element name="phone"/>
</xs:schema>

If you store your schema as people.xsd
here is how you call the schema from within the instance

<people xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="people.xsd">
      <person>
            <name>Bob</name>
            <address>123 Wilson ST</address>
            <phone>412-312-5555</phone>
      </person>
      <person>
            <name>Ted</name>
            <address>530 W. 5th St</address>
            <phone>111-133-2145</phone>
      </person>
</people>

And that validates well.
Is this what you were looking for?
cheers,

Gertone
0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 14147836
please note that I defined all elements globally
(I made reference to them rather than defining them inside their parents definition)
This is what you need to be able to "see" them as a possible root
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
Suggested Courses

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question