mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Fix for ETHREEOH-1811, ETHREEOH-866 & ETHREEOH-2226: Issue with required field nodes within optional parent node that is a complextype
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@17083 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -1283,9 +1283,10 @@ 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));
|
||||||
final Element bindElement =
|
final Element bindElement =
|
||||||
this.createBind(xformsDocument,
|
this.createBind(xformsDocument,
|
||||||
pathToRoot + (occurs.isRepeated() ? "[position() != last()]" : ""));
|
pathToRoot + (isRepeated ? "[position() != last()]" : ""));
|
||||||
final String bindId = bindElement.getAttributeNS(null, "id");
|
final String bindId = bindElement.getAttributeNS(null, "id");
|
||||||
|
|
||||||
modelSection.appendChild(bindElement);
|
modelSection.appendChild(bindElement);
|
||||||
@@ -1715,7 +1716,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())
|
if (occurs.isRepeated() || (occurs.isOptional() && (element.getTypeDefinition() instanceof XSSimpleTypeDefinition == false)))
|
||||||
{
|
{
|
||||||
LOGGER.debug("adding " + (occurs.minimum + 1) +
|
LOGGER.debug("adding " + (occurs.minimum + 1) +
|
||||||
" default instance elements for " + elementName +
|
" default instance elements for " + elementName +
|
||||||
@@ -1758,7 +1759,8 @@ 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.maximum == 1)
|
if ((o.isOptional() && controlType instanceof XSSimpleTypeDefinition) ||
|
||||||
|
(o.maximum == 1 && o.minimum == 1))
|
||||||
{
|
{
|
||||||
return formSection;
|
return formSection;
|
||||||
}
|
}
|
||||||
@@ -1854,14 +1856,15 @@ 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));
|
||||||
Element bindElement =
|
Element bindElement =
|
||||||
this.createBind(xformsDocument, pathToRoot + (occurs.isRepeated() ? "[position() != last()]" : ""));
|
this.createBind(xformsDocument, pathToRoot + (isRepeated ? "[position() != last()]" : ""));
|
||||||
String bindId = bindElement.getAttributeNS(null, "id");
|
String bindId = bindElement.getAttributeNS(null, "id");
|
||||||
modelSection.appendChild(bindElement);
|
modelSection.appendChild(bindElement);
|
||||||
bindElement = this.startBindElement(bindElement, schema, controlType, owner, occurs);
|
bindElement = this.startBindElement(bindElement, schema, controlType, owner, occurs);
|
||||||
|
|
||||||
// add a group if a repeat !
|
// add a group if a repeat !
|
||||||
if (owner instanceof XSElementDeclaration && occurs.maximum != 1)
|
if (owner instanceof XSElementDeclaration && occurs.isRepeated())
|
||||||
{
|
{
|
||||||
final Element groupElement = this.createGroup(xformsDocument,
|
final Element groupElement = this.createGroup(xformsDocument,
|
||||||
modelSection,
|
modelSection,
|
||||||
|
@@ -72,6 +72,11 @@ public class SchemaUtil
|
|||||||
return this.isUnbounded() || this.maximum > 1;
|
return this.isUnbounded() || this.maximum > 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isOptional()
|
||||||
|
{
|
||||||
|
return this.minimum == 0 && this.maximum == 1;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isUnbounded()
|
public boolean isUnbounded()
|
||||||
{
|
{
|
||||||
return this.maximum == UNBOUNDED;
|
return this.maximum == UNBOUNDED;
|
||||||
|
103
source/test-resources/xforms/tests/bugs/ETHREEOH-1811.xsd
Normal file
103
source/test-resources/xforms/tests/bugs/ETHREEOH-1811.xsd
Normal file
@@ -0,0 +1,103 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
<!--
|
||||||
|
* Copyright (C) 2005-2009 Alfresco Software Limited.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
|
* As a special exception to the terms and conditions of version 2.0 of
|
||||||
|
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||||
|
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||||
|
* FLOSS exception. You should have recieved a copy of the text describing
|
||||||
|
* the FLOSS exception, and it is also available here:
|
||||||
|
* http://www.alfresco.com/legal/licensing"
|
||||||
|
-->
|
||||||
|
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
|
||||||
|
xmlns:alf="http://www.alfresco.org"
|
||||||
|
xmlns:article="http://www.alfresco.org/alfresco/article"
|
||||||
|
targetNamespace="http://www.alfresco.org/alfresco/article"
|
||||||
|
elementFormDefault="qualified">
|
||||||
|
|
||||||
|
<!-- List of locales (languages) that articles can be created with -->
|
||||||
|
<xs:simpleType name="localeType">
|
||||||
|
<xs:restriction base="xs:normalizedString">
|
||||||
|
<xs:enumeration value="en_US">
|
||||||
|
<xs:annotation>
|
||||||
|
<xs:appinfo>
|
||||||
|
<alf:label>English (US)</alf:label>
|
||||||
|
</xs:appinfo>
|
||||||
|
</xs:annotation>
|
||||||
|
</xs:enumeration>
|
||||||
|
<xs:enumeration value="jp_JP">
|
||||||
|
<xs:annotation>
|
||||||
|
<xs:appinfo>
|
||||||
|
<alf:label>Japanese</alf:label>
|
||||||
|
</xs:appinfo>
|
||||||
|
</xs:annotation>
|
||||||
|
</xs:enumeration>
|
||||||
|
</xs:restriction>
|
||||||
|
</xs:simpleType>
|
||||||
|
|
||||||
|
<!-- Defines the Photo complex type -->
|
||||||
|
<xs:complexType name="photoType">
|
||||||
|
<xs:sequence>
|
||||||
|
<xs:element name="Image" type="xs:anyURI" minOccurs="1" maxOccurs="1"/>
|
||||||
|
<xs:element name="Caption" type="xs:normalizedString" minOccurs="0" maxOccurs="1"/>
|
||||||
|
</xs:sequence>
|
||||||
|
</xs:complexType>
|
||||||
|
|
||||||
|
<!-- Defines the Article complex type -->
|
||||||
|
<xs:complexType name="articleType">
|
||||||
|
<xs:sequence>
|
||||||
|
<xs:element name="Title" type="xs:normalizedString" minOccurs="1" maxOccurs="1" />
|
||||||
|
<xs:element name="Language" type="article:localeType" minOccurs="1" maxOccurs="1">
|
||||||
|
<xs:annotation>
|
||||||
|
<xs:appinfo>
|
||||||
|
<alf:appearance>minimal</alf:appearance>
|
||||||
|
</xs:appinfo>
|
||||||
|
</xs:annotation>
|
||||||
|
</xs:element>
|
||||||
|
<xs:element name="Keyword" type="xs:normalizedString" minOccurs="0" maxOccurs="unbounded" />
|
||||||
|
<xs:element name="Body" type="xs:string" minOccurs="1" maxOccurs="1" />
|
||||||
|
<xs:element name="Photo" type="article:photoType" minOccurs="0" maxOccurs="1" />
|
||||||
|
</xs:sequence>
|
||||||
|
</xs:complexType>
|
||||||
|
|
||||||
|
<!-- Defines the Multi-lingual Article type (a set of Articles) -->
|
||||||
|
<xs:complexType name="multilingualArticleType">
|
||||||
|
<xs:sequence>
|
||||||
|
<xs:element name="MultilingualArticle" type="article:articleType" minOccurs="1" maxOccurs="unbounded">
|
||||||
|
<xs:annotation>
|
||||||
|
<xs:appinfo>
|
||||||
|
<alf:label>Article</alf:label>
|
||||||
|
</xs:appinfo>
|
||||||
|
</xs:annotation>
|
||||||
|
<!-- Note: these constraints aren't verified by Alfresco, but at the very least serve as useful documentation
|
||||||
|
on what the intended data validity rules are. -->
|
||||||
|
<xs:unique name="UniqueLanguage">
|
||||||
|
<xs:selector xpath="article:language" />
|
||||||
|
<xs:field xpath="." />
|
||||||
|
</xs:unique>
|
||||||
|
<xs:unique name="UniqueKeyword">
|
||||||
|
<xs:selector xpath="article:keyword" />
|
||||||
|
<xs:field xpath="." />
|
||||||
|
</xs:unique>
|
||||||
|
</xs:element>
|
||||||
|
</xs:sequence>
|
||||||
|
</xs:complexType>
|
||||||
|
|
||||||
|
<!-- defines the form for creating an article -->
|
||||||
|
<xs:element name="article" type="article:multilingualArticleType" />
|
||||||
|
|
||||||
|
</xs:schema>
|
@@ -0,0 +1,52 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
<!--
|
||||||
|
* Copyright (C) 2005-2009 Alfresco Software Limited.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
|
* As a special exception to the terms and conditions of version 2.0 of
|
||||||
|
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||||
|
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||||
|
* FLOSS exception. You should have recieved a copy of the text describing
|
||||||
|
* the FLOSS exception, and it is also available here:
|
||||||
|
* http://www.alfresco.com/legal/licensing"
|
||||||
|
-->
|
||||||
|
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
|
||||||
|
xmlns:alf="http://www.alfresco.org"
|
||||||
|
xmlns:article="http://www.alfresco.org/alfresco/article"
|
||||||
|
targetNamespace="http://www.alfresco.org/alfresco/article"
|
||||||
|
elementFormDefault="qualified">
|
||||||
|
|
||||||
|
<!-- Defines the Photo complex type -->
|
||||||
|
<xs:complexType name="photoType">
|
||||||
|
<xs:sequence>
|
||||||
|
<xs:element name="Image" type="xs:normalizedString" minOccurs="1" maxOccurs="1" />
|
||||||
|
<xs:element name="Caption" type="xs:normalizedString" minOccurs="0" maxOccurs="1" />
|
||||||
|
<!--<xs:element name="Keywords" type="xs:anyType" minOccurs="0" />-->
|
||||||
|
</xs:sequence>
|
||||||
|
</xs:complexType>
|
||||||
|
|
||||||
|
<xs:element name="optreq">
|
||||||
|
<xs:complexType>
|
||||||
|
<xs:sequence>
|
||||||
|
<xs:element name="name" type="xs:normalizedString" minOccurs="1" maxOccurs="1" />
|
||||||
|
<xs:element name="title" type="xs:normalizedString" minOccurs="0" maxOccurs="1" />
|
||||||
|
<xs:element name="keywords" type="xs:normalizedString" minOccurs="0" maxOccurs="unbounded" />
|
||||||
|
<xs:element name="photo" type="article:photoType" minOccurs="0" maxOccurs="1" />
|
||||||
|
</xs:sequence>
|
||||||
|
</xs:complexType>
|
||||||
|
</xs:element>
|
||||||
|
|
||||||
|
</xs:schema>
|
Reference in New Issue
Block a user