use of org.relaxng.datatype.DatatypeException in project validator by validator.
the class MessageEmitterAdapter method vnuElementNameMessageText.
private void vnuElementNameMessageText(VnuBadElementNameException e) throws SAXException {
MessageTextHandler messageTextHandler = emitter.startText();
if (messageTextHandler != null) {
boolean isWarning = false;
Map<String, DatatypeException> datatypeErrors = e.getExceptions();
for (Map.Entry<String, DatatypeException> entry : datatypeErrors.entrySet()) {
DatatypeException dex = entry.getValue();
if (dex instanceof Html5DatatypeException) {
Html5DatatypeException ex5 = (Html5DatatypeException) dex;
if (ex5.isWarning()) {
isWarning = true;
}
}
}
if (isWarning) {
messageTextString(messageTextHandler, POTENTIALLY_BAD_ELEMENT_NAME, false);
} else {
messageTextString(messageTextHandler, BAD_ELEMENT_NAME, false);
}
messageTextString(messageTextHandler, SPACE, false);
codeString(messageTextHandler, e.getElementName());
emitDatatypeErrors(messageTextHandler, e.getExceptions());
}
emitter.endText();
}
use of org.relaxng.datatype.DatatypeException in project validator by validator.
the class Html5AttributeDatatypeBuilder method endElement.
@Override
public void endElement(String uri, String localName, String qName) throws SAXException {
switch(state) {
case AWAITING_WIKI_BODY:
case AWAITING_H3:
return;
case IN_HEADLINE:
if (depth == 0) {
try {
String name = stringBuilder.toString();
AbstractDatatype datatype = (AbstractDatatype) datatypeLibrary.createDatatype(name);
currentClass = datatype.getClass();
treeBuilder = new TreeBuilder(true, true);
treeBuilder.startElement(NS, "dt", "dt", EmptyAttributes.EMPTY_ATTRIBUTES);
String dt = "Syntax of " + datatype.getName() + ":";
treeBuilder.characters(dt.toCharArray(), 0, dt.length());
treeBuilder.endElement(NS, "dt", "dt");
state = State.AWAITING_P;
} catch (DatatypeException e) {
System.out.println(String.format("Warning: No datatype class for \"%s\".", stringBuilder.toString().trim()));
state = State.AWAITING_H3;
}
} else {
depth--;
}
return;
case AWAITING_P:
// should be impossible
state = State.AWAITING_H3;
return;
case IN_P:
if (depth == 0) {
treeBuilder.endElement(NS, "dt", "dt");
adviceByClass.put(currentClass, (DocumentFragment) treeBuilder.getRoot());
state = State.AWAITING_H3;
} else {
depth--;
treeBuilder.endElement(uri, localName, qName);
}
return;
}
}
use of org.relaxng.datatype.DatatypeException in project validator by validator.
the class BaseUriTracker method push.
private void push(String relative, String language, Direction dir) {
String lang = "";
boolean langSpecified = false;
if (language != null) {
try {
if (!"".equals(language)) {
Language.THE_INSTANCE.checkValid(language);
}
lang = language;
langSpecified = true;
} catch (DatatypeException e) {
}
}
Node curr = peek();
URL base = curr.currentAbsolute;
if (!langSpecified) {
lang = curr.lang;
}
boolean rtl;
switch(dir) {
case RTL:
rtl = true;
break;
case LTR:
rtl = false;
break;
default:
rtl = curr.rtl;
break;
}
if (relative == null) {
stack.addLast(new Node(base, null, lang, langSpecified, rtl));
} else {
URL newBase;
String ascii = null;
try {
if (base != null) {
try {
newBase = base.resolve(relative);
} catch (GalimatiasParseException e) {
newBase = base;
}
} else {
try {
newBase = URL.parse((new URI(ascii)).toString());
} catch (GalimatiasParseException e) {
newBase = null;
}
}
} catch (Exception e) {
newBase = base;
}
stack.addLast(new Node(newBase, ascii, lang, langSpecified, rtl));
}
}
Aggregations