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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T19:50:24+00:00 2026-06-16T19:50:24+00:00

i have an XSD like this <xs:schema attributeFormDefault=unqualified elementFormDefault=qualified targetNamespace=www.aaa.com/aa xmlns:xs=http://www.w3.org/2001/XMLSchema> <xs:include schemaLocation=class.xsd/> <xs:element

  • 0

i have an XSD like this

<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="www.aaa.com/aa" xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:include schemaLocation="class.xsd"/>
    <xs:element name="record">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="Stud" minOccurs="0">
                    <xs:complexType>
                        <xs:sequence>
                            <xs:element name="fname" type="xs:string"/>
                            <xs:element name="lname" type="xs:string"/> 
                            ........                                
                        </xs:sequence>
                    </xs:complexType>
                </xs:element>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
</xs:schema>

When i parse this XSD using XSOM it gives Null Pointer Exception. When i remove the <xs:include schemaLocation="class.xsd"/> element it works fine

 XSOMParser parser = new XSOMParser();
       parser.parse(inputStream);// -> this statement gives null pointer.

Stack trace

Exception in thread "main" java.lang.NullPointerException
    at com.sun.xml.xsom.impl.parser.NGCCRuntimeEx.parseEntity(NGCCRuntimeEx.java:327)
    at com.sun.xml.xsom.impl.parser.NGCCRuntimeEx.includeSchema(NGCCRuntimeEx.java:234)
    at com.sun.xml.xsom.impl.parser.state.includeDecl.action0(includeDecl.java:42)
    at com.sun.xml.xsom.impl.parser.state.includeDecl.leaveElement(includeDecl.java:109)
    at com.sun.xml.xsom.impl.parser.state.NGCCRuntime.endElement(NGCCRuntime.java:275)
    at org.xml.sax.helpers.XMLFilterImpl.endElement(XMLFilterImpl.java:546)
    at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source)
    at org.apache.xerces.parsers.AbstractXMLDocumentParser.emptyElement(Unknown Source)
    at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
    at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
    at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
    at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
    at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
    at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
    at org.xml.sax.helpers.XMLFilterImpl.parse(XMLFilterImpl.java:333)
    at com.sun.xml.xsom.parser.JAXPParser.parse(JAXPParser.java:115)
    at com.sun.xml.xsom.impl.parser.NGCCRuntimeEx.parseEntity(NGCCRuntimeEx.java:337)
    at com.sun.xml.xsom.impl.parser.ParserContext.parse(ParserContext.java:124)
    at com.sun.xml.xsom.parser.XSOMParser.parse(XSOMParser.java:183)
    at com.sun.xml.xsom.parser.XSOMParser.parse(XSOMParser.java:138)

thanks in advance

  • 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-16T19:50:25+00:00Added an answer on June 16, 2026 at 7:50 pm

    Why NullPointerException occurs
    The problem is that there is no error handler to handle the exception thrown while parsing and hence an exception in parsing causes returning of null.

    Setting the instance of an implementation of org.xml.sax.ErrorHandler as errorHandler solves the issue.

    parser.setErrorHandler(new DOMErrorHandler());
    

    DOMErrorHandler is the implementation of org.xml.sax.ErrorHandler.

    Why xs:include doesn’t work

    The parser parses the InputStream of the specified XSD. So it won’t get the systemId() of given schema, using which a baseURI has to be created for accessing included files. Thus it won’t be able to access the file to be included.

    So when i call parser.parse() with InputSource of the schema, it works fine.

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

Sidebar

Related Questions

I have a xsd file that looks like this: <xs:schema attributeFormDefault=unqualified elementFormDefault=qualified xmlns:xs=http://www.w3.org/2001/XMLSchema> <xs:element
I have a an XSD that looks like this (roughly) <xs:schema id=Appointment targetNamespace=http://tempuri.org/Record.xsd elementFormDefault=qualified
I have an XML Schema that looks like this: <xs:schema xmlns:xs=http://www.w3.org/2001/XMLSchema> <xs:element name=root> <xs:complexType>
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
hi i have an xml like this <?xml version=1.0?> <DataSetExchangeWMS xmlns=http://tempuri.org/DataSetExchangeWMS.xsd> <dtObjektInfo> <LanguageCode>1031</LanguageCode> <LiegenschaftID>7463</LiegenschaftID>
I have one xsd file I'd rather not modify (Exceptions.xsd): <xs:schema xmlns:xs=http://www.w3.org/2001/XMLSchema xmlns=http://me.com/Exceptions.xsd targetNamespace=http://me.com/Exceptions.xsd
I have the following two XSDS, test.xsd <?xml version=1.0 encoding=UTF-8?> <schema xmlns=http://www.w3.org/2001/XMLSchema xmlns:xsd=http://www.w3.org/2001/XMLSchema.xsd xmlns:ns1=http://www.test.com/ns1
i have this xml schema <?xml version=1.0 encoding=UTF-8?> <xs:schema xmlns=http://hidden/abc xmlns:xs=http://www.w3.org/2001/XMLSchema targetNamespace=http://hidden/abc elementFormDefault=qualified attributeFormDefault=unqualified
I have an XML document that looks like this: <?xml version=1.0 encoding=UTF-8?> <xs:msgdata xmlns:xs=http://www.myCompany.com
Now I have an XSD file (e.g. FOO_SCHEMA.xsd) that looks something like this: <xs:schema

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.