|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.merlotxml.util.xml.xerces.SchemaIdentityConstraintValidator
Validates Identity Constraints - Unique, Key and KeyRef - for XML Schema. Xerces validates these during initial parsing, but not dynamically. In other words, if a value changes that causes a duplicate Key Xerces won't pick this up.
The validation that Xerces does during parsing can be repeated by calling Document.normalizeDocument(), but this takes too much time, because the entire document is revalidated. Errors could be caught and linked to nodes using an org.w3c.dom.DOMErrorHandler. This approach works, but is too slow to do with each change in value.
This class implements the same functionality that Xerces uses during parsing, but in a dynamic way.
See org.apache.xerces.impl.xs.XMLSchemaValidator.ValueStoreCache
This class is instanciated from
parseValidXMLStream
Nested Class Summary | |
class |
SchemaIdentityConstraintValidator.DynamicValueStore
Similar to org.apache.xerces.impl.xs.XMLSchemaValidator.ValueStoreCache except that the Xerces ValueStores are not dynamic - they were intended to validate only once during parsing. |
Field Summary | |
protected int |
debugLevel
Utility to minimise the output during debugging. |
Constructor Summary | |
SchemaIdentityConstraintValidator(org.w3c.dom.Document document,
SchemaGrammarDocumentImpl grammarDocument)
Create and initialize this validator with the current value of each field in the document. |
Method Summary | |
protected void |
debug(int level,
java.lang.String msg)
Utility for debugging. |
java.lang.String |
getErrorMessage(FieldNode node)
Retrieves the current error message associated with this FieldNode. |
FieldNode[] |
getIdentityConstraintFieldNodePeers(FieldNode node)
Finds the FieldNodes for the other fields that form part of the same Key, KeyRef or Unique as this one. |
boolean |
getIsKeyRefField(GrammarSimpleType simpleType)
Used to determine is the field represented by this simpleType is of type KeyRef. |
FieldNode[][] |
getPossibleReferenceFieldNodes(FieldNode keyRefNode)
Gets the valid possible key nodes that this keyref node may refer to. |
org.w3c.dom.Element |
getSelectorElement(FieldNode fieldNode)
Follows the reverse of the Field's XPath to get back from the Field to the Selector element that served as the context element for the Field's XPath statement. |
void |
setValue(FieldNode node,
java.lang.String value)
Updates the value of this FieldNode in the value store and checks for duplicates. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected int debugLevel
Constructor Detail |
public SchemaIdentityConstraintValidator(org.w3c.dom.Document document, SchemaGrammarDocumentImpl grammarDocument)
Method Detail |
protected void debug(int level, java.lang.String msg)
level
- 0=no debugging, 1 little bit, 2 more, etc.msg
- The message to print.public void setValue(FieldNode node, java.lang.String value)
node
- The field for which the value is being set.value
- The new value.public java.lang.String getErrorMessage(FieldNode node)
node
-
public FieldNode[] getIdentityConstraintFieldNodePeers(FieldNode node)
node
- One of the fields that is part of the key.
public org.w3c.dom.Element getSelectorElement(FieldNode fieldNode)
fieldNode
- The field for which the selector is sought.public FieldNode[][] getPossibleReferenceFieldNodes(FieldNode keyRefNode)
keyRefNode
- A field in the key.
public boolean getIsKeyRefField(GrammarSimpleType simpleType)
simpleType
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |