garyp       01/06/14 23:18:18

  Modified:    java/src/org/apache/xalan/serialize SerializerToHTML.java
               java/src/org/apache/xalan/templates OutputProperties.java
                        output_html.properties
  Log:
  Enhancement to implement xalan:omit-meta-tag="yes" on the xsl:output element. 
 When specified,  no META tag will be created with the HTML output method, even 
if one should be created according to the XSLT
  Recommendation.
  This clears bug 1310 (http://nagoya.apache.org/bugzilla/show_bug.cgi?id=1310).
  Also, implemented fix in bug 2000 
(http://nagoya.apache.org/bugzilla/show_bug.cgi?id=2000) to avoid changing 
OutputProperties out from under the Enumeration.
  We now enumerate a clone of the OutputProperties.
  Retrofitted to the DTM merge.
  
  Revision  Changes    Path
  1.5       +39 -9     
xml-xalan/java/src/org/apache/xalan/serialize/SerializerToHTML.java
  
  Index: SerializerToHTML.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/serialize/SerializerToHTML.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- SerializerToHTML.java     2001/06/12 19:14:54     1.4
  +++ SerializerToHTML.java     2001/06/15 06:18:16     1.5
  @@ -382,6 +382,9 @@
     /** True if URLs should be specially escaped with the %xx form. */
     private boolean m_specialEscapeURLs = true;
   
  +  /** True if the META tag should be omitted. */
  +  private boolean m_omitMetaTag = false;
  +
     /**
      * Tells if the formatter should use special URL escaping.
      *
  @@ -393,6 +396,16 @@
     }
   
     /**
  +   * Tells if the formatter should omit the META tag.
  +   *
  +   * @param bool True if the META tag should be omitted.
  +   */
  +  public void setOmitMetaTag(boolean bool)
  +  {
  +    m_omitMetaTag = bool;
  +  }
  +
  +  /**
      * Specifies an output format for this serializer. It the
      * serializer has already been associated with an output format,
      * it will switch to the new format. This method should not be
  @@ -407,6 +420,10 @@
       m_specialEscapeURLs =
         
OutputProperties.getBooleanProperty(OutputProperties.S_USE_URL_ESCAPING,
                                             format);
  +
  +    m_omitMetaTag =
  +      OutputProperties.getBooleanProperty(OutputProperties.S_OMIT_META_TAG,
  +                                          format);
                               
       super.setOutputFormat(format);
     }
  @@ -422,6 +439,16 @@
     }
   
     /**
  +   * Tells if the formatter should omit the META tag.
  +   *
  +   * @return True if the META tag should be omitted.
  +   */
  +  public boolean getOmitMetaTag()
  +  {
  +    return m_omitMetaTag;
  +  }
  +
  +  /**
      * Get a description of the given element.
      *
      * @param name non-null name of element, case insensitive.
  @@ -587,18 +614,21 @@
       {
         writeParentTagEnd();
   
  -      if (m_doIndent)
  -        indent(m_currentIndent);
  +      if (!m_omitMetaTag)
  +      {
  +        if (m_doIndent)
  +          indent(m_currentIndent);
   
  -      accum(
  -        "<META http-equiv=\"Content-Type\" content=\"text/html; charset=");
  +        accum(
  +          "<META http-equiv=\"Content-Type\" content=\"text/html; charset=");
   
  -      // String encoding = 
Encodings.getMimeEncoding(m_encoding).toLowerCase();
  -      String encoding = Encodings.getMimeEncoding(m_encoding);
  +        // String encoding = 
Encodings.getMimeEncoding(m_encoding).toLowerCase();
  +        String encoding = Encodings.getMimeEncoding(m_encoding);
   
  -      accum(encoding);
  -      accum('"');
  -      accum('>');
  +        accum(encoding);
  +        accum('"');
  +        accum('>');
  +      }
       }
     }
   
  
  
  
  1.19      +18 -1     
xml-xalan/java/src/org/apache/xalan/templates/OutputProperties.java
  
  Index: OutputProperties.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/templates/OutputProperties.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- OutputProperties.java     2001/06/12 19:15:13     1.18
  +++ OutputProperties.java     2001/06/15 06:18:16     1.19
  @@ -237,7 +237,18 @@
       // Note that we're working at the HashTable level here, 
       // and not at the Properties level!  This is important 
       // because we don't want to modify the default properties.
  -    Enumeration keys = props.keys();
  +    // NB: If fixupPropertyString ends up changing the property
  +    // name or value, we need to remove the old key and re-add
  +    // with the new key and value.  However, then our Enumeration
  +    // could lose its place in the HashTable.  So, we first
  +    // clone the HashTable and enumerate over that since the
  +    // clone will not change.  When we migrate to Collections,
  +    // this code should be revisited and cleaned up to use
  +    // an Iterator which may (or may not) alleviate the need for
  +    // the clone.  Many thanks to Padraig O'hIceadha
  +    // <[EMAIL PROTECTED]> for finding this problem.  Bugzilla 2000.
  +
  +    Enumeration keys = ((Properties) props.clone()).keys();
       while(keys.hasMoreElements())
       {
         String key = (String)keys.nextElement();
  @@ -1040,6 +1051,12 @@
      *  use %xx escaping. */
     public static String S_USE_URL_ESCAPING =
       S_BUILTIN_EXTENSIONS_UNIVERSAL+"use-url-escaping";
  +
  +  /** Use a value of "yes" if the META tag should be omitted where it would
  +   *  otherwise be supplied.
  +   */
  +  public static String S_OMIT_META_TAG =
  +    S_BUILTIN_EXTENSIONS_UNIVERSAL+"omit-meta-tag";
   
     /** The default properties of all output files. */
     private static Properties m_xml_properties = null;
  
  
  
  1.7       +2 -1      
xml-xalan/java/src/org/apache/xalan/templates/output_html.properties
  
  Index: output_html.properties
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/templates/output_html.properties,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- output_html.properties    2001/06/12 19:15:14     1.6
  +++ output_html.properties    2001/06/15 06:18:17     1.7
  @@ -21,4 +21,5 @@
   {http\u003a//xml.apache.org/xslt}indent-amount=0
   
{http\u003a//xml.apache.org/xslt}content-handler=org.apache.xalan.serialize.SerializerToHTML
   {http\u003a//xml.apache.org/xslt}entities=HTMLEntities.res
  -{http\u003a//xml.apache.org/xslt}use-url-escaping=yes
  \ No newline at end of file
  +{http\u003a//xml.apache.org/xslt}use-url-escaping=yes
  +{http\u003a//xml.apache.org/xslt}omit-meta-tag=no
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to