MCPcopy Index your code
hub / github.com/apache/tomcat / generateXmlProlog

Method generateXmlProlog

java/org/apache/jasper/compiler/Generator.java:825–859  ·  view source on GitHub ↗

Generates an XML Prolog, which includes an XML declaration and an XML doctype declaration.

(Node.Nodes page)

Source from the content-addressed store, hash-verified

823 * Generates an XML Prolog, which includes an XML declaration and an XML doctype declaration.
824 */
825 private void generateXmlProlog(Node.Nodes page) {
826
827 /*
828 * An XML declaration is generated under the following conditions: a) 'omit-xml-declaration' attribute of
829 * <jsp:output> action is set to "no" or "false"; b) JSP document without a <jsp:root>.
830 */
831 String omitXmlDecl = pageInfo.getOmitXmlDecl();
832 if ((omitXmlDecl != null && !JspUtil.booleanValue(omitXmlDecl)) ||
833 (omitXmlDecl == null && page.getRoot().isXmlSyntax() && !pageInfo.hasJspRoot() && !ctxt.isTagFile())) {
834 String cType = pageInfo.getContentType();
835 String charSet = cType.substring(cType.indexOf("charset=") + 8);
836 out.printil("out.write(\"<?xml version=\\\"1.0\\\" encoding=\\\"" + charSet + "\\\"?>\\n\");");
837 }
838
839 /*
840 * Output a DOCTYPE declaration if the doctype-root-element appears. If doctype-public appears: <!DOCTYPE name
841 * PUBLIC "doctypePublic" "doctypeSystem"> else <!DOCTYPE name SYSTEM "doctypeSystem" >
842 */
843 String doctypeName = pageInfo.getDoctypeName();
844 if (doctypeName != null) {
845 String doctypePublic = pageInfo.getDoctypePublic();
846 String doctypeSystem = pageInfo.getDoctypeSystem();
847 out.printin("out.write(\"<!DOCTYPE ");
848 out.print(doctypeName);
849 if (doctypePublic == null) {
850 out.print(" SYSTEM \\\"");
851 } else {
852 out.print(" PUBLIC \\\"");
853 out.print(doctypePublic);
854 out.print("\\\" \\\"");
855 }
856 out.print(doctypeSystem);
857 out.println("\\\">\\n\");");
858 }
859 }
860
861 /**
862 * A visitor that generates codes for the elements in the page.

Callers 1

generateMethod · 0.95

Calls 15

booleanValueMethod · 0.95
getOmitXmlDeclMethod · 0.80
isXmlSyntaxMethod · 0.80
getDoctypeNameMethod · 0.80
getDoctypePublicMethod · 0.80
getDoctypeSystemMethod · 0.80
printinMethod · 0.80
isTagFileMethod · 0.65
getContentTypeMethod · 0.65
getRootMethod · 0.45
hasJspRootMethod · 0.45
indexOfMethod · 0.45

Tested by

no test coverage detected