[
https://issues.apache.org/jira/browse/AXIS2-5972?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Robert Lazarski resolved AXIS2-5972.
------------------------------------
Resolution: Fixed
When a schema uses <xs:attribute ref="xmime:contentType"/>, the ADB
code generator was producing Java code with a null/empty namespace
URI:
// Before (bug): namespace lost
reader.getAttributeValue(null, "contentType");
writeAttribute("", "contentType", ..., xmlWriter);
The root cause was in SchemaCompiler.processAttribute(): when
resolving a ref attribute, the recursive call registered the mapping
using the resolved global attribute's getWireName(), which returns an
empty namespace for global attributes with inline simple types. This
empty-namespace QName propagated to the XSL template as @nsuri="",
producing incorrect generated code.
The fix re-keys the metainfo mapping after the recursive call when the
resolved wireName has lost the ref namespace, restoring the correct
QName:
// After (fix): namespace preserved from ref QName
reader.getAttributeValue("http://www.w3.org/2005/05/xmlmime",
"contentType");
writeAttribute("http://www.w3.org/2005/05/xmlmime", "contentType",
..., xmlWriter);
Changes:
- SchemaCompiler.processAttribute() — After recursive processing of
ref attributes, detect and correct lost namespace by re-keying the
metainfo mapping
- BeanWriterMetaInfoHolder.rekeyMapping() — New method to transfer all
map entries from one QName key to another across all internal maps
- New unit test verifying both base64Binary and hexBinary types in
xmlmime.xsd retain the correct namespace
All existing tests pass (adb-codegen: 24, adb-tests: 259).
> missing namespace declaration - attribute present in multiple XSD's not
> parsed correctly
> ----------------------------------------------------------------------------------------
>
> Key: AXIS2-5972
> URL: https://issues.apache.org/jira/browse/AXIS2-5972
> Project: Axis2
> Issue Type: Bug
> Components: wsdl
> Affects Versions: 1.7.8
> Environment: debian
> Reporter: Lino Lendi
> Priority: Major
> Fix For: 2.0.1
>
>
> The namespace is missing. The created java File stated:
> java.lang.String tempAttribContentType = reader.getAttributeValue(null",
> "contentType");
>
> While in the wsdl we define a namespace xmlns:cr which links to an xsd in
> which we have:
>
> at the top:
> ...
> xmlns:xmime="http://www.w3.org/2005/05/xmlmime" version="1.0">
> <xs:import namespace="http://www.w3.org/2005/05/xmlmime"
> schemaLocation="http://www.w3.org/2005/05/xmlmime.xsd"/>
>
> and then:
> <xs:complexType name="FileRefType">
> <xs:annotation>
> <xs:documentation xml:lang="DE">.....</xs:documentation>
> </xs:annotation>
> <xs:attribute ref="xmime:contentType" use="required"/>
> <xs:attribute name="filename" type="xs:normalizedString" use="required"/>
> <xs:attribute name="hash" type="xs:normalizedString" use="required"/>
> <xs:attribute name="hashAlgo" type="juspace:HashAlgoEnum" use="required"/>
> <xs:attribute name="fileType" type="cr:FileTypeEnum" use="required"/>
> </xs:complexType>
>
> All attribute besides ref="xmime:contentType" get parsed correctly.
>
> We did a manual workaround by:
> java.lang.String tempAttribContentType =
> reader.getAttributeValue("http://www.w3.org/2005/05/xmlmime",
> "contentType");
>
> For a solid solution to the root cause, please make the java2wsdl robust to
> multiple XSD's containing equally named attributes (or maybe differing only
> in capitalisation).
>
> See also: https://issues.apache.org/jira/browse/AXIS2-5949
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]