Revision: 519
Author:
joe.b...@gmail.com
Date: Mon Nov 10 16:18:03 2014 UTC
Log: (Issue 156) XMLSchemaCache.java: changed computeSubstitutionGroup
method to be recursive, so that elements w/o typeRefs but w/substitution
groups can have their type properly set
(e.g. a has not type attribute and is in subgroup of b, b had not type
attribute and is in subgroup of c, c has a type attribute... a and b should
have the same type as c)
XMLSchemaConverter.java: in convertElement method, if element type is
complexUrTyp and the element is a member of a substitutionGroup, use the
substitutionGroupHead's type as the element type
https://code.google.com/p/genxdm/source/detail?r=519
Modified:
/trunk/project/processor.w3c.xs/src/main/java/org/genxdm/processor/w3c/xs/impl/XMLSchemaConverter.java
/trunk/project/processor.w3c.xs/src/main/java/org/genxdm/processor/w3c/xs/xmlrep/XMLSchemaCache.java
=======================================
---
/trunk/project/processor.w3c.xs/src/main/java/org/genxdm/processor/w3c/xs/impl/XMLSchemaConverter.java
Fri Jul 11 15:46:51 2014 UTC
+++
/trunk/project/processor.w3c.xs/src/main/java/org/genxdm/processor/w3c/xs/impl/XMLSchemaConverter.java
Mon Nov 10 16:18:03 2014 UTC
@@ -1093,6 +1093,7 @@
}
}
final ElementDeclTypeImpl element;
+ ElementDeclTypeImpl substitutionGroupHead = null;
try
{
PreCondition.assertArgumentNotNull(xmlElement.typeRef, "{type
definition} of " + name);
@@ -1109,7 +1110,7 @@
if (null != xmlElement.substitutionGroup)
{
// TODO: Would be nice to avoid this downcast. Maybe by
using name for group head?
- final ElementDeclTypeImpl substitutionGroupHead =
(ElementDeclTypeImpl)convertElement(xmlElement.substitutionGroup);
+ substitutionGroupHead =
(ElementDeclTypeImpl)convertElement(xmlElement.substitutionGroup);
element.setSubstitutionGroup(substitutionGroupHead);
substitutionGroupHead.addSubstitutionGroupMember(element);
}
@@ -1135,7 +1136,15 @@
m_locations.m_elementLocations.put(element,
xmlElement.getLocation());
// {type definition}
- element.setType(convertType(xmlElement.typeRef));
+ Type typeFromTypeRef = convertType(xmlElement.typeRef);
+
+ // If the typeFromTypeRef is complexUrType, then it was not set,
probably because
+ // the element did not have a type attribute. So, use the type
from the substitutionGroup
+ // head, if possible.
+ if(substitutionGroupHead != null &&
typeFromTypeRef.isComplexUrType()) {
+ typeFromTypeRef = substitutionGroupHead.getType();
+ }
+ element.setType(typeFromTypeRef);
// {nillable}
element.setNillable(xmlElement.isNillable());
=======================================
---
/trunk/project/processor.w3c.xs/src/main/java/org/genxdm/processor/w3c/xs/xmlrep/XMLSchemaCache.java
Wed Apr 23 19:47:37 2014 UTC
+++
/trunk/project/processor.w3c.xs/src/main/java/org/genxdm/processor/w3c/xs/xmlrep/XMLSchemaCache.java
Mon Nov 10 16:18:03 2014 UTC
@@ -160,12 +160,23 @@
for (final QName name : m_elements.keySet())
{
final XMLElement element = m_elements.get(name);
- if (null != element.substitutionGroup &&
element.typeRef.isComplexUrType())
- {
- element.typeRef = element.substitutionGroup.typeRef;
- }
+ recursiveComputeSubstitutionGroups(element);
}
}
+ private void recursiveComputeSubstitutionGroups(XMLElement element)
+ {
+ if (null != element.substitutionGroup &&
element.typeRef.isComplexUrType())
+ {
+ recursiveComputeSubstitutionGroups(element.substitutionGroup);
+
+ // Note: if substitutionGroup head's type is a local type, we'll
pick that up later, in XMLSchemaConverter.convertElement(XMLElement);
+ // for now, we'll only be concerned with global types
+ if(element.substitutionGroup.typeRef.isGlobal())
+ {
+ element.typeRef = element.substitutionGroup.typeRef;
+ }
+ }
+ }
public XMLAttribute registerAttribute(final QName name, final
SrcFrozenLocation location) throws SmDuplicateAttributeException
{