luehe 2002/11/07 10:34:19
Modified:jasper2/src/share/org/apache/jasper/compiler
PageDataImpl.java Validator.java
Log:
Append tag directive (containing single 'pageEncoding' attribute whose
value is hard-coded to UTF-8) to XML view of tag files, and suppress
'pageEncoding' attribute in any existing tag directives.
Revision ChangesPath
1.17 +98 -29
jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/PageDataImpl.java
Index: PageDataImpl.java
===
RCS file:
/home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/PageDataImpl.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- PageDataImpl.java 6 Nov 2002 20:58:10 - 1.16
+++ PageDataImpl.java 7 Nov 2002 18:34:19 - 1.17
-120,7 +120,7
*
* param page the page nodes from which to generate the XML view
*/
-public PageDataImpl(Node.Nodes page, PageInfo pageInfo)
+public PageDataImpl(Node.Nodes page, Compiler compiler)
throws JasperException {
// First pass
-131,7 +131,7
// Second pass
buf = new StringBuffer();
SecondPassVisitor secondPassVisitor
- = new SecondPassVisitor(page.getRoot(), buf, pageInfo);
+ = new SecondPassVisitor(page.getRoot(), buf, compiler);
page.visit(secondPassVisitor);
}
-237,7 +237,7
private Node.Root root;
private StringBuffer buf;
- private PageInfo pageInfo;
+ private Compiler compiler;
// current jsp:id attribute value
private int jspId;
-246,10 +246,10
* Constructor
*/
public SecondPassVisitor(Node.Root root, StringBuffer buf,
- PageInfo pageInfo) {
+ Compiler compiler) {
this.root = root;
this.buf = buf;
- this.pageInfo = pageInfo;
+ this.compiler = compiler;
}
/*
-371,7 +371,7
}
public void visit(Node.TagDirective n) throws JasperException {
- appendTag(JSP_TAG_DIRECTIVE, n.getAttributes(), null, null);
+ appendTagDirective(n);
}
public void visit(Node.AttributeDirective n) throws JasperException {
-408,7 +408,11
if (tag.equals(JSP_ROOT) || body != null || text != null) {
buf.append(\n);
if (tag.equals(JSP_ROOT)) {
- appendPageDirective();
+ if (compiler.getCompilationContext().isTagFile()) {
+ appendTagDirective();
+ } else {
+ appendPageDirective();
+ }
}
if (body != null) {
body.visit(this);
-430,9 +434,27
* document, and since XML allows only single-value attributes,
* the values of multiple import attributes must be combined into one,
* separated by comma.
+ *
+ * If the given page directive contains just 'contentType' and/or
+ * 'pageEncoding' attributes, we ignore it, as we've already appended
+ * a page directive containing just these two attributes.
*/
private void appendPageDirective(Node.PageDirective pageDir) {
+ boolean append = false;
Attributes attrs = pageDir.getAttributes();
+ int len = attrs.getLength();
+ for (int i=0; ilen; i++) {
+ String attrName = attrs.getQName(i);
+ if (!pageEncoding.equals(attrName)
+ !contentType.equals(attrName)) {
+ append = true;
+ break;
+ }
+ }
+ if (!append) {
+ return;
+ }
+
buf.append().append(JSP_PAGE_DIRECTIVE);
buf.append(\n);
-441,7 +463,6
buf.append(jspId++).append(\\n);
// append remaining attributes
- int len = attrs.getLength();
for (int i=0; ilen; i++) {
String attrName = attrs.getQName(i);
if (import.equals(attrName) || contentType.equals(attrName)
-449,7 +470,7
/*
* Page directive's 'import' attribute is considered
* further down, and its 'pageEncoding' and 'contentType'
- * attributes are ignored, since we've already created
+ * attributes are ignored, since we've already appended
* a new page directive containing just these two
* attributes
*/
-477,6 +498,71
buf.append(/\n);
}
+ /*
+ * Appends a page directive with 'pageEncoding' and 'contentType'