You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ki...@apache.org on 2001/10/09 19:53:29 UTC

cvs commit: jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/compiler XmlOutputter.java

kinman      01/10/09 10:53:29

  Modified:    jasper/src/share/org/apache/jasper/compiler
                        XmlOutputter.java
  Log:
  PR: 4022
  
  - If there are more than one "import" specification for <% page > directive,
  - make sure that the translated XML document has only one import specified,
  - with its values set to the import expressions, separated by commas.
  
  Revision  Changes    Path
  1.17      +30 -4     jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/compiler/XmlOutputter.java
  
  Index: XmlOutputter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/compiler/XmlOutputter.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- XmlOutputter.java	2001/09/07 01:01:01	1.16
  +++ XmlOutputter.java	2001/10/09 17:53:29	1.17
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/compiler/XmlOutputter.java,v 1.16 2001/09/07 01:01:01 craigmcc Exp $
  - * $Revision: 1.16 $
  - * $Date: 2001/09/07 01:01:01 $
  + * $Header: /home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/compiler/XmlOutputter.java,v 1.17 2001/10/09 17:53:29 kinman Exp $
  + * $Revision: 1.17 $
  + * $Date: 2001/10/09 17:53:29 $
    *
    * ====================================================================
    *
  @@ -193,7 +193,9 @@
        * [StringBuffer is an argument so we can reuse the method
        * to generate the "header" in a different stream. The header
        * can only be generated once we've processed all parts
  -     * of the translation unit]
  +     * of the translation unit].
  +     * Since XML allows only one value be specified for an attribute,
  +     * page.import directives are accumlated and outputted as one.
        */
       void append(String tag, Attributes attrs, StringBuffer buff, boolean hasNoBody) {
           buff.append("<").append(tag);
  @@ -203,12 +205,36 @@
               else buff.append(">");
           } else {
               buff.append("\n");
  +            boolean pageImportSeen = false;
               int attrsLength = attrs.getLength();
               for (int i = 0; i < attrsLength; i++) {
  +                // Skip page.import directive here
                   String name = attrs.getQName(i);
  +                if (tag.equals("jsp:directive.page") && name.equals("import")) {
  +                    pageImportSeen = true;
  +                    continue;
  +                }
                   String value = attrs.getValue(i);
                   buff.append("  ").append(name).append("=\"");
   		buff.append(JspUtil.getExprInXml(value)).append("\"\n");
  +            }
  +            if (pageImportSeen) {
  +                // Values of page.import are now put together, spearated by ,'s
  +                boolean first = true;
  +                for (int i = 0; i < attrsLength; i++) {
  +                    String name = attrs.getQName(i);
  +                    if (!tag.equals("jsp:directive.page") || !name.equals("import"))
  +                         continue;
  +                    String value = attrs.getValue(i);
  +                    if (first) {
  +                        first = false;
  +                        buff.append("  import=\"");
  +                    }
  +                    else
  +                        buff.append(",");
  +                    buff.append(JspUtil.getExprInXml(value));
  +                }
  +                buff.append("\"\n");
               }
               if (hasNoBody)
                   buff.append("/>\n");