jp.terasoluna.fw.oxm.xsd.xerces
クラス XMLSchemaValidatorEx

java.lang.Object
  上位を拡張 org.apache.xerces.impl.xs.XMLSchemaValidator
      上位を拡張 jp.terasoluna.fw.oxm.xsd.xerces.XMLSchemaValidatorEx
すべての実装されたインタフェース:
org.apache.xerces.impl.RevalidationHandler, org.apache.xerces.impl.xs.identity.FieldActivator, org.apache.xerces.xni.parser.XMLComponent, org.apache.xerces.xni.parser.XMLDocumentFilter, org.apache.xerces.xni.parser.XMLDocumentSource, org.apache.xerces.xni.XMLDocumentHandler

public class XMLSchemaValidatorEx
extends org.apache.xerces.impl.xs.XMLSchemaValidator

解析中のXMLの要素情報をXMLErrorReporterExのスタックに格納するために、XMLSchemaValidatorの拡張を行ったクラス。

要素の開始時に、要素名にインデックスを付加した文字列を、XMLErrorReporterExのスタックにプッシュする。
要素の終了時に、スタックからポップする。
要素の情報が入ったスタックを利用することで、エラーが発生した箇所を特定することができる。

XMLの要素情報がどのようにスタックに格納されるかを以下に記す。

【XMLデータのサンプル】

 <sample-dto>
   <param-a>
     <param-b>
       <param-c>...</param-c>
       <param-d>...</param-d>
     </param-b>
   </param-a>
   <param-e>
     <param-f>...</param-f>
   </param-e>
   <param-e>
     <param-f>...</param-f>
   </param-e>
 </sample-dto>
 

【上記のXMLデータが入力された場合の、スタックの状態の変化】

 
  1. (空)
  2. {sample-dto[0]}
  3. {sample-dto[0]}{param-a[0]}
  4. {sample-dto[0]}{param-a[0]}{param-b[0]}
  5. {sample-dto[0]}{param-a[0]}{param-b[0]}{param-c[0]}
  6. {sample-dto[0]}{param-a[0]}{param-b[0]}
  7. {sample-dto[0]}{param-a[0]}{param-b[0]}{param-d[0]}
  8. {sample-dto[0]}{param-a[0]}{param-b[0]}
  9. {sample-dto[0]}{param-a[0]}
  10. {sample-dto[0]}
  11. {sample-dto[0]}{param-e[0]}
  12. {sample-dto[0]}{param-e[0]}{param-f[0]}
  13. {sample-dto[0]}{param-e[0]}
  14. {sample-dto[0]}
  15. {sample-dto[0]}{param-e[1]}
  16. {sample-dto[0]}{param-e[1]}{param-f[0]}
  17. {sample-dto[0]}{param-e[1]}
  18. {sample-dto[0]}
  19. (空)

例えば、上記サンプルでparam-c要素に不正な値が入っていた場合、エラー発生時のスタックの状態は以下の通りである。
スタックの状態:{sample-dto[0]}{param-a[0]}{param-b[0]}{param-c[0]}

XMLErrorReporterExは以下のようにスタックの値をドット(".")で連結して、エラーのフィールド情報を生成する。
フィールド情報:sample-dto[0].param-a[0].param-b[0].param-c[0]

解析中のXMLの属性の情報は特定することができない。
エラーが発生した属性名はエラー情報の置換文字列から取得することができる。
詳細は、XMLErrorReporterExを参照すること。

関連項目:
XMLErrorReporterEx

入れ子のクラスの概要
 
クラス org.apache.xerces.impl.xs.XMLSchemaValidator から継承された入れ子のクラス/インタフェース
org.apache.xerces.impl.xs.XMLSchemaValidator.KeyRefValueStore, org.apache.xerces.impl.xs.XMLSchemaValidator.KeyValueStore, org.apache.xerces.impl.xs.XMLSchemaValidator.LocalIDKey, org.apache.xerces.impl.xs.XMLSchemaValidator.ShortVector, org.apache.xerces.impl.xs.XMLSchemaValidator.UniqueValueStore, org.apache.xerces.impl.xs.XMLSchemaValidator.ValueStoreBase, org.apache.xerces.impl.xs.XMLSchemaValidator.ValueStoreCache, org.apache.xerces.impl.xs.XMLSchemaValidator.XPathMatcherStack, org.apache.xerces.impl.xs.XMLSchemaValidator.XSIErrorReporter
 
フィールドの概要
private static org.apache.commons.logging.Log log
          ログクラス。
private  XMLErrorReporterEx reporter
          XMLErrorReporterExインスタンス
 
クラス org.apache.xerces.impl.xs.XMLSchemaValidator から継承されたフィールド
ALLOW_JAVA_ENCODINGS, CONTINUE_AFTER_FATAL_ERROR, DYNAMIC_VALIDATION, ENTITY_MANAGER, ENTITY_RESOLVER, ERROR_REPORTER, fAugmentations, fAugPSVI, fCurrentPSVI, fDefaultValue, fDocumentHandler, fDocumentSource, fDoValidation, fDynamicValidation, fEntityRef, fEntityResolver, fExternalNoNamespaceSchema, fExternalSchemas, fFullChecking, fGrammarPool, fIdConstraint, fInCDATA, fJaxpSchemaSource, fLocationPairs, fMatcherStack, fMayMatchFieldMap, fNormalizeData, fSchemaDynamicValidation, fSchemaElementDefault, fSymbolTable, fUseGrammarPoolOnly, fValidationManager, fValidationState, fValueStoreCache, fXSDDescription, fXSIErrorReporter, GENERATE_SYNTHETIC_ANNOTATIONS, HONOUR_ALL_SCHEMALOCATIONS, ID_CONSTRAINT_NUM, ID_IDREF_CHECKING, IDENTITY_CONSTRAINT_CHECKING, IGNORE_XSI_TYPE, JAXP_SCHEMA_LANGUAGE, JAXP_SCHEMA_SOURCE, NORMALIZE_DATA, PARSER_SETTINGS, ROOT_TYPE_DEF, SCHEMA_AUGMENT_PSVI, SCHEMA_ELEMENT_DEFAULT, SCHEMA_FULL_CHECKING, SCHEMA_LOCATION, SCHEMA_NONS_LOCATION, SCHEMA_VALIDATION, STANDARD_URI_CONFORMANT_FEATURE, SYMBOL_TABLE, UNPARSED_ENTITY_CHECKING, USE_GRAMMAR_POOL_ONLY, VALIDATE_ANNOTATIONS, VALIDATION, VALIDATION_MANAGER, XMLGRAMMAR_POOL
 
コンストラクタの概要
XMLSchemaValidatorEx(XMLErrorReporterEx reporter)
          コンストラクタ
 
メソッドの概要
 void endElement(org.apache.xerces.xni.QName element, org.apache.xerces.xni.Augmentations augs)
          要素の終了時に、XMLErrorReporterExのスタックからポップする。
 void startElement(org.apache.xerces.xni.QName element, org.apache.xerces.xni.XMLAttributes attributes, org.apache.xerces.xni.Augmentations augs)
          要素の開始時に、解析中のフィールド情報をXMLErrorReporterExのスタックにプッシュする。
 
クラス org.apache.xerces.impl.xs.XMLSchemaValidator から継承されたメソッド
activateField, characterData, characters, comment, doctypeDecl, elementDefault, emptyElement, endCDATA, endDocument, endGeneralEntity, endValueScopeFor, getDocumentHandler, getDocumentSource, getFeatureDefault, getPropertyDefault, getRecognizedFeatures, getRecognizedProperties, ignorableWhitespace, mayMatch, processingInstruction, reset, setDocumentHandler, setDocumentSource, setFeature, setMayMatch, setProperty, startCDATA, startDocument, startGeneralEntity, startValueScopeFor, textDecl, xmlDecl
 
クラス java.lang.Object から継承されたメソッド
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

フィールドの詳細

log

private static org.apache.commons.logging.Log log
ログクラス。


reporter

private XMLErrorReporterEx reporter
XMLErrorReporterExインスタンス

コンストラクタの詳細

XMLSchemaValidatorEx

public XMLSchemaValidatorEx(XMLErrorReporterEx reporter)
コンストラクタ

パラメータ:
reporter - XMLErrorReporterExインスタンス
メソッドの詳細

startElement

public void startElement(org.apache.xerces.xni.QName element,
                         org.apache.xerces.xni.XMLAttributes attributes,
                         org.apache.xerces.xni.Augmentations augs)
                  throws org.apache.xerces.xni.XNIException
要素の開始時に、解析中のフィールド情報をXMLErrorReporterExのスタックにプッシュする。

定義:
インタフェース org.apache.xerces.xni.XMLDocumentHandler 内の startElement
オーバーライド:
クラス org.apache.xerces.impl.xs.XMLSchemaValidator 内の startElement
パラメータ:
element - XML要素の情報を持つインスタンス
attributes - XML属性の情報を持つインスタンス
augs - 妥当性検証の結果が格納されるインスタンス
例外:
org.apache.xerces.xni.XNIException - パーサ内で発生する実行時例外

endElement

public void endElement(org.apache.xerces.xni.QName element,
                       org.apache.xerces.xni.Augmentations augs)
                throws org.apache.xerces.xni.XNIException
要素の終了時に、XMLErrorReporterExのスタックからポップする。

定義:
インタフェース org.apache.xerces.xni.XMLDocumentHandler 内の endElement
オーバーライド:
クラス org.apache.xerces.impl.xs.XMLSchemaValidator 内の endElement
パラメータ:
element - XML要素の情報を持つインスタンス
augs - 妥当性検証の結果が格納されるインスタンス
例外:
org.apache.xerces.xni.XNIException - パーサ内で発生する実行時例外