Skip to content

Commit

Permalink
Fixing MID-1995 (superfluous xsi:type).
Browse files Browse the repository at this point in the history
  • Loading branch information
mederly committed Jul 16, 2014
1 parent b7ea65c commit d88afe0
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
Expand Up @@ -710,13 +710,17 @@ public <T> XNode marshall(T bean) throws SchemaException {
}

ListXNode xlist = new ListXNode();
for (Object element: col) {

// elementName will be determined from the first item on the list
// TODO make sure it will be correct with respect to other items as well!
if (getterResultValue instanceof JAXBElement && ((JAXBElement) getterResultValue).getName() != null) {
elementName = ((JAXBElement) getterResultValue).getName();
}

for (Object element: col) {
QName fieldTypeName = inspector.findFieldTypeName(field, element.getClass(), namespace);
Object elementToMarshall = element;
if (element instanceof JAXBElement){
if (((JAXBElement) element).getName() != null){
elementName = ((JAXBElement) element).getName();
}
elementToMarshall = ((JAXBElement) element).getValue();
}
XNode marshalled = marshallValue(elementToMarshall, fieldTypeName, isAttribute);
Expand All @@ -725,7 +729,7 @@ public <T> XNode marshall(T bean) throws SchemaException {
// Fix it in 3.1. [med]
if (fieldTypeName == null && element instanceof JAXBElement && marshalled != null) {
QName typeName = inspector.determineTypeForClass(elementToMarshall.getClass());
if (typeName != null) {
if (typeName != null && !getSchemaRegistry().hasImplicitTypeDefinition(elementName, typeName)) {
marshalled.setExplicitTypeDeclaration(true);
marshalled.setTypeQName(typeName);
}
Expand Down
Expand Up @@ -1014,7 +1014,7 @@ public boolean hasImplicitTypeDefinition(QName elementName, QName typeName) {
}

private QName resolveElementNameIfNeeded(QName elementName) {
if (elementName.getNamespaceURI() != null) {
if (StringUtils.isNotEmpty(elementName.getNamespaceURI())) {
return elementName;
}
ItemDefinition itemDef = resolveGlobalItemDefinitionWithoutNamespace(elementName.getLocalPart(), ItemDefinition.class);
Expand Down
3 changes: 3 additions & 0 deletions infra/schema/src/test/resources/common/task-bulk-action-1.xml
Expand Up @@ -33,6 +33,9 @@
<q:value>AAAAA</q:value>
</q:equal>
</s:searchFilter>
<s:action>
<s:type>log</s:type>
</s:action>
</s:expression>
<s:expression xsi:type="s:ExpressionSequenceType">
<s:expression xsi:type="s:ActionExpressionType">
Expand Down

0 comments on commit d88afe0

Please sign in to comment.