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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T02:52:45+00:00 2026-06-07T02:52:45+00:00

Here is XML Schema: <?xml version=1.0 encoding=utf-8?> <xs:schema xmlns:xs=http://www.w3.org/2001/XMLSchema> <xs:element name=products> <xs:complexType> <xs:sequence minOccurs=0

  • 0

Here is XML Schema:

<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

  <xs:element name="products">
    <xs:complexType>
      <xs:sequence minOccurs="0" maxOccurs="unbounded">
        <xs:element name="product" type="ProductType"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>

  <xs:complexType name="ProductType">
    <xs:sequence>
      <xs:element name="id" type="xs:long" />
      <xs:element name="name" type="xs:string" />
      <xs:element name="price" type="xs:decimal" />
    </xs:sequence>
  </xs:complexType>

</xs:schema>

XML file that is validated for conformance:

<?xml version="1.0" ?>
<products>
  <product>
    <invalid_tag>32342</invalid_tag>
    <name>Some name</name>
    <price>3.89</price>
  </product>
</products>

Java code that works with XML and should test conformance:

SAXParserFactory factory = SAXParserFactory.newInstance();
factory.setValidating(false);
SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
factory.setSchema(schemaFactory.newSchema(new File(xmlSchema)));
parser = factory.newSAXParser();
ProductsSaxHandler handler = new ProductsSaxHandler();
parser.parse(new File(xmlFile), handler);

But I don’t get any exception. What is wrong?

  • 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-07T02:52:47+00:00Added an answer on June 7, 2026 at 2:52 am

    I see that you are using custom ProductsSaxHandler.

    You did not provide code for it, but most likely it does not throw an exception when one of the notification methods of ErrorHandler interface is called.

    Make sure you override error, fatalError and warning methods of ProductSaxHandler to throw an exception.

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

Sidebar

Related Questions

Here is my pages.xsd <?xml version=1.0 encoding=UTF-8 ?> <xs:schema xmlns:xs=http://www.w3.org/2001/XMLSchema xmlns:mac=http://www.tvworks.com/tva/xml/ns/max/data-types elementFormDefault=qualified attributeFormDefault=unqualified> <xs:import
I have following XML schema: <?xml version=1.0 encoding=UTF-8 standalone=no?> <xs:schema xmlns:xs=http://www.w3.org/2001/XMLSchema> <xs:element name=content type=contentType/>
Here is my bean.xml <?xml version=1.0 encoding=UTF-8?> <beans xmlns=http://www.springframework.org/schema/beans xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance xmlns:context=http://www.springframework.org/schema/context xmlns:p=http://www.springframework.org/schema/p xmlns:tx=http://www.springframework.org/schema/tx xsi:schemaLocation=
I'm using an .xsd schema like this <?xml version=1.0 encoding=utf-8?> <xs:schema id=NewDataSet xmlns= xmlns:xs=http://www.w3.org/2001/XMLSchema
Here's the XML: <?xml version='1.0' encoding='UTF-8' standalone='yes' ?> <feed xmlns=http://www.w3.org/2005/Atom xmlns:dc=http://purl.org/dc/elements/1.1/> <title>Rated Images</title> <link
Cutting to the case. Persistence.xml <?xml version=1.0 encoding=UTF-8?> <persistence xmlns=http://java.sun.com/xml/ns/persistence xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance xsi:schemaLocation=http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd version=2.0>
I have the generic structure here: <?xml version=1.0 encoding=UTF-8?> <SOAP-ENV:Envelope xmlns:xsi= http://www.w3.org/2001/XMLSchema-instance xmlns:SOAP-ENC=http://schemas.xmlsoap.org/soap/encoding/ xmlns:SOAP-ENV=http://schemas.xmlsoap.org/soap/envelope/
My xml code is here, <?xml version=1.0 encoding=utf-8?><RelativeLayout xmlns:android=http://schemas.android.com/apk/res/android android:layout_width=fill_parent android:layout_height=fill_parent android:id=@+id/mainlayout > <LinearLayout
Here is my layout <?xml version=1.0 encoding=utf-8?> <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android android:layout_width=fill_parent android:id=@+id/LinearLayout01 android:layout_height=wrap_content> <Spinner android:text=@+id/AutoCompleteTextView01
Here's my layout code; <?xml version=1.0 encoding=utf-8?> <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android android:orientation=vertical android:layout_width=fill_parent android:layout_height=fill_parent> <TextView android:text=@string/welcome

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.