Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 352941

Summary: Global Attributes in XSD Schema
Product: [Modeling] EMF Reporter: Frank Siegert <f.siegert>
Component: XSDAssignee: Ed Merks <Ed.Merks>
Status: RESOLVED INVALID QA Contact:
Severity: normal    
Priority: P3 CC: f.siegert
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows Vista   
Whiteboard:
Attachments:
Description Flags
XSD Schema using global attributes
none
XML file using the XSD schema from test.xsd none

Description Frank Siegert CLA 2011-07-23 16:28:06 EDT
Build Identifier: 20110615-0604

A XSD schema definition using global attributes can't currently be validated correctly. The validation ends in a conflict that on the one hand the described attribute is required and on the other hand not allowed to be used. The following error messages are the results:

cvc-complex-type.3.2.2: Attribute '...' is not allowed
cvc-complex-type.4: Attribute '...' must appear on element '...'.

Reproducible: Always

Steps to Reproduce:
1. put the attached file test.xsd into a project
2. put the attached file test.xml into a project
3. validate test.xml against test.xsd
Comment 1 Frank Siegert CLA 2011-07-23 16:31:33 EDT
Created attachment 200236 [details]
XSD Schema using global attributes

test file to reproduce the error messages
Comment 2 Frank Siegert CLA 2011-07-23 16:32:34 EDT
Created attachment 200237 [details]
XML file using the XSD schema from test.xsd

test file to reproduce the error messages
Comment 3 Ed Merks CLA 2011-07-23 21:16:17 EDT
The file isn't valid.  The attribute must be qualified with its namespace.  The declaration xmlns="..." only provides an implicit namespace for elements in the contained XML.  They do not implicitly provide the namespace for attributes.  So it's impossible to have a qualified attribute in the instance unless you use an explicit named prefix for that namespace.
Comment 4 Frank Siegert CLA 2011-07-24 11:32:27 EDT
Thanks for pointing this out. To use global attributes unqualified I had to remove the target name space from the XSD schema. As a result in the instance document no name space needs to be defined and the XSD schema has to be referenced by xsi:noNamespaceSchemaLocation="...".