📄 jspdocumentparser.java
字号:
/*
* See org.xml.sax.ext.LexicalHandler.
*/
public void startDTD(String name, String publicId, String systemId)
throws SAXException {
if (!isValidating) {
fatalError(ENABLE_DTD_VALIDATION_EXCEPTION);
}
inDTD = true;
}
/*
* See org.xml.sax.ext.LexicalHandler.
*/
public void endDTD() throws SAXException {
inDTD = false;
}
/*
* Receives notification of a non-recoverable error.
*/
public void fatalError(SAXParseException e) throws SAXException {
throw e;
}
/*
* Receives notification of a recoverable error.
*/
public void error(SAXParseException e) throws SAXException {
throw e;
}
/*
* Receives notification of the start of a Namespace mapping.
*/
public void startPrefixMapping(String prefix, String uri)
throws SAXException {
TagLibraryInfo taglibInfo;
if (directivesOnly && !(JSP_URI.equals(uri))) {
return;
}
try {
taglibInfo = getTaglibInfo(prefix, uri);
} catch (JasperException je) {
throw new SAXParseException(
Localizer.getMessage("jsp.error.could.not.add.taglibraries"),
locator,
je);
}
if (taglibInfo != null) {
if (pageInfo.getTaglib(uri) == null) {
pageInfo.addTaglib(uri, taglibInfo);
}
pageInfo.pushPrefixMapping(prefix, uri);
} else {
pageInfo.pushPrefixMapping(prefix, null);
}
}
/*
* Receives notification of the end of a Namespace mapping.
*/
public void endPrefixMapping(String prefix) throws SAXException {
if (directivesOnly) {
String uri = pageInfo.getURI(prefix);
if (!JSP_URI.equals(uri)) {
return;
}
}
pageInfo.popPrefixMapping(prefix);
}
//*********************************************************************
// Private utility methods
private Node parseStandardAction(
String qName,
String localName,
Attributes nonTaglibAttrs,
Attributes nonTaglibXmlnsAttrs,
Attributes taglibAttrs,
Mark start,
Node parent)
throws SAXException {
Node node = null;
if (localName.equals(ROOT_ACTION)) {
if (!(current instanceof Node.Root)) {
throw new SAXParseException(
Localizer.getMessage("jsp.error.nested_jsproot"),
locator);
}
node =
new Node.JspRoot(
qName,
nonTaglibAttrs,
nonTaglibXmlnsAttrs,
taglibAttrs,
start,
current);
if (isTop) {
pageInfo.setHasJspRoot(true);
}
} else if (localName.equals(PAGE_DIRECTIVE_ACTION)) {
if (isTagFile) {
throw new SAXParseException(
Localizer.getMessage(
"jsp.error.action.istagfile",
localName),
locator);
}
node =
new Node.PageDirective(
qName,
nonTaglibAttrs,
nonTaglibXmlnsAttrs,
taglibAttrs,
start,
current);
String imports = nonTaglibAttrs.getValue("import");
// There can only be one 'import' attribute per page directive
if (imports != null) {
((Node.PageDirective)node).addImport(imports);
}
} else if (localName.equals(INCLUDE_DIRECTIVE_ACTION)) {
node =
new Node.IncludeDirective(
qName,
nonTaglibAttrs,
nonTaglibXmlnsAttrs,
taglibAttrs,
start,
current);
processIncludeDirective(nonTaglibAttrs.getValue("file"), node);
} else if (localName.equals(DECLARATION_ACTION)) {
if (scriptlessBodyNode != null) {
// We're nested inside a node whose body is
// declared to be scriptless
throw new SAXParseException(
Localizer.getMessage(
"jsp.error.no.scriptlets",
localName),
locator);
}
node =
new Node.Declaration(
qName,
nonTaglibXmlnsAttrs,
taglibAttrs,
start,
current);
} else if (localName.equals(SCRIPTLET_ACTION)) {
if (scriptlessBodyNode != null) {
// We're nested inside a node whose body is
// declared to be scriptless
throw new SAXParseException(
Localizer.getMessage(
"jsp.error.no.scriptlets",
localName),
locator);
}
node =
new Node.Scriptlet(
qName,
nonTaglibXmlnsAttrs,
taglibAttrs,
start,
current);
} else if (localName.equals(EXPRESSION_ACTION)) {
if (scriptlessBodyNode != null) {
// We're nested inside a node whose body is
// declared to be scriptless
throw new SAXParseException(
Localizer.getMessage(
"jsp.error.no.scriptlets",
localName),
locator);
}
node =
new Node.Expression(
qName,
nonTaglibXmlnsAttrs,
taglibAttrs,
start,
current);
} else if (localName.equals(USE_BEAN_ACTION)) {
node =
new Node.UseBean(
qName,
nonTaglibAttrs,
nonTaglibXmlnsAttrs,
taglibAttrs,
start,
current);
} else if (localName.equals(SET_PROPERTY_ACTION)) {
node =
new Node.SetProperty(
qName,
nonTaglibAttrs,
nonTaglibXmlnsAttrs,
taglibAttrs,
start,
current);
} else if (localName.equals(GET_PROPERTY_ACTION)) {
node =
new Node.GetProperty(
qName,
nonTaglibAttrs,
nonTaglibXmlnsAttrs,
taglibAttrs,
start,
current);
} else if (localName.equals(INCLUDE_ACTION)) {
node =
new Node.IncludeAction(
qName,
nonTaglibAttrs,
nonTaglibXmlnsAttrs,
taglibAttrs,
start,
current);
} else if (localName.equals(FORWARD_ACTION)) {
node =
new Node.ForwardAction(
qName,
nonTaglibAttrs,
nonTaglibXmlnsAttrs,
taglibAttrs,
start,
current);
} else if (localName.equals(PARAM_ACTION)) {
node =
new Node.ParamAction(
qName,
nonTaglibAttrs,
nonTaglibXmlnsAttrs,
taglibAttrs,
start,
current);
} else if (localName.equals(PARAMS_ACTION)) {
node =
new Node.ParamsAction(
qName,
nonTaglibXmlnsAttrs,
taglibAttrs,
start,
current);
} else if (localName.equals(PLUGIN_ACTION)) {
node =
new Node.PlugIn(
qName,
nonTaglibAttrs,
nonTaglibXmlnsAttrs,
taglibAttrs,
start,
current);
} else if (localName.equals(TEXT_ACTION)) {
node =
new Node.JspText(
qName,
nonTaglibXmlnsAttrs,
taglibAttrs,
start,
current);
} else if (localName.equals(BODY_ACTION)) {
node =
new Node.JspBody(
qName,
nonTaglibXmlnsAttrs,
taglibAttrs,
start,
current);
} else if (localName.equals(ATTRIBUTE_ACTION)) {
node =
new Node.NamedAttribute(
qName,
nonTaglibAttrs,
nonTaglibXmlnsAttrs,
taglibAttrs,
start,
current);
} else if (localName.equals(OUTPUT_ACTION)) {
node =
new Node.JspOutput(
qName,
nonTaglibAttrs,
nonTaglibXmlnsAttrs,
taglibAttrs,
start,
current);
} else if (localName.equals(TAG_DIRECTIVE_ACTION)) {
if (!isTagFile) {
throw new SAXParseException(
Localizer.getMessage(
"jsp.error.action.isnottagfile",
localName),
locator);
}
node =
new Node.TagDirective(
qName,
nonTaglibAttrs,
nonTaglibXmlnsAttrs,
taglibAttrs,
start,
current);
String imports = nonTaglibAttrs.getValue("import");
// There can only be one 'import' attribute per tag directive
if (imports != null) {
((Node.TagDirective)node).addImport(imports);
}
} else if (localName.equals(ATTRIBUTE_DIRECTIVE_ACTION)) {
if (!isTagFile) {
throw new SAXParseException(
Localizer.getMessage(
"jsp.error.action.isnottagfile",
localName),
locator);
}
node =
new Node.AttributeDirective(
qName,
nonTaglibAttrs,
nonTaglibXmlnsAttrs,
taglibAttrs,
start,
current);
} else if (localName.equals(VARIABLE_DIRECTIVE_ACTION)) {
if (!isTagFile) {
throw new SAXParseException(
Localizer.getMessage(
"jsp.error.action.isnottagfile",
localName),
locator);
}
node =
new Node.VariableDirective(
qName,
nonTaglibAttrs,
nonTaglibXmlnsAttrs,
taglibAttrs,
start,
current);
} else if (localName.equals(INVOKE_ACTION)) {
if (!isTagFile) {
throw new SAXParseException(
Localizer.getMessage(
"jsp.error.action.isnottagfile",
localName),
locator);
}
node =
new Node.InvokeAction(
qName,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -