From badba0e799be95063a24a0af334df320eca44827 Mon Sep 17 00:00:00 2001 From: Ariel Backenroth Date: Thu, 11 Jan 2007 03:57:24 +0000 Subject: [PATCH] fix for schema2xforms converter when dealing with elements that have anonymous complexTypes which are repeated. the proper nodeset wasn't being associated since the bind was incomplete. also correcting an issue where bind can only be required for simple schema types since complex types have complex values which aren't implicitly validated. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@4789 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../web/forms/xforms/SchemaFormBuilder.java | 33 +++++++++++-------- .../customer-tests/eyestreet-footer.xsd | 26 +++++++++++++++ 2 files changed, 45 insertions(+), 14 deletions(-) create mode 100644 source/test-resources/xforms/customer-tests/eyestreet-footer.xsd diff --git a/source/java/org/alfresco/web/forms/xforms/SchemaFormBuilder.java b/source/java/org/alfresco/web/forms/xforms/SchemaFormBuilder.java index d95270dfb9..a8d075fbc4 100644 --- a/source/java/org/alfresco/web/forms/xforms/SchemaFormBuilder.java +++ b/source/java/org/alfresco/web/forms/xforms/SchemaFormBuilder.java @@ -1474,18 +1474,16 @@ public class SchemaFormBuilder pathToRoot); modelSection.appendChild(bindElement); - if (typeName != null) - { - this.startBindElement(bindElement, - schema, - controlType, - null, - pathToRoot, - SchemaUtil.getOccurance(elementDecl)); - } + LOGGER.debug("adding bind for control " + controlType + + " type " + typeName + + " path to root " + pathToRoot); + this.startBindElement(bindElement, + schema, + controlType, + null, + pathToRoot, + SchemaUtil.getOccurance(elementDecl)); } - - //addComplexType(xForm,modelSection, formSection,(ComplexType)controlType,elementDecl,pathToRoot, relative); this.addComplexType(xForm, modelSection, defaultInstanceElement, @@ -2616,7 +2614,9 @@ public class SchemaFormBuilder String nodeset = pathToRoot; if (o.isRepeated()) + { nodeset = pathToRoot + "[position() != last()]"; + } bindElement.setAttributeNS(NamespaceConstants.XFORMS_NS, NamespaceConstants.XFORMS_PREFIX + ":nodeset", @@ -2629,9 +2629,11 @@ public class SchemaFormBuilder schema, controlType); if (typeName != null && typeName.length() != 0) + { bindElement.setAttributeNS(NamespaceConstants.XFORMS_NS, NamespaceConstants.XFORMS_PREFIX + ":type", typeName); + } } final short constraintType = @@ -2647,9 +2649,12 @@ public class SchemaFormBuilder NamespaceConstants.XFORMS_PREFIX + ":readonly", (constraintType == XSConstants.VC_FIXED) + "()"); - bindElement.setAttributeNS(NamespaceConstants.XFORMS_NS, - NamespaceConstants.XFORMS_PREFIX + ":required", - (o.minimum != 0) + "()"); + if (controlType instanceof XSSimpleTypeDefinition) + { + bindElement.setAttributeNS(NamespaceConstants.XFORMS_NS, + NamespaceConstants.XFORMS_PREFIX + ":required", + (o.minimum != 0) + "()"); + } //no more minOccurs & maxOccurs element: add a constraint if maxOccurs>1: //count(.) <= maxOccurs && count(.) >= minOccurs diff --git a/source/test-resources/xforms/customer-tests/eyestreet-footer.xsd b/source/test-resources/xforms/customer-tests/eyestreet-footer.xsd new file mode 100644 index 0000000000..1cefc3a016 --- /dev/null +++ b/source/test-resources/xforms/customer-tests/eyestreet-footer.xsd @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + +