Revision: 517
Author:
joe.b...@gmail.com
Date: Tue Sep 23 19:54:39 2014 UTC
Log: (Issue 153) AttributeManager.initialize(...) now returns a QName
for unresolved xsi:types instead of a boolean. That QName is non-null only
if an xsi:type is not resolveable. ValidationKernel.startElement now
reports an error if AttributeManager.initialize returns a QName (see above)
and the current processContents is strict.
https://code.google.com/p/genxdm/source/detail?r=517
Modified:
/trunk/project/processor.w3c.xs.validation/src/main/java/org/genxdm/processor/w3c/xs/validation/impl/AttributeManager.java
/trunk/project/processor.w3c.xs.validation/src/main/java/org/genxdm/processor/w3c/xs/validation/impl/ValidationKernel.java
=======================================
---
/trunk/project/processor.w3c.xs.validation/src/main/java/org/genxdm/processor/w3c/xs/validation/impl/AttributeManager.java
Tue Apr 8 19:11:05 2014 UTC
+++
/trunk/project/processor.w3c.xs.validation/src/main/java/org/genxdm/processor/w3c/xs/validation/impl/AttributeManager.java
Tue Sep 23 19:54:39 2014 UTC
@@ -399,12 +399,12 @@
* The handler for exceptions.
* @param p2n
* A prefix resolver.
- * @return whether or not caller should switch processContents mode from
lax to skip. Returns true iff the current processContents is lax,
- * AND an xsi:type attribute exists, AND that type cannot be resolved.
Otherwise, returns false.
+ * @return null if no xsi:type attribute exists or if the xsi:type can be
resolved; otherwise, returns the QName of the unresolved xsi:type which
+ * the caller should use for error reporting, if desired
*/
- public boolean initialize(final QName elementName, final Locatable
locatable, final LinkedList<VxMapping<QName, String>> attributes, final
PrefixResolver p2n, final URI baseURI, final SchemaExceptionHandler errors,
final VxSchemaDocumentLocationStrategy schemaDocumentLocationStrategy,
final ProcessContentsMode processContents) throws IOException,
AbortException
+ public QName initialize(final QName elementName, final Locatable
locatable, final LinkedList<VxMapping<QName, String>> attributes, final
PrefixResolver p2n, final URI baseURI, final SchemaExceptionHandler errors,
final VxSchemaDocumentLocationStrategy schemaDocumentLocationStrategy,
final ProcessContentsMode processContents) throws IOException,
AbortException
{
- boolean setFromLaxToSkip = false;
+ QName unresolvedXsiTypeName = null;
reset();
if (attributes.size() > 0) // Optimization.
@@ -427,17 +427,13 @@
final QName typeName = atomBridge.getQName(actualValue);
m_localType = metaBridge.getTypeDefinition(typeName);
- if (null != m_localType || processContents ==
ProcessContentsMode.Skip || processContents == ProcessContentsMode.Lax)
+ if (null != m_localType)
{
m_xsiAtoms.put(attributeName, new Pair<A, SimpleType>(actualValue,
attributeType));
- if(processContents == ProcessContentsMode.Lax)
- {
- setFromLaxToSkip = true;
- }
}
else
{
- errors.error(new CvcElementUnresolvedLocalTypeException(typeName,
elementName, locatable.getLocation()));
+ unresolvedXsiTypeName = typeName;
}
}
catch (final DatatypeException dte)
@@ -524,7 +520,7 @@
}
}
}
- return setFromLaxToSkip;
+ return unresolvedXsiTypeName;
}
public void reset()
=======================================
---
/trunk/project/processor.w3c.xs.validation/src/main/java/org/genxdm/processor/w3c/xs/validation/impl/ValidationKernel.java
Tue Apr 8 19:11:05 2014 UTC
+++
/trunk/project/processor.w3c.xs.validation/src/main/java/org/genxdm/processor/w3c/xs/validation/impl/ValidationKernel.java
Tue Sep 23 19:54:39 2014 UTC
@@ -28,6 +28,7 @@
import org.genxdm.names.NameSource;
import
org.genxdm.processor.w3c.xs.exception.cvc.CvcElementFixedValueOverriddenSimpleException;
import
org.genxdm.processor.w3c.xs.exception.cvc.CvcElementUnexpectedChildInNilledElementException;
+import
org.genxdm.processor.w3c.xs.exception.cvc.CvcElementUnresolvedLocalTypeException;
import
org.genxdm.processor.w3c.xs.exception.cvc.CvcUnexpectedNonWhiteSpaceTextInElementOnlyContentException;
import
org.genxdm.processor.w3c.xs.exception.cvc.CvcUnexpectedTextInEmptyContentException;
import org.genxdm.processor.w3c.xs.exception.sm.SmExceptionSupplier;
@@ -602,22 +603,21 @@
// Digest the attributes from the XMLSchema-instance namespace.
- boolean switchProcessContentFromLaxToSkip =
m_attributes.initialize(elementName, m_currentItem, attributes,
m_namespaces, documentURI, m_errors, sdl,
m_currentPSVI.getProcessContents());
+ QName unresolvedXsiTypeName = m_attributes.initialize(elementName,
m_currentItem, attributes, m_namespaces, documentURI, m_errors, sdl,
m_currentPSVI.getProcessContents());
// if we're not operating in caller-overrides-type mode, get the
xsi:type override
if (m_attributes.getLocalType() != null)
localType = m_attributes.getLocalType();
- else if(switchProcessContentFromLaxToSkip)
- {
- if(savedPC == null)
- {
- savedPC = m_currentPSVI.getProcessContents();
- }
- m_currentPSVI.setProcessContents(ProcessContentsMode.Skip);
- }
+
final Boolean explicitNil = m_attributes.getLocalNil();
m_currentPSVI = m_mac.startElement(elementName, localType, explicitNil);
+
+ if(unresolvedXsiTypeName != null && m_currentPSVI.getProcessContents()
== ProcessContentsMode.Strict)
+ {
+ m_errors.error(new
CvcElementUnresolvedLocalTypeException(unresolvedXsiTypeName, elementName,
m_currentItem.getLocation()));
+ }
+
// reset processContents in the child, if we relaxed it above, signalled
by non-null savedPC
if (savedPC != null)
m_currentPSVI.setProcessContents(savedPC); // actually a different
ModelPSVI than the one we set lax above