Dimitar Ivanov
Dimitar Ivanov

Reputation: 116

Schema location even number of URI's on marshaling

I am using the following schema to parse GraphML XML files.

I managed to bind java classes from the schema (using xjc) and also unmarshaled a few example XML files.

Unfortunately, when I come to marshaling the XMLs I am getting the following error:

SchemaLocation: schemaLocation value = 'Graphml.xsd' must have even number of URI's

As far as I can see the only schemaLocation use in the xsd is the following:

<xs:import namespace="http://www.w3.org/1999/xlink"                
  schemaLocation="http://graphml.graphdrawing.org/xmlns/1.0/xlink.xsd">
  ...

But I can't see a problem in it.

Can someone suggest what is wrong ?

Upvotes: 1

Views: 1442

Answers (2)

C. M. Sperberg-McQueen
C. M. Sperberg-McQueen

Reputation: 25034

The schema fragment you show is syntactically correct; you are right not to find any problem there. The error message also doesn't seem to be talking about the schema at http://graphml.graphdrawing.org/xmlns/1.1/graphml-structure.xsd -- it's talking about something called GraphML.xsd.

Without seeing the XML instance it's hard to be sure, but perhaps in the document instance there is an attribute value specification of the form xsi:schemaLocation = "GraphML.xsd" and a validator is complaining that the value "GraphML.xsd" needs instead to be a value containing an even number of URIs: namespace-name, schema-location pairs (as described in Blaise Doughan's answer).

Upvotes: 2

bdoughan
bdoughan

Reputation: 149017

There are two parts to a schemaLocation the first is the namespace and the second followed by a space is the location. Something like the following would be valid.

<foo 
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns/1.0 http://graphml.graphdrawing.org/xmlns/1.0/xlink.xsd">
    ...
</foo>

A schema location can be set on a Marshaller. Is it possible that you are doing the following?

Marshaller marshaller = jaxbContext.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_SCHEMA_LOCATION, "Graphml.xsd");

Upvotes: 4

Related Questions