Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » XSD » Incorrect validation((Possibly) incorrect validation of imported schema)
Incorrect validation [message #530070] Wed, 28 April 2010 11:36
Tsvetan Stoyanov is currently offline Tsvetan StoyanovFriend
Messages: 10
Registered: July 2009
Junior Member
Hi all,

I have a schema file(A1.xsd, ns="") that imports another schema (B.xsd, ns=""). This second schema imports another schema file that has the same target namespace as A1 - A.xsd, ns="".
After loading an XSDSchema instance for A1.xsd, the validation returns an error saying that "Type reference '' is unresolved".
Do I have to do something with the imports before invoking the schema validation?


Source code:

<schema xmlns="" targetNamespace="" xmlns:tns="" elementFormDefault="qualified" xmlns:b="">

	<import namespace="" schemaLocation="B.xsd"></import>
		<complexType name="C_CT_02">
			<element name="e1" type="tns:A_ST_01"></element>
			<element name="e2" type="tns:A_ST_01NOTEXISTING" nillable="false"></element>

<schema xmlns="" targetNamespace="" xmlns:tns="" elementFormDefault="qualified" xmlns:a="">

	<import schemaLocation="A.xsd" namespace=""></import>
	<complexType name="B_CT_01"></complexType>
	<simpleType name="B_ST_01">
		<restriction base="string"/>
	<element name="B_E_01" type="string"/>
	<element name="B_E_02" type="tns:B_CT_01"/>
	<element name="B_E_03" type="a:A_ST_01"/>
	<element name="B_E_04" type="a:A_CT_01"/>

<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="" targetNamespace="" xmlns:tns="" elementFormDefault="qualified">

	<complexType name="A_CT_01"></complexType>
	<simpleType name="A_ST_01">
		<restriction base="string"/>
	<element name="A_E_01" type="string"></element>
	<element name="A_E_02" type="tns:A_CT_01"></element>

ResourceSet resourceSet = new ResourceSetImpl();
resourceSet.getLoadOptions().put(XSDResourceImpl.XSD_TRACK_LOCATION, Boolean.TRUE);
URL entry = Activator.getDefault().getBundle().getResource("resources/original/A1.xsd");
URI uri = URI.createURI(entry.toString());
XSDResourceImpl xsdResource = (XSDResourceImpl) resourceSet.getResource(uri, true);
XSDSchema schema = xsdResource.getSchema();
EList<XSDDiagnostic> allDiagnostics = schema.getAllDiagnostics();
for (XSDDiagnostic diagnostic : allDiagnostics) {
	System.out.println(diagnostic.getLine() + ":" + diagnostic.getMessage());
Previous Topic:XSDSchema
Next Topic:XML plugin translator for XML files
Goto Forum:

Current Time: Wed Feb 26 23:43:36 GMT 2020

Powered by FUDForum. Page generated in 0.04156 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top