Fix for ETHREEOH-3117: Schema elements of type xs:anyType defined as repeating have their group label missing

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@17177 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Gavin Cornwell
2009-10-27 11:38:39 +00:00
parent cf2fc18ec2
commit 8ad23d61c0
2 changed files with 51 additions and 4 deletions

View File

@@ -1301,7 +1301,7 @@ public class Schema2XForms implements Serializable
" occurs " + occurs); " occurs " + occurs);
// create the <xforms:bind> element and add it to the model. // create the <xforms:bind> element and add it to the model.
boolean isRepeated = occurs.isRepeated() || (occurs.isOptional() && (controlType instanceof XSSimpleTypeDefinition == false)); boolean isRepeated = isRepeated(occurs, controlType);
final Element bindElement = final Element bindElement =
this.createBind(xformsDocument, this.createBind(xformsDocument,
pathToRoot + (isRepeated ? "[position() != last()]" : "")); pathToRoot + (isRepeated ? "[position() != last()]" : ""));
@@ -1734,7 +1734,7 @@ public class Schema2XForms implements Serializable
" default instance element for " + elementName + " default instance element for " + elementName +
" at path " + path); " at path " + path);
// update the default instance // update the default instance
if (occurs.isRepeated() || (occurs.isOptional() && (element.getTypeDefinition() instanceof XSSimpleTypeDefinition == false))) if (isRepeated(occurs, element.getTypeDefinition()))
{ {
LOGGER.debug("adding " + (occurs.minimum + 1) + LOGGER.debug("adding " + (occurs.minimum + 1) +
" default instance elements for " + elementName + " default instance elements for " + elementName +
@@ -1777,7 +1777,7 @@ public class Schema2XForms implements Serializable
{ {
// add xforms:repeat section if this element re-occurs // add xforms:repeat section if this element re-occurs
if ((o.isOptional() && controlType instanceof XSSimpleTypeDefinition) || if ((o.isOptional() && (controlType instanceof XSSimpleTypeDefinition || "anyType".equals(controlType.getName()))) ||
(o.maximum == 1 && o.minimum == 1)) (o.maximum == 1 && o.minimum == 1))
{ {
return formSection; return formSection;
@@ -1874,7 +1874,7 @@ public class Schema2XForms implements Serializable
} }
// create the <xforms:bind> element and add it to the model. // create the <xforms:bind> element and add it to the model.
boolean isRepeated = occurs.isRepeated() || (occurs.isOptional() && (controlType instanceof XSSimpleTypeDefinition == false)); boolean isRepeated = isRepeated(occurs, controlType);
Element bindElement = Element bindElement =
this.createBind(xformsDocument, pathToRoot + (isRepeated ? "[position() != last()]" : "")); this.createBind(xformsDocument, pathToRoot + (isRepeated ? "[position() != last()]" : ""));
String bindId = bindElement.getAttributeNS(null, "id"); String bindId = bindElement.getAttributeNS(null, "id");
@@ -3234,4 +3234,29 @@ public class Schema2XForms implements Serializable
LOGGER.debug("created bind " + id + " for nodeset " + nodeset); LOGGER.debug("created bind " + id + " for nodeset " + nodeset);
return result; return result;
} }
private boolean isRepeated(SchemaUtil.Occurrence occurs, XSTypeDefinition type)
{
// return immediately if occurs signifies repeat
if (occurs.isRepeated())
{
return true;
}
boolean repeated = false;
if (occurs.isOptional())
{
// if element is optional check the type, for
// simple and 'any' types return false
if ((type instanceof XSSimpleTypeDefinition == false) &&
("anyType".equals(type.getName()) == false))
{
repeated = true;
}
}
return repeated;
}
} }

View File

@@ -0,0 +1,22 @@
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:alf="http://www.alfresco.org"
targetNamespace="http://www.alfresco.org"
elementFormDefault="qualified">
<xs:complexType name="form-section">
<xs:sequence>
<xs:element name="section-title" type="xs:normalizedString" minOccurs="0" />
<xs:element name="section-text" type="xs:anyType" minOccurs="0" maxOccurs="unbounded" />
</xs:sequence>
</xs:complexType>
<xs:element name="simple">
<xs:complexType>
<xs:sequence>
<xs:element name="sections" type="alf:form-section" minOccurs="1" maxOccurs="unbounded" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>