I have a schema with two attributes that share the same name within an attributeGroup. One of the attributes is a ref to an attribute in another namespace, so it is namespace qualified, but Castor 0.9.5 maps both the fields to _lang and hence generates a "duplicate name _lang" exception. This bug already exists since Feb 2002 as Bug 867 (http://bugzilla.exolab.org/show_bug.cgi?id=867). The schema is attached as dummy.xsd. The relevant piece of schema is:

        <xsd:attributeGroup name="language">
                <xsd:attribute name="lang" use="optional" />
                <xsd:attribute ref="foo:lang" use="optional"/>
                <xsd:attribute name="script" use="optional"/>
        </xsd:attributeGroup>

The workaround given in the response for this bug was to use a binding file. I've tried several binding files but I can't solve the problem, could you suggest what is wrong?

The following do nothing, the error still appears

<binding defaultBindingType="type">
   <attributeBinding name="group:language/@lang" >
     <member name="newname" />
   </attributeBinding>
</binding>

or

<binding defaultBindingType="type">
   <attributeBinding name="complexType:modsType/group:language/@lang" >
     <member name="newname" />
   </attributeBinding>
</binding>

In fact even if I try to change the name of a different attribute (one without a naming collision, such as "script") then no changes are made.


The following causes a strange error message, referring to "-error-if-this-is-used-". I suspect I need to supply a handler, but can't find any documentation on what this is. Are there any examples of handlers available, or examples of different binding files? How does Castor distinguish between the two "lang" attributes within a binding file?


<binding defaultBindingType="type">
  <groupBinding name="group:language">
   <attributeBinding name="@lang" >
     <member name="newname" />
   </attributeBinding>
  </groupBinding>
</binding>


--Unable to load a binding file due to the following Exception:
--------------------------------
Stack Trace for :ValidationException: -error-if-this-is-used- is a required field.;
- location of error: XPATH: binding/componentBindingType{file: file:///home/afc/castor/mets_example/bindingFile; line: 7; column: 11}
ValidationException: -error-if-this-is-used- is a required field.;
- location of error: XPATH: binding/componentBindingType
at org.exolab.castor.xml.FieldValidator.validate(FieldValidator.java:195)
at org.exolab.castor.xml.util.XMLClassDescriptorImpl.validate(XMLClassDescriptorImpl.java:885)
at org.exolab.castor.xml.Validator.validate(Validator.java:122)
at org.exolab.castor.xml.FieldValidator.validate(FieldValidator.java:216)
at org.exolab.castor.xml.util.XMLClassDescriptorImpl.validate(XMLClassDescriptorImpl.java:885)
at org.exolab.castor.xml.Validator.validate(Validator.java:122)
at org.exolab.castor.xml.UnmarshalHandler.endElement(UnmarshalHandler.java:709)
at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanEndElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:555)
at org.exolab.castor.builder.binding.BindingLoader.loadBinding(BindingLoader.java:130)
at org.exolab.castor.builder.binding.BindingLoader.createBinding(BindingLoader.java:250)
at org.exolab.castor.builder.SourceGenerator.main(SourceGenerator.java:1112)
--------------------------------
ValidationException: -error-if-this-is-used- is a required field.;
- location of error: XPATH: binding/componentBindingType{file: file:///home/afc/castor/mets_example/bindingFile; line: 7; column: 11}
at org.exolab.castor.builder.binding.BindingLoader.loadBinding(BindingLoader.java:196)
at org.exolab.castor.builder.binding.BindingLoader.createBinding(BindingLoader.java:250)
at org.exolab.castor.builder.SourceGenerator.main(SourceGenerator.java:1112)
-- No binding file will be used
Warning: The W3C datatype 'language' is not currently supported by Castor Source Generator. It will be treated as a java.lang.String.





Amanda


--
Amanda Clare  http://users.aber.ac.uk/afc/
Tel: +44 (0)1970 622410  Fax: +44 (0)1970 622455
Dept. of Computer Science, University of Wales, Aberystwyth, SY23 3DB
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema targetNamespace="http://abc.xyz.com/"; 
            xmlns="http://abc.xyz.com/"; 
            xmlns:xsd="http://www.w3.org/2001/XMLSchema"; 
            xmlns:foo="http://www.w3.org/XML/1998/namespace";  
            elementFormDefault="qualified" 
            attributeFormDefault="qualified">

   <xsd:import namespace="http://www.w3.org/XML/1998/namespace"; schemaLocation="xml.xsd"/> 
	
	<xsd:element name="mods" type="modsType"/>

	<xsd:complexType name="modsType">
		<xsd:attribute name="ID" type="xsd:ID" use="optional"/>
		<xsd:attributeGroup ref="language"/>
	</xsd:complexType>


	<xsd:attributeGroup name="language">
		<xsd:attribute name="lang" use="optional" />
		<xsd:attribute ref="foo:lang" use="optional"/>
		<xsd:attribute name="script" use="optional"/>
		<xsd:attribute name="transliteration" use="optional"/>
	</xsd:attributeGroup>
</xsd:schema>

Reply via email to