This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes XML and Related Technologies and the fly likes Unable to refer global element Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Unable to refer global element" Watch "Unable to refer global element" New topic

Unable to refer global element

Ravinderjit Singh
Ranch Hand

Joined: Jan 13, 2010
Posts: 70
Hello All,

This is my xml schema where I am trying to refer to global element, but getting error.

Line number 11 causing the below error.

src-resolve.4.2: Error resolving component 'schema'. It was detected that 'schema' is in namespace '',
but components from this namespace are not referenceable from schema document
If this is the incorrect namespace, perhaps the prefix of 'schema' needs to be changed.
If this is the correct namespace, then an appropriate 'import' tag should be added to

how to resolve this?
Ravinderjit Singh
Ranch Hand

Joined: Jan 13, 2010
Posts: 70
any pointer?
g tsuji
Ranch Hand

Joined: Jan 18, 2011
Posts: 500
Since w3c schema is in a different namespace than the present target namespace of the schema, you've to import it. The import element is a top level element, hence, you place the following accordingly.

I deliberately omit the schemaLocation in the above as it is only a suggestive data and you could be overridden at the application level. If you let the validation engine do the import implicitly with the data so supplied, you can put it there as well, like this.

That is the schema for schema supplied by the consortium. (It includes some dtd and sometime could cause trouble to some engine's default loading.) If you've anything better or a more restructive subset of it, you can actually supply any other location as long as the required schema for schema is properly pointed to.
It is sorta covered in the JavaRanch Style Guide.
subject: Unable to refer global element
Similar Threads
JAXB: Two xsd - Create single JAXBContext
Is Nillable same as an empty element
Doubt on XML Schema validity
Defining XSD for an XML file with constraint on the contents of a tag
Unable to send a SOAP request to a service implementing Provider