Generates an XML Prolog, which includes an XML declaration and an XML doctype declaration.
(Node.Nodes page)
| 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. |
no test coverage detected