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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T06:55:33+00:00 2026-06-11T06:55:33+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=id type=xs:long /> </xs:schema>

  • 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="id" type="xs:long" />
</xs:schema>

XML file that is validated for conformance:

<?xml version="1.0" ?>
<id>invalid_data</id>

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();
MySaxHandler handler = new MySaxHandler();
parser.parse(new File(xmlFile), handler);

During invocation of this code NumberFormatException is throwed in characters method of MySaxHandler. MySaxHandler also contains overriden methods warning, error and fatalError but they aren’t executed.

I don’t want this NumberFormatException being thrown. I want datatype being validated according to Schema. How do I do it?

  • 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-11T06:55:35+00:00Added an answer on June 11, 2026 at 6:55 am

    I wonder if it’s simply a timing issue. The schema validator can’t test the content of the element until the end element event is reached, but the text node is reported to the ContentHandler before the end element event is reached. Try masking the exception in your application to see if the validation error gets reported a bit later.

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

Sidebar

Related Questions

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
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

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.