|
Re: Incorrect validation [message #604621 is a reply to message #604616] |
Wed, 28 April 2010 12:55 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) |
Ed Merks![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=ed.merks%40gmail.com) Messages: 33264 Registered: July 2009 |
Senior Member |
|
|
Tsvetan,
A1.xsd will not generally see the indirect imports of any schemas it
directly imports so I don't expect A1.xsd to see what's in A.xsd. As
such, the error message is expected unless you add an include.
Tsvetan Stoyanov wrote:
> Hi all,
>
> I have a schema file(A1.xsd, ns="http://www.example.org/A") that
> imports another schema (B.xsd, ns="http://www.example.org/B"). This
> second schema imports another schema file that has the same target
> namespace as A1 - A.xsd, ns="http://www.example.org/A".
> After loading an XSDSchema instance for A1.xsd, the validation returns
> an error saying that "Type reference
> 'http://www.example.org/A#A_ST_01' is unresolved".
> Do I have to do something with the imports before invoking the schema
> validation?
>
> 10x
> Tsvetan
>
> Source code:
>
> A1.xsd
> <schema xmlns="http://www.w3.org/2001/XMLSchema"
> targetNamespace="http://www.example.org/A"
> xmlns:tns="http://www.example.org/A" elementFormDefault="qualified"
> xmlns:b="http://www.example.org/B">
>
> <import namespace="http://www.example.org/B"
> schemaLocation="B.xsd"></import>
>
>
> <complexType name="C_CT_02">
> <sequence> <element name="e1"
> type="tns:A_ST_01"></element>
> <element name="e2" type="tns:A_ST_01NOTEXISTING"
> nillable="false"></element>
> </sequence>
> </complexType>
> </schema>
>
> B.xsd
> <schema xmlns="http://www.w3.org/2001/XMLSchema"
> targetNamespace="http://www.example.org/B"
> xmlns:tns="http://www.example.org/B" elementFormDefault="qualified"
> xmlns:a="http://www.example.org/A">
>
> <import schemaLocation="A.xsd"
> namespace="http://www.example.org/A"></import>
>
> <complexType name="B_CT_01"></complexType>
>
> <simpleType name="B_ST_01">
> <restriction base="string"/>
> </simpleType>
>
> <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"/>
> </schema>
> A.xsd
> <?xml version="1.0" encoding="UTF-8"?>
> <schema xmlns="http://www.w3.org/2001/XMLSchema"
> targetNamespace="http://www.example.org/A"
> xmlns:tns="http://www.example.org/A" elementFormDefault="qualified">
>
> <complexType name="A_CT_01"></complexType>
>
> <simpleType name="A_ST_01">
> <restriction base="string"/>
> </simpleType>
>
> <element name="A_E_01" type="string"></element>
>
> <element name="A_E_02" type="tns:A_CT_01"></element>
> </schema>
> Java
>
> ResourceSet resourceSet = new ResourceSetImpl();
> resourceSet.getLoadOptions().put(XSDResourceImpl.XSD_TRACK_L OCATION,
> 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();
> schema.validate();
> EList<XSDDiagnostic> allDiagnostics = schema.getAllDiagnostics();
> for (XSDDiagnostic diagnostic : allDiagnostics) {
> System.out.println(diagnostic.getLine() + ":" +
> diagnostic.getMessage());
> }
>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Powered by
FUDForum. Page generated in 0.02841 seconds