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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T12:29:50+00:00 2026-06-10T12:29:50+00:00

Ok so here is the deal. I have an xml file starting like this:

  • 0

Ok so here is the deal. I have an xml file starting like this:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ns3:rosApplicationDocument xmlns:ns2="http://ereg.egov.bg/segment/0009-000013" xmlns:ns3="http://ereg.egov.bg/segment/0009-900001" xmlns:ns4="http://ereg.egov.bg/segment/0009-000022">

And the xsd starting like that:

<?xml version="1.0" encoding="utf-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    targetNamespace="http://ereg.egov.bg/segment/0009-900001" xmlns="http://ereg.egov.bg/segment/0009-900001"

xmlns:dtn="http://ereg.egov.bg/value/0008-000007" xmlns:emad="http://ereg.egov.bg/value/0008-000036"
xmlns:aisuri="http://ereg.egov.bg/value/0008-000039" xmlns:ssu="http://ereg.egov.bg/value/0008-000077"


xmlns:dtu="http://ereg.egov.bg/segment/0009-000003" xmlns:ebd="http://ereg.egov.bg/segment/0009-000013"
xmlns:rou="http://ereg.egov.bg/segment/0009-000022" xmlns:idu="http://ereg.egov.bg/segment/0009-000046"
xmlns:eovau="http://ereg.egov.bg/segment/0009-000051" xmlns:easu="http://ereg.egov.bg/segment/0009-000091"
xmlns:ss="http://www.bulsi.bg/egov/ServiceSupplier" elementFormDefault="qualified">

<xsd:import namespace="http://www.bulsi.bg/egov/ServiceSupplier"
    schemaLocation="ServiceSupplierType.xsd" />

<xsd:import namespace="http://ereg.egov.bg/value/0008-000007"
    schemaLocation="DocumentTypeName-0008-000007.xsd" />
<xsd:import namespace="http://ereg.egov.bg/value/0008-000036"
    schemaLocation="EmailAddress-0008-000036.xsd" />
<xsd:import namespace="http://ereg.egov.bg/value/0008-000039"
    schemaLocation="AISURI-0008-000039.xsd" />
<xsd:import namespace="http://ereg.egov.bg/value/0008-000077"
    schemaLocation="SUNAUServiceURI-0008-000077.xsd" />

<xsd:import namespace="http://ereg.egov.bg/segment/0009-000003"
    schemaLocation="DocumentTypeURI-0009-000003.xsd" />
<xsd:import namespace="http://ereg.egov.bg/segment/0009-000013"
    schemaLocation="EntityBasicData-0009-000013.xsd" />
<xsd:import namespace="http://ereg.egov.bg/segment/0009-000022"
    schemaLocation="RegisterObjectURI-0009-000022.xsd" />
<xsd:import namespace="http://ereg.egov.bg/segment/0009-000046"
    schemaLocation="InitiatingDocumentURI-0009-000046.xsd" />
<xsd:import namespace="http://ereg.egov.bg/segment/0009-000051"
    schemaLocation="EditorOrVisualizerApplicationURI-0009-000022.xsd" />
<xsd:import namespace="http://ereg.egov.bg/segment/0009-000091"
    schemaLocation="ElectronicAdministrativeServiceURI-0009-000091.xsd" />

<!-- <xsd:key name="serviceID"> <xsd:selector xpath="RosApplicationDocument/Enclosures/SimpleServiceEnclosure"/> 
    <xsd:field xpath="@id"/> </xsd:key> <xsd:keyref name="serviceIDREF" refer="serviceID"> 
    <xsd:selector xpath="RosApplicationDocument/Enclosures/ComplexServiceEnclosure/InitialServices/InitialService/InitialService" 
    /> <xsd:field xpath="@ref"/> </xsd:keyref> -->

<xsd:element name="RosApplicationDocument" type="RosApplicationDocument" />

And the unmarshalling :

JAXBContext context = JAXBContext.newInstance(c);
            Unmarshaller um = context.createUnmarshaller();
            if (c.equals(RosApplicationDocument.class)) {
                SchemaFactory schemaFactory = SchemaFactory
                        .newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
                Schema schema = schemaFactory.newSchema(new File(pathToXSD));
                um.setSchema(schema);
                RosApplicationDocument document = (RosApplicationDocument) um
                        .unmarshal(getSource(pathToFile));
                RosApplicationDocumentFactory.removeCDATAFromSegments(document);
                return document;
            }

public static SAXSource getSource(String pathToFile) {
        try {
            SAXParserFactory parserFactory = SAXParserFactory.newInstance();
            parserFactory.setNamespaceAware(true);
            parserFactory.setValidating(true);
            SAXParser saxParser = parserFactory.newSAXParser();
            XMLReader xmlReader = saxParser.getXMLReader();
            xmlReader
                    .setEntityResolver(new RosApplicationDocumentEntityResolver());
            InputSource inSrc = new InputSource(new FileReader(pathToFile));
            return new SAXSource(xmlReader, inSrc);
        } catch (SAXException e) {
            e.printStackTrace();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (ParserConfigurationException e) {
            e.printStackTrace();
        }

        return null;
    }

Why do i get this exception : [org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element ‘ns3:rosApplicationDocument’.]

Edit:

Here is the LSResourceResolver:

public class MyLSResourceResolver implements LSResourceResolver {

    @Override
    public LSInput resolveResource(String type, String namespaceURI,
            String publicId, String systemId, String baseURI) {
        System.out.println(publicId);
        System.out.println(systemId);
        System.out.println(baseURI);
        System.out.println(namespaceURI);
        System.out.println(type);
        return null;
    }

}

i set it to the factory like : schemaFactory.setResourceResolver(new MyLSResourceResolver());

And here is the output of the console :

null
ServiceSupplierType.xsd
file:/home/doncho/Documents/data/java/ROSAppl/src/bg/bulsi/egov/rosappl/xml_schemas/appl_v3.xsd
http://www.bulsi.bg/egov/ServiceSupplier
http://www.w3.org/2001/XMLSchema
null
EmailAddress-0008-000036.xsd
file:/home/doncho/Documents/data/java/ROSAppl/src/bg/bulsi/egov/rosappl/xml_schemas/ServiceSupplierType.xsd
http://ereg.egov.bg/value/0008-000036
http://www.w3.org/2001/XMLSchema
null
EntityBasicData-0009-000013.xsd
file:/home/doncho/Documents/data/java/ROSAppl/src/bg/bulsi/egov/rosappl/xml_schemas/ServiceSupplierType.xsd
http://ereg.egov.bg/segment/0009-000013
http://www.w3.org/2001/XMLSchema
null
EntityName-0008-000029.xsd
file:/home/doncho/Documents/data/java/ROSAppl/src/bg/bulsi/egov/rosappl/xml_schemas/EntityBasicData-0009-000013.xsd
http://ereg.egov.bg/value/0008-000029
http://www.w3.org/2001/XMLSchema
null
EntityIdentifier-0008-000028.xsd
file:/home/doncho/Documents/data/java/ROSAppl/src/bg/bulsi/egov/rosappl/xml_schemas/EntityBasicData-0009-000013.xsd
http://ereg.egov.bg/value/0008-000028
http://www.w3.org/2001/XMLSchema
null
DocumentTypeName-0008-000007.xsd
file:/home/doncho/Documents/data/java/ROSAppl/src/bg/bulsi/egov/rosappl/xml_schemas/appl_v3.xsd
http://ereg.egov.bg/value/0008-000007
http://www.w3.org/2001/XMLSchema
null
AISURI-0008-000039.xsd
file:/home/doncho/Documents/data/java/ROSAppl/src/bg/bulsi/egov/rosappl/xml_schemas/appl_v3.xsd
http://ereg.egov.bg/value/0008-000039
http://www.w3.org/2001/XMLSchema
null
SUNAUServiceURI-0008-000077.xsd
file:/home/doncho/Documents/data/java/ROSAppl/src/bg/bulsi/egov/rosappl/xml_schemas/appl_v3.xsd
http://ereg.egov.bg/value/0008-000077
http://www.w3.org/2001/XMLSchema
null
DocumentTypeURI-0009-000003.xsd
file:/home/doncho/Documents/data/java/ROSAppl/src/bg/bulsi/egov/rosappl/xml_schemas/appl_v3.xsd
http://ereg.egov.bg/segment/0009-000003
http://www.w3.org/2001/XMLSchema
null
RegisterObjectURI-0009-000022.xsd
file:/home/doncho/Documents/data/java/ROSAppl/src/bg/bulsi/egov/rosappl/xml_schemas/DocumentTypeURI-0009-000003.xsd
http://ereg.egov.bg/segment/0009-000022
http://www.w3.org/2001/XMLSchema
null
BatchNumber-0008-000001.xsd
file:/home/doncho/Documents/data/java/ROSAppl/src/bg/bulsi/egov/rosappl/xml_schemas/RegisterObjectURI-0009-000022.xsd
http://ereg.egov.bg/value/0008-000001
http://www.w3.org/2001/XMLSchema
null
InitiatingDocumentURI-0009-000046.xsd
file:/home/doncho/Documents/data/java/ROSAppl/src/bg/bulsi/egov/rosappl/xml_schemas/appl_v3.xsd
http://ereg.egov.bg/segment/0009-000046
http://www.w3.org/2001/XMLSchema
null
DocumentURI-0009-000001.xsd
file:/home/doncho/Documents/data/java/ROSAppl/src/bg/bulsi/egov/rosappl/xml_schemas/InitiatingDocumentURI-0009-000046.xsd
http://ereg.egov.bg/segment/0009-000001
http://www.w3.org/2001/XMLSchema
null
RegisterIndex-0008-000002.xsd
file:/home/doncho/Documents/data/java/ROSAppl/src/bg/bulsi/egov/rosappl/xml_schemas/DocumentURI-0009-000001.xsd
http://ereg.egov.bg/value/0008-000002
http://www.w3.org/2001/XMLSchema
null
DocumentSequenceNumber-0008-000003.xsd
file:/home/doncho/Documents/data/java/ROSAppl/src/bg/bulsi/egov/rosappl/xml_schemas/DocumentURI-0009-000001.xsd
http://ereg.egov.bg/value/0008-000003
http://www.w3.org/2001/XMLSchema
null
DocumentReceiptOrSigningDate-0008-000004.xsd
file:/home/doncho/Documents/data/java/ROSAppl/src/bg/bulsi/egov/rosappl/xml_schemas/DocumentURI-0009-000001.xsd
http://ereg.egov.bg/value/0008-000004
http://www.w3.org/2001/XMLSchema
null
EditorOrVisualizerApplicationURI-0009-000022.xsd
file:/home/doncho/Documents/data/java/ROSAppl/src/bg/bulsi/egov/rosappl/xml_schemas/appl_v3.xsd
http://ereg.egov.bg/segment/0009-000051
http://www.w3.org/2001/XMLSchema
null
ElectronicAdministrativeServiceURI-0009-000091.xsd
file:/home/doncho/Documents/data/java/ROSAppl/src/bg/bulsi/egov/rosappl/xml_schemas/appl_v3.xsd
http://ereg.egov.bg/segment/0009-000091
http://www.w3.org/2001/XMLSchema
javax.xml.bind.MarshalException
 - with linked exception:
[org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element 'ns3:rosApplicationDocument'.]

The same exception at the end.. So the problem isnt in the xsd

  • 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-10T12:29:53+00:00Added an answer on June 10, 2026 at 12:29 pm

    In the xml you have:

    xmlns:ns3="http://ereg.egov.bg/segment/0009-900001"
    

    So http://ereg.egov.bg/segment/0009-900001 should be the default namespace of your schema, but I don’t see it declared in the sample code that you posted.

    Also, in the schema the element is declared RosApplicationDocument while in the document rosApplicationDocument (lower case)

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

Sidebar

Related Questions

I have been struggling with this for months in my project. Here's the deal:
I have an XML document like this: <xml> <item> <title>Article 1</title> <text><![CDATA[Lorem ipsum dolor
Here's the deal. I have an XML document with a lot of records. Something
Here's the deal : I have Publication objets in my application. I also have
Here is the deal, in my Java project I have to make a composite
OK, here's the deal. I have Git installed on my Debian (lenny) remote server.
Here is an example bit from the xml file: <array> <dict> <key>Name</key> <string>Joe Smith</string>
So ... I have build.xml that loads property file from basedir. Then, as the
Here's the deal: I have a report designer where users can create reports based
I have a WCF application that at present is using XML based file storage

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.