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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T12:54:35+00:00 2026-06-02T12:54:35+00:00

I have the following XML file: <?xml version=1.0?> <!DOCTYPE library SYSTEM library.dtd> <library xmlns=http://example.com/a

  • 0

I have the following XML file:

<?xml version="1.0"?>
<!DOCTYPE library SYSTEM "library.dtd">
<library
xmlns="http://example.com/a"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://example.com library.xsd"
name=".NET Developer's Library">
<book>
<category>computerss</category>
<title>Programming Microsoft .NET</title>
<author>Jeff Prosise</author>
<isbn>0-7356-1376-1</isbn>
</book>
<book>
<category>computer</category>
<title>Microsoft .NET for Programmers</title>
<author>Fergal Grimes</author>
<isbn>1-930110-19-7</isbn>
</book>
</library>

And the following Java code:

DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
SchemaFactory sf = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");
docBuilderFactory.setSchema(sf.newSchema(new File("library.xsd")));
docBuilderFactory.setNamespaceAware(true);
DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
docBuilder.parse(new FileInputStream("data.xml"));

It produces the following error:

[Error] :7:33: cvc-elt.1: Cannot find the declaration of element 'library'.

If I remove the XSD declaration in the XML file everything works fine…

Any inside highly appreciated. Thanks.

And here is the schema:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:element name="library">
        <xs:complexType>
            <xs:sequence>
                <xs:element ref="book" maxOccurs="unbounded"/>
            </xs:sequence>
            <xs:attribute name="name" type="xs:string" use="optional"/>
        </xs:complexType>
    </xs:element>
    <xs:element name="book">
        <xs:complexType>
            <xs:sequence>
                <xs:element ref="category"/>
                <xs:element ref="title"/>
                <xs:element ref="author"/>
                <xs:element ref="isbn"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
    <xs:element  name="category">
    <xs:simpleType>
        <xs:restriction base="xs:string">
            <xs:enumeration value="computer" />
            <xs:enumeration value="poetry" />
        </xs:restriction>
    </xs:simpleType>
    </xs:element>
    <xs:element name="title" type="xs:string"/>
    <xs:element name="author" type="xs:string"/>
    <xs:element name="isbn" type="xs:string"/>
</xs: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-06-02T12:54:37+00:00Added an answer on June 2, 2026 at 12:54 pm

    Your XML has a reference to namespace (xmlns=”http://example.com/a”) which is not the same as in your schema. Have you tried to validate your XML against schema in any XML editor (e.g. Altova or Eclipse etc).

    So far it looks like your parsing error is legit, XML is not valid according to the schema.

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

Sidebar

Related Questions

I have the following XML layout file, HELPME.XML <?xml version=1.0 encoding=utf-8?> <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android android:layout_width=fill_parent
I have the following in an XML file: <entry> ... <link href=http://www.example.com/somelink /> ...
I have created the following vsct file xml. <?xml version=1.0 encoding=utf-8?> <CommandTable xmlns=http://schemas.microsoft.com/VisualStudio/2005-10-18/CommandTable xmlns:xs=http://www.w3.org/2001/XMLSchema>
I have the following xml snippet: <?xml version=1.0 encoding=UTF-8 ?> <!DOCTYPE sqlMap PUBLIC -//ibatis.apache.org//DTD
I have the following invalid XML file: <?xml version=1.0 encoding=utf-8 ?> <Page num=1 crop_box=0,
I have the following text in xml file: <Config Builder=LP Wizard> <Libraries> <Library Name=XCAMSource/>
I have following xml file: <?xml version = "1.0" ?> <Employee> <Emp_Id>E-001</Emp_Id> <Emp_Name>Vinod</Emp_Name> <Emp_E-mail>Vinod1@yahoo.com</Emp_E-mail>
Suppose I have the following XML file, and I want to use PowerShell (version
I made a jsf project and have the following example from http://docs.openlayers.org/library/introduction.html but as
I have following xml file: <ab> <![CDATA[ <table> <tbody> <tr> <th>abcdef</th> </tr> <tr> <p>

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.