Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XML
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
XML General XML discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XML section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 14th, 2006, 05:13 PM
Authorized User
 
Join Date: Feb 2006
Location: , , .
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default XML schema validation problems

Why am I getting the following error ?

Results from W3C XML Schema validation:
Validation error:
Reason: The element 'Books' is used but not declared in the DTD/Schema.
Error code: -1072898035

--------------------------------------------------------------------
My XML doc

<?xml version ='1.0' ?>
<!DOCTYPE Books SYSTEM "BooksDTD.dtd">
<Books
    xmlns="http://madeupbookshop.com/books"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://madeupbookshop.com/books books.xsd">
    <Book>
        <ISBN>12345</ISBN>
        <PUBLISHER>Wrok</PUBLISHER>
        <AUTHOR>
        <FIRST_NAME>William</FIRST_NAME>
        <LAST_NAME>Blake</LAST_NAME>
        </AUTHOR>
        <TITLE>Walk in the wood</TITLE>
        <EDITION>First edition</EDITION>
        <PRICE>$99.95</PRICE>
        <PAGES>500</PAGES>
        <DATE_PUBLISHED>12 January 2004</DATE_PUBLISHED>
        <DESCRIPTION>I love trees</DESCRIPTION>
        <IMAGE>one.gif</IMAGE>
    </Book>
    <Book>
        <ISBN>12346</ISBN>
        <PUBLISHER>Wrok</PUBLISHER>
        <AUTHOR>
        <FIRST_NAME>Erric</FIRST_NAME>
        <LAST_NAME>Bird</LAST_NAME>
        </AUTHOR>
        <TITLE>eating to be large</TITLE>
        <EDITION>First edition</EDITION>
        <PRICE>$45.95</PRICE>
        <PAGES>600</PAGES>
        <DATE_PUBLISHED>16 January 2004</DATE_PUBLISHED>
        <DESCRIPTION>Be big and fat</DESCRIPTION>
        <IMAGE>two.jpg</IMAGE>
    </Book>
<Books>

--------------------------------------------------------------------------
I have the following schema

<?xml version="1.0"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
 xmlns:target="http://madeupbookshop.com/books"
 targetNamespace="http://madeupbookshop.com/books"
 elementFormDefault="qualified">
 <element name="Books" type="target:booksType" />
 <complexType name="AuthorType">
    <sequence>
      <element name="FIRST_NAME" type="string"/>
      <element name="LAST_NAME" type="string"/>
    </sequence>
 </complexType>
 <complexType name="bookType">
    <sequence>
       <element name="ISBN" type="string"/>
       <element name="PUBLISHER" type="string"/>
       <element name="AUTHOR" type="target:AuthorType"/>
       <element name="TITLE" type="string"/>
       <element name="EDITION" type="string"/>
       <element name="PRICE" type="string"/>
       <element name="PAGES" type="positiveInteger"/>
       <element name="DATE_PUBLISHED" type="string"/>
       <element name="DESCRIPTION" type="string"/>
       <element name="IMAGE" type="string"/>
    </sequence>
 </complexType>
 <complexType name="booksType">
     <sequence>
    <element name="Book" type="target:bookType" minOccurs="0" maxOccurs="unbounded" />
     </sequence>
 </complexType>
</schema>
Reply With Quote
  #2 (permalink)  
Old February 14th, 2006, 05:42 PM
mhkay's Avatar
Wrox Author
Points: 18,487, Level: 59
Points: 18,487, Level: 59 Points: 18,487, Level: 59 Points: 18,487, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Try removing the DOCTYPE, to see if that's causing the trouble; and correct <books> on line 36 to </books>. With that change the document is valid, so if you're still getting a problem then its in the way you are invoking the schema processor.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
Reply With Quote
  #3 (permalink)  
Old February 15th, 2006, 09:57 AM
Authorized User
 
Join Date: Feb 2006
Location: , , .
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default

On line 36 the line is </books>, <books> was a type for the forum.

You are correct DOCTYPE line is causing the problem. But my assignment I have to incuded both a schema and DTD validation. Is there away to include this line without the schema generating a error ?

Thanks for your help

Brendon

Reply With Quote
  #4 (permalink)  
Old February 15th, 2006, 06:02 PM
mhkay's Avatar
Wrox Author
Points: 18,487, Level: 59
Points: 18,487, Level: 59 Points: 18,487, Level: 59 Points: 18,487, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Provided the document is valid both against the DTD and against the schema, it shouldn't be a problem. But invoking a parser to perform both validations becomes rather product-dependent, and I suspect the problem is related to the way you are running your chosen product.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Bewildering schema error in validation. overcast XSLT 5 August 26th, 2008 01:16 PM
Schema Validation markus2000 XSLT 1 June 22nd, 2006 08:23 AM
XML validation with Schema/DTD using JAXP Hendrik XML 0 December 28th, 2004 06:58 AM
XML Schema Validation without internet esp5a XML 1 September 5th, 2003 06:22 AM
XML, XML Schema, JavaScript, ASP cyberjames2003 XML 0 June 4th, 2003 04:49 AM



All times are GMT -4. The time now is 07:38 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.