Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 0.9.9, 1.0, 1.0.1, 1.0.2, 1.0.3
-
Fix Version/s: 1.0.4
-
Component/s: XML code generator
-
Labels:None
-
Environment:Windows
JDK 1.5
-
Number of attachments :
Description
Hello,
When you reference an attribute from an included Schema, the generated java code sets the type to default : java.lang.Object, although I set the referenced attribute's type to xs:string.
eg :
included common.xsd schema extract :
<xs:attribute name="xmlDBId" type="xs:string" />
including toto.xsd schema extract :
<xs:include schemaLocation="common.xsd"/>
<xs:element name="SourceInfos">
<xs:complexType>
<xs:sequence>
<xs:element ref="SourceID"/>
</xs:sequence>
<xs:attribute ref="xmlDBId" />
</xs:complexType>
</xs:element>
===> Java code extract :
/**
- Field _xmlDBId
*/
private java.lang.Object _xmlDBId;
===> Patch proposal oforg.exolab.castor.builder.SourceFactory
private void processAttributes(ComplexType complexType, FactoryState state) {
if (complexType == null)
return;
Enumeration enumeration = complexType.getAttributeDecls();
XMLBindingComponent component = new XMLBindingComponent(_config);
if (_binding != null) component.setBinding(_binding);
while (enumeration.hasMoreElements()) {
AttributeDecl attr = (AttributeDecl)enumeration.nextElement();
component.setView(attr);
//-- if we have a new SimpleType...generate ClassInfo
SimpleType sType = attr.getSimpleType();
// TODO : check if new version of Castor (> 0.9.9) solves this
// Included (->referenced) attributes does not have right java type
// eg xmldbId (type = xs:string) ===> java.lang.Object
// Look for referenced type (if any) for setting type.
// BEGIN-PATCH
if (sType == null)
{
if (attr.getReference() != null)
}
// END-PATCH
if (sType != null) {
if ( ! (SimpleTypesFactory.isBuiltInType(sType.getTypeCode())) )
if (sType.getSchema() == component.getSchema())
{
if (state.resolve(sType) == null) {
if (sType.hasFacet(Facet.ENUMERATION)) {
createSourceCode(sType, state.getSGStateInfo());
}
}
}
}
FieldInfo fieldInfo = memberFactory.createFieldInfo(component, state);
handleField(fieldInfo, state);
}
return;
}
Bertrand, can you please attach minial XML Schema instances that I could use for testing ?