// Flag set to delay incrementing tagDependentNesting until jsp:body
// is first encountered
private boolean tagDependentPending = false;
+ // Tag being parsed that should have an empty body
+ private Node tagEmptyBody = null;
/*
* Constructor
AttributesImpl nonTaglibAttrs = null;
AttributesImpl nonTaglibXmlnsAttrs = null;
+ checkEmptyBody();
+
processChars();
checkPrefixes(uri, qName, attrs);
if (scriptlessBodyNode == null
&& bodyType.equalsIgnoreCase(TagInfo.BODY_CONTENT_SCRIPTLESS)) {
scriptlessBodyNode = node;
- }
- else if (TagInfo.BODY_CONTENT_TAG_DEPENDENT.equalsIgnoreCase(bodyType)) {
+ } else if (TagInfo.BODY_CONTENT_TAG_DEPENDENT.equalsIgnoreCase(bodyType)) {
tagDependentPending = true;
+ } else if (TagInfo.BODY_CONTENT_EMPTY.equals(bodyType)) {
+ tagEmptyBody = node;
}
}
}
* @throws SAXException
*/
@Override
- public void characters(char[] buf, int offset, int len) {
+ public void characters(char[] buf, int offset, int len)
+ throws SAXException {
+
+ checkEmptyBody();
if (charBuffer == null) {
charBuffer = new StringBuilder();
public void endElement(String uri, String localName, String qName)
throws SAXException {
+ if (tagEmptyBody != null) {
+ tagEmptyBody = null;
+ }
+
processChars();
if (directivesOnly &&
*/
public void startCDATA() throws SAXException {
+ checkEmptyBody();
processChars(); // Flush char buffer and remove white spaces
startMark = new Mark(ctxt, path, locator.getLineNumber(),
locator.getColumnNumber());
return "";
}
+ private void checkEmptyBody() throws SAXException {
+ if (tagEmptyBody != null) {
+ throw new SAXParseException(Localizer.getMessage(
+ "jasper.error.emptybodycontent.nonempty",
+ tagEmptyBody.qName), locator);
+ }
+ }
/*
* Gets SAXParser.
*