DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=24292>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=24292

Contradictory validation messages

           Summary: Contradictory validation messages
           Product: Xerces2-J
           Version: 2.5.0
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: XML Schema Structures
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


Taking a schema for a target namespace that defines an attribute and an element 
containing it (both belonging to the target namespace):

[testAtt.xsd]

<?xml version="1.0" encoding="UTF-8"?> 
<xsd:schema targetNamespace="http://www.oxygenxml.com/test"; 
xmlns="http://www.oxygenxml.com/test"; 
xmlns:xsd="http://www.w3.org/2001/XMLSchema";>
  <xsd:attribute name="att" type="xsd:string"/>
  <xsd:element name="elem">
    <xsd:complexType>
      <xsd:attribute ref="att" use="required"/>
    </xsd:complexType>
  </xsd:element>
</xsd:schema>

and creating an invalid document that instead of specifying the attribute in 
the target namespace specifies it in no namespace:

[testAtt.xml]

<?xml version="1.0" encoding="UTF-8"?> 
<elem xmlns="http://www.oxygenxml.com/test"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
  xsi:schemaLocation="http://www.oxygenxml.com/test testAtt.xsd" 
att="1234"></elem>

The error messages are:

E cvc-complex-type.3.2.2: Attribute 'att' is not allowed to appear in 
element 'elem'.
E cvc-complex-type.4: Attribute 'att' must appear on element 'elem'.

The problem is the second message that should better say something like:
Attribute 'att' from namespace 'http://www.oxygenxml.com/test' must appear on 
element 'elem'.

The relevant parts from the sources are:

class XMLSchemaValidator
method addDefaultAttributes
from 2814 to 2816
    reportSchemaError(
      "cvc-complex-type.4",
      new Object[] { element.rawname, currDecl.fName });

and 
file XMLSchemaMessages.properties
line 49
cvc-complex-type.4 = cvc-complex-type.4: Attribute ''{1}'' must appear on 
element ''{0}''.

One possible solution will be pass the namespace as another parameter to the 
message, something like below:

    reportSchemaError(
      "cvc-complex-type.4",
      new Object[] { element.rawname, currDecl.fName, 
currDecl.fTargetNamespace });


cvc-complex-type.4 = cvc-complex-type.4: Attribute ''{1}'' from 
namespace ''{2}''must appear on element ''{0}''.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to