Search in sources :

Example 1 with AbstractValidationException

use of com.thaiopensource.relaxng.exceptions.AbstractValidationException in project validator by validator.

the class MessageEmitterAdapter method elaboration.

private void elaboration(Exception e) throws SAXException {
    if (!(e instanceof AbstractValidationException || e instanceof VnuBadAttrValueException || e instanceof VnuBadElementNameException || e instanceof DatatypeMismatchException)) {
        return;
    }
    if (e instanceof ImpossibleAttributeIgnoredException) {
        ImpossibleAttributeIgnoredException ex = (ImpossibleAttributeIgnoredException) e;
        Name elt = ex.getCurrentElement();
        elaborateElementSpecificAttributes(elt, ex.getAttributeName());
    } else if (e instanceof OnlyTextNotAllowedException) {
        OnlyTextNotAllowedException ex = (OnlyTextNotAllowedException) e;
        Name elt = ex.getCurrentElement();
        elaborateContentModel(elt);
    } else if (e instanceof OutOfContextElementException) {
        OutOfContextElementException ex = (OutOfContextElementException) e;
        Name parent = ex.getParent();
        Name child = ex.getCurrentElement();
        elaborateContentModelandContext(parent, child);
    } else if (e instanceof RequiredAttributesMissingException) {
        RequiredAttributesMissingException ex = (RequiredAttributesMissingException) e;
        Name elt = ex.getCurrentElement();
        elaborateElementSpecificAttributes(elt);
    } else if (e instanceof RequiredAttributesMissingOneOfException) {
        RequiredAttributesMissingOneOfException ex = (RequiredAttributesMissingOneOfException) e;
        Name elt = ex.getCurrentElement();
        elaborateElementSpecificAttributes(elt);
    } else if (e instanceof RequiredElementsMissingException) {
        RequiredElementsMissingException ex = (RequiredElementsMissingException) e;
        Name elt = ex.getParent();
        elaborateContentModel(elt);
    } else if (e instanceof RequiredElementsMissingOneOfException) {
        RequiredElementsMissingOneOfException ex = (RequiredElementsMissingOneOfException) e;
        Name elt = ex.getParent();
        elaborateContentModel(elt);
    } else if (e instanceof StringNotAllowedException) {
        StringNotAllowedException ex = (StringNotAllowedException) e;
        Name elt = ex.getCurrentElement();
        elaborateContentModel(elt);
    } else if (e instanceof TextNotAllowedException) {
        TextNotAllowedException ex = (TextNotAllowedException) e;
        Name elt = ex.getCurrentElement();
        elaborateContentModel(elt);
    } else if (e instanceof UnfinishedElementException) {
        UnfinishedElementException ex = (UnfinishedElementException) e;
        Name elt = ex.getCurrentElement();
        elaborateContentModel(elt);
    } else if (e instanceof UnfinishedElementOneOfException) {
        UnfinishedElementOneOfException ex = (UnfinishedElementOneOfException) e;
        Name elt = ex.getCurrentElement();
        elaborateContentModel(elt);
    } else if (e instanceof UnknownElementException) {
        UnknownElementException ex = (UnknownElementException) e;
        Name elt = ex.getParent();
        elaborateContentModel(elt);
    } else if (e instanceof BadAttributeValueException) {
        BadAttributeValueException ex = (BadAttributeValueException) e;
        Map<String, DatatypeException> map = ex.getExceptions();
        elaborateDatatypes(map);
    } else if (e instanceof VnuBadAttrValueException) {
        VnuBadAttrValueException ex = (VnuBadAttrValueException) e;
        Map<String, DatatypeException> map = ex.getExceptions();
        elaborateDatatypes(map);
    } else if (e instanceof VnuBadElementNameException) {
        VnuBadElementNameException ex = (VnuBadElementNameException) e;
        Map<String, DatatypeException> map = ex.getExceptions();
        elaborateDatatypes(map);
    } else if (e instanceof DatatypeMismatchException) {
        DatatypeMismatchException ex = (DatatypeMismatchException) e;
        Map<String, DatatypeException> map = ex.getExceptions();
        elaborateDatatypes(map);
    } else if (e instanceof StringNotAllowedException) {
        StringNotAllowedException ex = (StringNotAllowedException) e;
        Map<String, DatatypeException> map = ex.getExceptions();
        elaborateDatatypes(map);
    }
}
Also used : RequiredAttributesMissingException(com.thaiopensource.relaxng.exceptions.RequiredAttributesMissingException) RequiredAttributesMissingOneOfException(com.thaiopensource.relaxng.exceptions.RequiredAttributesMissingOneOfException) RequiredElementsMissingException(com.thaiopensource.relaxng.exceptions.RequiredElementsMissingException) RequiredElementsMissingOneOfException(com.thaiopensource.relaxng.exceptions.RequiredElementsMissingOneOfException) UnfinishedElementException(com.thaiopensource.relaxng.exceptions.UnfinishedElementException) OutOfContextElementException(com.thaiopensource.relaxng.exceptions.OutOfContextElementException) StringNotAllowedException(com.thaiopensource.relaxng.exceptions.StringNotAllowedException) UnfinishedElementOneOfException(com.thaiopensource.relaxng.exceptions.UnfinishedElementOneOfException) VnuBadElementNameException(nu.validator.checker.VnuBadElementNameException) DatatypeMismatchException(nu.validator.checker.DatatypeMismatchException) Name(com.thaiopensource.xml.util.Name) OnlyTextNotAllowedException(com.thaiopensource.relaxng.exceptions.OnlyTextNotAllowedException) Html5DatatypeException(nu.validator.datatype.Html5DatatypeException) DatatypeException(org.relaxng.datatype.DatatypeException) AbstractValidationException(com.thaiopensource.relaxng.exceptions.AbstractValidationException) ImpossibleAttributeIgnoredException(com.thaiopensource.relaxng.exceptions.ImpossibleAttributeIgnoredException) BadAttributeValueException(com.thaiopensource.relaxng.exceptions.BadAttributeValueException) VnuBadAttrValueException(nu.validator.checker.VnuBadAttrValueException) UnknownElementException(com.thaiopensource.relaxng.exceptions.UnknownElementException) OnlyTextNotAllowedException(com.thaiopensource.relaxng.exceptions.OnlyTextNotAllowedException) TextNotAllowedException(com.thaiopensource.relaxng.exceptions.TextNotAllowedException) Map(java.util.Map) HashMap(java.util.HashMap) TreeMap(java.util.TreeMap)

Example 2 with AbstractValidationException

use of com.thaiopensource.relaxng.exceptions.AbstractValidationException in project validator by validator.

the class MessageEmitterAdapter method messageText.

/**
 * @param message
 * @throws SAXException
 */
private void messageText(Exception message) throws SAXException {
    if (message instanceof AbstractValidationException) {
        AbstractValidationException ave = (AbstractValidationException) message;
        rngMessageText(ave);
    } else if (message instanceof VnuBadAttrValueException) {
        VnuBadAttrValueException e = (VnuBadAttrValueException) message;
        vnuBadAttrValueMessageText(e);
    } else if (message instanceof VnuBadElementNameException) {
        VnuBadElementNameException e = (VnuBadElementNameException) message;
        vnuElementNameMessageText(e);
    } else {
        String msg = message.getMessage();
        if (msg != null) {
            MessageTextHandler messageTextHandler = emitter.startText();
            if (messageTextHandler != null) {
                emitStringWithQurlyQuotes(messageTextHandler, msg);
            }
            emitter.endText();
        }
    }
}
Also used : AbstractValidationException(com.thaiopensource.relaxng.exceptions.AbstractValidationException) VnuBadAttrValueException(nu.validator.checker.VnuBadAttrValueException) VnuBadElementNameException(nu.validator.checker.VnuBadElementNameException)

Aggregations

AbstractValidationException (com.thaiopensource.relaxng.exceptions.AbstractValidationException)2 VnuBadAttrValueException (nu.validator.checker.VnuBadAttrValueException)2 VnuBadElementNameException (nu.validator.checker.VnuBadElementNameException)2 BadAttributeValueException (com.thaiopensource.relaxng.exceptions.BadAttributeValueException)1 ImpossibleAttributeIgnoredException (com.thaiopensource.relaxng.exceptions.ImpossibleAttributeIgnoredException)1 OnlyTextNotAllowedException (com.thaiopensource.relaxng.exceptions.OnlyTextNotAllowedException)1 OutOfContextElementException (com.thaiopensource.relaxng.exceptions.OutOfContextElementException)1 RequiredAttributesMissingException (com.thaiopensource.relaxng.exceptions.RequiredAttributesMissingException)1 RequiredAttributesMissingOneOfException (com.thaiopensource.relaxng.exceptions.RequiredAttributesMissingOneOfException)1 RequiredElementsMissingException (com.thaiopensource.relaxng.exceptions.RequiredElementsMissingException)1 RequiredElementsMissingOneOfException (com.thaiopensource.relaxng.exceptions.RequiredElementsMissingOneOfException)1 StringNotAllowedException (com.thaiopensource.relaxng.exceptions.StringNotAllowedException)1 TextNotAllowedException (com.thaiopensource.relaxng.exceptions.TextNotAllowedException)1 UnfinishedElementException (com.thaiopensource.relaxng.exceptions.UnfinishedElementException)1 UnfinishedElementOneOfException (com.thaiopensource.relaxng.exceptions.UnfinishedElementOneOfException)1 UnknownElementException (com.thaiopensource.relaxng.exceptions.UnknownElementException)1 Name (com.thaiopensource.xml.util.Name)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 TreeMap (java.util.TreeMap)1