in freemarker-docgen-core/src/main/java/org/freemarker/docgen/core/DocgenRestrictionsValidator.java [281:405]
private void startSupportedDocbook5Element(
String localName, Attributes atts) throws SAXException {
boolean isDocumentElem;
if (documentElementName == null) {
documentElementName = localName;
isDocumentElem = true;
} else {
isDocumentElem = false;
}
if (localName.equals(E_SECTION)) {
sectionNestingLevel++;
if (sectionNestingLevel > MAX_SECTION_NESTING_LEVEL) {
errorHandler.error(newSAXException(
"\"" + localName + "\" element nesting too deep. "
+ "The maximum supported is "
+ MAX_SECTION_NESTING_LEVEL
+ " levels. Hint: Use \"" + E_SIMPLESECT
+ "\" instead."));
}
} else if (localName.equals(E_PARA)) {
paraNestingLevel++;
} else if (localName.equals(E_ITEMIZEDLIST)
|| localName.equals(E_ORDEREDLIST)
|| localName.equals(E_PROGRAMLISTING)
|| localName.equals(E_MEDIAOBJECT)) {
checkNotInAPara(localName);
if (localName.equals(E_PROGRAMLISTING)) {
if (options.getProgramlistingRequiresLanguage()
&& atts.getValue("", A_LANGUAGE) == null) {
errorHandler.error(newSAXException(
"In this book, \"" + localName
+ "\" elements must have a \"" + A_LANGUAGE
+ "\" attribute. Hint: If the language is so "
+ "marginal that will not ever have syntax "
+ "highlighter anyway, use \"unknown\" as the "
+ "attribute value."));
}
if (options.getProgramlistingRequiresRole()
&& atts.getValue("", A_ROLE) == null) {
errorHandler.error(newSAXException("In this book, "
+ "\"" + localName + "\" elements "
+ "must have a \"" + A_ROLE + "\" attribute. "
+ "Hint: If none of the avialble roles fit, "
+ "use \"unspecified\" as the attribute value."
));
}
checkHasPrecedingParaInListitem(localName);
programlistingLineLength = 0;
programlistingNestingLevel++;
}
} else if (localName.equals(E_INFORMALTABLE)
|| localName.equals(E_TABLE)) {
checkNotInAPara(localName);
checkHasPrecedingParaInListitem(localName);
} else if (localName.equals(E_FOOTNOTE)) {
if (!paraNestingLevelsHiddenByFootnote.isEmpty()) {
errorHandler.error(newSAXException("\"" + localName
+ "\" inside another \"" + localName
+ "\" is not allowed."));
}
if (programlistingNestingLevel != 0) {
errorHandler.error(newSAXException("\"" + localName
+ "\" inside a \"" + E_PROGRAMLISTING
+ "\" is not allowed."));
}
paraNestingLevelsHiddenByFootnote.add(paraNestingLevel);
paraNestingLevel = 0;
programlistingNestingLevelsHiddenByFootnote.add(
programlistingNestingLevel);
programlistingNestingLevel = 0;
programlistingLineLengthHiddenByFootnote.add(
programlistingLineLength);
programlistingLineLength = 0;
} else if (localName.equals(E_ANCHOR)
|| localName.equals(E_INDEXTERM)) {
invisibleElementNestingLevel++;
} else if (isDocumentElem) {
String conformance = atts.getValue("", A_CONFORMANCE);
if (conformance == null) {
errorHandler.error(newSAXException("The \""
+ localName + "\" element must have a \""
+ A_CONFORMANCE + "\" attribute. Hint: "
+ "Add the attribute with value \""
+ AV_CONFORMANCE_DOCGEN + "\"."));
} else if (!conformance.equals(AV_CONFORMANCE_DOCGEN)) {
errorHandler.error(newSAXException("The value of the \""
+ A_CONFORMANCE + "\" attribute must be \""
+ AV_CONFORMANCE_DOCGEN + "\"."));
}
}
if (atts.getIndex(A_XML_ID) != -1
&& !ELEMENTS_ALLOW_ID.contains(localName)) {
errorHandler.error(newSAXException("The \"" + localName
+ "\" element can't have an \"" + A_XML_ID + "\" "
+ "attribute (" + A_XML_ID + "=\""
+ atts.getValue("xml:id") + "\"). (Hint: "
+ (localName.equals(E_TITLE)
? "Move the " + A_XML_ID + " over into the "
+ "element whose \"" + E_TITLE
+ "\" the element is."
: "Try moving the " + A_XML_ID
+ " higher in the element hierarchy.")
+ ")"));
}
if (atts.getIndex(A_XREFLABEL) != -1
&& !ELEMENTS_ALLOW_ID.contains(localName)) {
errorHandler.error(newSAXException("The \"" + localName
+ "\" element can't have an \"" + A_XREFLABEL
+ "\" attribute, because it couldn't have a \""
+ A_XML_ID + "\" attribute either, and hence it "
+ "couldn't be the target of a link. (Hint: "
+ (localName.equals(E_TITLE)
? "Move the \"" + A_XREFLABEL + "\" attribute "
+ "over into the element whose \"" + E_TITLE
+ "\" the element is."
: "Try moving the " + A_XREFLABEL
+ " higher in the element hierarchy.")
+ ")"));
}
}