You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by sb...@locus.apache.org on 2000/12/06 06:29:54 UTC

cvs commit: xml-xalan/java/src/org/apache/xalan/processor ProcessorOutputElem.java

sboag       00/12/05 21:29:54

  Modified:    java/src/org/apache/xalan/processor ProcessorOutputElem.java
  Log:
  Changes for OutputProperties.  Use class as the setter methods
  implementor, and then set the properties object.  Add the object
  to the stylesheet so you don't get the same type of errors as with
  DecimalFormat.
  
  Revision  Changes    Path
  1.9       +148 -10   xml-xalan/java/src/org/apache/xalan/processor/ProcessorOutputElem.java
  
  Index: ProcessorOutputElem.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/processor/ProcessorOutputElem.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- ProcessorOutputElem.java	2000/11/30 09:57:30	1.8
  +++ ProcessorOutputElem.java	2000/12/06 05:29:53	1.9
  @@ -2,7 +2,7 @@
    * The Apache Software License, Version 1.1
    *
    *
  - * Copyright (c) 1999 The Apache Software Foundation.  All rights 
  + * Copyright (c) 1999 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -10,7 +10,7 @@
    * are met:
    *
    * 1. Redistributions of source code must retain the above copyright
  - *    notice, this list of conditions and the following disclaimer. 
  + *    notice, this list of conditions and the following disclaimer.
    *
    * 2. Redistributions in binary form must reproduce the above copyright
    *    notice, this list of conditions and the following disclaimer in
  @@ -18,7 +18,7 @@
    *    distribution.
    *
    * 3. The end-user documentation included with the redistribution,
  - *    if any, must include the following acknowledgment:  
  + *    if any, must include the following acknowledgment:
    *       "This product includes software developed by the
    *        Apache Software Foundation (http://www.apache.org/)."
    *    Alternately, this acknowledgment may appear in the software itself,
  @@ -26,7 +26,7 @@
    *
    * 4. The names "Xalan" and "Apache Software Foundation" must
    *    not be used to endorse or promote products derived from this
  - *    software without prior written permission. For written 
  + *    software without prior written permission. For written
    *    permission, please contact apache@apache.org.
    *
    * 5. Products derived from this software may not be called "Apache",
  @@ -56,15 +56,19 @@
    */
   package org.apache.xalan.processor;
   
  -import org.apache.xalan.serialize.OutputFormat;
  +import javax.xml.transform.OutputKeys;
   
   import java.util.Hashtable;
   
  -import org.apache.xalan.templates.OutputFormatExtended;
  +import org.apache.xalan.templates.OutputProperties;
   import org.apache.xalan.templates.StylesheetRoot;
   import org.apache.xalan.templates.Stylesheet;
  +import org.apache.xalan.templates.ElemTemplateElement;
   
  +import org.apache.xml.utils.QName;
  +
   import javax.xml.transform.TransformerException;
  +
   import org.xml.sax.Attributes;
   
   /**
  @@ -75,7 +79,132 @@
   class ProcessorOutputElem extends XSLTElementProcessor
   {
   
  +  /** The output properties, set temporarily while the properties are 
  +   *  being set from the attributes, and then nulled after that operation 
  +   *  is completed.  */
  +  private OutputProperties m_outputProperties;
  +
  +  /**
  +   * Set the cdata-section-elements property from the attribute value.
  +   * @see {@link javax.xml.transform.OutputKeys#CDATA_SECTION_ELEMENTS}
  +   * @param newValue non-null reference to processed attribute value.
  +   */
  +  public void setCdataSectionElements(java.util.Vector newValue)
  +  {
  +    m_outputProperties.setQNameProperties(OutputKeys.CDATA_SECTION_ELEMENTS, newValue);
  +  }
  +
  +  /**
  +   * Set the doctype-public property from the attribute value.
  +   * @see {@link javax.xml.transform.OutputKeys#DOCTYPE_PUBLIC}
  +   * @param newValue non-null reference to processed attribute value.
  +   */
  +  public void setDoctypePublic(String newValue)
  +  {
  +    m_outputProperties.setProperty(OutputKeys.DOCTYPE_PUBLIC, newValue);
  +  }
  +
  +  /**
  +   * Set the doctype-system property from the attribute value.
  +   * @see {@link javax.xml.transform.OutputKeys#DOCTYPE_SYSTEM}
  +   * @param newValue non-null reference to processed attribute value.
  +   */
  +  public void setDoctypeSystem(String newValue)
  +  {
  +    m_outputProperties.setProperty(OutputKeys.DOCTYPE_SYSTEM, newValue);
  +  }
  +
     /**
  +   * Set the encoding property from the attribute value.
  +   * @see {@link javax.xml.transform.OutputKeys#ENCODING}
  +   * @param newValue non-null reference to processed attribute value.
  +   */
  +  public void setEncoding(String newValue)
  +  {
  +    m_outputProperties.setProperty(OutputKeys.ENCODING, newValue);
  +  }
  +
  +  /**
  +   * Set the indent property from the attribute value.
  +   * @see {@link javax.xml.transform.OutputKeys#INDENT}
  +   * @param newValue non-null reference to processed attribute value.
  +   */
  +  public void setIndent(boolean newValue)
  +  {
  +    m_outputProperties.setBooleanProperty(OutputKeys.INDENT, newValue);
  +  }
  +
  +  /**
  +   * Set the media type property from the attribute value.
  +   * @see {@link javax.xml.transform.OutputKeys#MEDIA_TYPE}
  +   * @param newValue non-null reference to processed attribute value.
  +   */
  +  public void setMediaType(String newValue)
  +  {
  +    m_outputProperties.setProperty(OutputKeys.MEDIA_TYPE, newValue);
  +  }
  +
  +  /**
  +   * Set the method property from the attribute value.
  +   * @see {@link javax.xml.transform.OutputKeys#METHOD}
  +   * @param newValue non-null reference to processed attribute value.
  +   */
  +  public void setMethod(org.apache.xml.utils.QName newValue)
  +  {
  +    m_outputProperties.setQNameProperty(OutputKeys.METHOD, newValue);
  +  }
  +
  +  /**
  +   * Set the omit-xml-declaration property from the attribute value.
  +   * @see {@link javax.xml.transform.OutputKeys#OMIT_XML_DECLARATION}
  +   * @param newValue processed attribute value.
  +   */
  +  public void setOmitXmlDeclaration(boolean newValue)
  +  {
  +    m_outputProperties.setBooleanProperty(OutputKeys.OMIT_XML_DECLARATION, newValue);
  +  }
  +
  +  /**
  +   * Set the standalone property from the attribute value.
  +   * @see {@link javax.xml.transform.OutputKeys#STANDALONE}
  +   * @param newValue processed attribute value.
  +   */
  +  public void setStandalone(boolean newValue)
  +  {
  +    m_outputProperties.setBooleanProperty(OutputKeys.STANDALONE, newValue);
  +  }
  +
  +  /**
  +   * Set the version property from the attribute value.
  +   * @see {@link javax.xml.transform.OutputKeys#VERSION}
  +   * @param newValue non-null reference to processed attribute value.
  +   */
  +  public void setVersion(String newValue)
  +  {
  +    m_outputProperties.setProperty(OutputKeys.VERSION, newValue);
  +  }
  +  
  +  /**
  +   * Set a foreign property from the attribute value.
  +   * @param newValue non-null reference to attribute value.
  +   */
  +  public void setForeignAttr(String attrUri, String attrLocalName, String attrRawName, String attrValue)
  +  {
  +    QName key = new QName(attrUri, attrLocalName);
  +    m_outputProperties.setProperty(key, attrValue);
  +  }
  +  
  +  /**
  +   * Set a foreign property from the attribute value.
  +   * @param newValue non-null reference to attribute value.
  +   */
  +  public void addLiteralResultAttribute(String attrUri, String attrLocalName, String attrRawName, String attrValue)
  +  {
  +    QName key = new QName(attrUri, attrLocalName);
  +    m_outputProperties.setProperty(key, attrValue);
  +  }
  +
  +  /**
      * Receive notification of the start of an xsl:output element.
      *
      * @param handler The calling StylesheetHandler/TemplatesBuilder.
  @@ -90,15 +219,24 @@
      * @param attributes The attributes attached to the element.  If
      *        there are no attributes, it shall be an empty
      *        Attributes object.
  +   *
  +   * @throws org.xml.sax.SAXException
      */
     public void startElement(
             StylesheetHandler handler, String uri, String localName, String rawName, Attributes attributes)
               throws org.xml.sax.SAXException
     {
  -
  -    OutputFormatExtended ofe = new OutputFormatExtended(handler.nextUid());
  +    // Hmmm... for the moment I don't think I'll have default properties set for this. -sb
  +    m_outputProperties = new OutputProperties();
   
  -    setPropertiesFromAttributes(handler, rawName, attributes, ofe);
  -    handler.getStylesheet().setOutput(ofe);
  +    m_outputProperties.setDOMBackPointer(handler.getOriginatingNode());
  +    m_outputProperties.setLocaterInfo(handler.getLocator());
  +    setPropertiesFromAttributes(handler, rawName, attributes, this);
  +    handler.getStylesheet().setOutput(m_outputProperties);
  +    
  +    ElemTemplateElement parent = handler.getElemTemplateElement();
  +    parent.appendChild(m_outputProperties);
  +    
  +    m_outputProperties = null;
     }
   }