santiagopg    2002/06/15 09:39:48

  Modified:    java/src/org/apache/xalan/xsltc/compiler Tag:
                        jaxp-ri-1_2_0-fcs-branch LiteralElement.java
                        Output.java Parser.java Stylesheet.java
                        Template.java XSLTC.java
               java/src/org/apache/xalan/xsltc/trax Tag:
                        jaxp-ri-1_2_0-fcs-branch TemplatesHandlerImpl.java
                        TemplatesImpl.java TransformerFactoryImpl.java
                        TransformerImpl.java
  Log:
  Fix layering of output properties in Trax.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.14.4.2  +16 -2     
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/LiteralElement.java
  
  Index: LiteralElement.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/LiteralElement.java,v
  retrieving revision 1.14.4.1
  retrieving revision 1.14.4.2
  diff -u -r1.14.4.1 -r1.14.4.2
  --- LiteralElement.java       3 Apr 2002 19:26:49 -0000       1.14.4.1
  +++ LiteralElement.java       15 Jun 2002 16:39:47 -0000      1.14.4.2
  @@ -64,11 +64,13 @@
   
   package org.apache.xalan.xsltc.compiler;
   
  +import java.util.Vector;
   import java.util.Hashtable;
  +import java.util.Properties;
   import java.util.Enumeration;
  -import java.util.Vector;
   
   import javax.xml.parsers.*;
  +import javax.xml.transform.OutputKeys;
   
   import org.xml.sax.*;
   
  @@ -269,6 +271,18 @@
        }
   
        _name = translateQName(_qname, stable);
  +
  +     // Determine output type if first literal output is html
  +     if (_name.toString().equalsIgnoreCase("html")) {
  +         final SyntaxTreeNode parent = getParent();
  +         if (parent instanceof Template) {
  +             final Template tt = (Template) parent;
  +             if (tt.isRootTemplate()) {
  +                 final Stylesheet stylesheet = parser.getCurrentStylesheet();
  +                 stylesheet.setOutputProperty(OutputKeys.METHOD, "html");
  +             }
  +         }
  +     }
   
        // Process all attributes and register all namespaces they use
        final int count = _attributes.getLength();
  
  
  
  1.12.4.1  +88 -25    
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Output.java
  
  Index: Output.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Output.java,v
  retrieving revision 1.12
  retrieving revision 1.12.4.1
  diff -u -r1.12 -r1.12.4.1
  --- Output.java       1 Feb 2002 20:07:08 -0000       1.12
  +++ Output.java       15 Jun 2002 16:39:47 -0000      1.12.4.1
  @@ -65,9 +65,11 @@
   package org.apache.xalan.xsltc.compiler;
   
   import java.util.Vector;
  +import java.util.Properties;
   import java.util.Enumeration;
   import java.util.StringTokenizer;
   import java.io.OutputStreamWriter;
  +import javax.xml.transform.OutputKeys;
   
   import org.apache.bcel.generic.*;
   import org.apache.bcel.classfile.JavaClass;
  @@ -96,8 +98,9 @@
       private boolean _disabled = false;
   
       // Some global constants
  -    private final static String STRING_SIG = "Ljava/lang/String;";
  -    private final static String ONE_DOT_ZERO_STRING = "1.0";
  +    private final static String STRING_SIG   = "Ljava/lang/String;";
  +    private final static String XML_VERSION  = "1.0";
  +    private final static String HTML_VERSION = "4.0";
   
       /**
        * Displays the contents of this element (for debugging)
  @@ -124,6 +127,7 @@
        * Scans the attribute list for the xsl:output instruction
        */
       public void parseContents(Parser parser) {
  +     final Properties outputProperties = new Properties();
   
        // Ask the parser if it wants this <xsl:output> element
        parser.setOutput(this);
  @@ -133,25 +137,30 @@
   
        String attrib = null;
   
  -     // Get the output XML version - only version "1.0" should be used
  +     // Get the output version
        _version = getAttribute("version");
  -     if ((_version == null) || (_version.equals(Constants.EMPTYSTRING))) {
  -         _version = ONE_DOT_ZERO_STRING;
  +     if (_version == null || _version.equals(Constants.EMPTYSTRING)) {
  +         _version = null;
        }
  -     if (!_version.equals(ONE_DOT_ZERO_STRING)) {
  -         ErrorMsg msg = new ErrorMsg(ErrorMsg.OUTPUT_VERSION_ERR, this);
  -         parser.reportError(Constants.WARNING, msg);
  +     else {
  +         outputProperties.setProperty(OutputKeys.VERSION, _version);
        }
   
        // Get the output method - "xml", "html", "text" or <qname>
        _method = getAttribute("method");
  -     if (_method.equals(Constants.EMPTYSTRING)) _method = null;
  -     if (_method != null) _method = _method.toLowerCase();
  +     if (_method.equals(Constants.EMPTYSTRING)) {
  +         _method = null;
  +     }
  +     if (_method != null) {
  +         _method = _method.toLowerCase();
  +         outputProperties.setProperty(OutputKeys.METHOD, _method);
  +     }
   
        // Get the output encoding - any value accepted here
        _encoding = getAttribute("encoding");
  -     if (_encoding.equals(Constants.EMPTYSTRING))
  +     if (_encoding.equals(Constants.EMPTYSTRING)) {
            _encoding = null;
  +     }
        else {
            try {
                OutputStreamWriter writer =
  @@ -162,42 +171,96 @@
                                            _encoding, this);
                parser.reportError(Constants.WARNING, msg);
            }
  +         outputProperties.setProperty(OutputKeys.ENCODING, _encoding);
        }
   
        // Should the XML header be omitted - translate to true/false
        attrib = getAttribute("omit-xml-declaration");
  -     if ((attrib != null) && (attrib.equals("yes"))) _omitHeader = true;
  +     if (attrib != null && !attrib.equals(Constants.EMPTYSTRING)) {
  +         if (attrib.equals("yes")) {
  +             _omitHeader = true;
  +         }
  +         outputProperties.setProperty(OutputKeys.OMIT_XML_DECLARATION, 
attrib);
  +     }
   
        // Add 'standalone' decaration to output - use text as is
        _standalone = getAttribute("standalone");
  -     if (_standalone.equals(Constants.EMPTYSTRING)) _standalone = null;
  +     if (_standalone.equals(Constants.EMPTYSTRING)) {
  +         _standalone = null;
  +     }
  +     else {
  +         outputProperties.setProperty(OutputKeys.STANDALONE, _standalone);
  +     }
   
        // Get system/public identifiers for output DOCTYPE declaration
        _doctypeSystem = getAttribute("doctype-system");
  -     if (_doctypeSystem.equals(Constants.EMPTYSTRING)) _doctypeSystem = null;
  +     if (_doctypeSystem.equals(Constants.EMPTYSTRING)) {
  +         _doctypeSystem = null;
  +     }
  +     else {
  +         outputProperties.setProperty(OutputKeys.DOCTYPE_SYSTEM, 
_doctypeSystem);
  +     }
  +
  +
        _doctypePublic = getAttribute("doctype-public");
  -     if (_doctypePublic.equals(Constants.EMPTYSTRING)) _doctypePublic = null;
  +     if (_doctypePublic.equals(Constants.EMPTYSTRING)) {
  +         _doctypePublic = null;
  +     }
  +     else {
  +         outputProperties.setProperty(OutputKeys.DOCTYPE_PUBLIC, 
_doctypePublic);
  +     }
   
        // Names the elements of whose text contents should be output as CDATA
        _cdata = getAttribute("cdata-section-elements");
  -     if ((_cdata != null) && (_cdata.equals(Constants.EMPTYSTRING)))
  +     if (_cdata != null && _cdata.equals(Constants.EMPTYSTRING)) {
            _cdata = null;
  +     }
  +     else {
  +         outputProperties.setProperty(OutputKeys.CDATA_SECTION_ELEMENTS, 
_cdata);
  +     }
   
        // Get the indent setting - only has effect for xml and html output
        attrib = getAttribute("indent");
  -     if ((attrib != null) && (!attrib.equals(EMPTYSTRING))) {
  -         if (attrib.equals("yes")) _indent = true;
  +     if (attrib != null && !attrib.equals(EMPTYSTRING)) {
  +         if (attrib.equals("yes")) {
  +             _indent = true;
  +         }
  +         outputProperties.setProperty(OutputKeys.INDENT, attrib);
        }
  -     else if ((_method != null) && (_method.equals("html"))) {
  +
  +     else if (_method != null && _method.equals("html")) {
            _indent = true;
        }
   
  -     // Get the MIME type for the output file - we don't do anythign with it,
  -     // but our client may use it to specify a data transport type, etc.
  +     // Get the MIME type for the output file
        _mediaType = getAttribute("media-type");
  -     if (_mediaType.equals(Constants.EMPTYSTRING)) _mediaType = null;
  +     if (_mediaType.equals(Constants.EMPTYSTRING)) {
  +         _mediaType = null;
  +     }
  +     else {
  +         outputProperties.setProperty(OutputKeys.MEDIA_TYPE, _mediaType);
  +     }
  +
  +     // Implied properties
  +     if (_method != null) {
  +         if (_method.equals("html")) {
  +             if (_version == null) {
  +                 _version = HTML_VERSION;
  +             }
  +             if (_mediaType == null) {
  +                 _mediaType = "text/html";
  +             }
  +             _indent = true;
  +         }
  +         else if (_method.equals("text")) {
  +             if (_mediaType == null) {
  +                 _mediaType = "text/plain";
  +             }
  +         }
  +     }
   
  -     // parseChildren(parser); - the element is always empty
  +     // Set output properties in current stylesheet
  +     parser.getCurrentStylesheet().setOutputProperties(outputProperties);
       }
   
       /**
  @@ -216,7 +279,7 @@
           il.append(classGen.loadTranslet());
   
        // Only update _version field if set and different from default
  -     if ((_version != null) && (!_version.equals(ONE_DOT_ZERO_STRING))) {
  +     if (_version != null && !_version.equals(XML_VERSION)) {
            field = cpg.addFieldref(TRANSLET_CLASS, "_version", STRING_SIG);
            il.append(DUP);
            il.append(new PUSH(cpg, _version));
  
  
  
  1.38.8.5  +6 -1      
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Parser.java
  
  Index: Parser.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Parser.java,v
  retrieving revision 1.38.8.4
  retrieving revision 1.38.8.5
  diff -u -r1.38.8.4 -r1.38.8.5
  --- Parser.java       15 Jun 2002 13:51:21 -0000      1.38.8.4
  +++ Parser.java       15 Jun 2002 16:39:47 -0000      1.38.8.5
  @@ -71,6 +71,7 @@
   import java.util.Vector;
   import java.util.Hashtable;
   import java.util.Dictionary;
  +import java.util.Properties;
   import java.util.Enumeration;
   import java.util.StringTokenizer;
   import java.util.Stack;
  @@ -167,6 +168,10 @@
   
       public Output getOutput() {
        return _output;
  +    }
  +
  +    public Properties getOutputProperties() {
  +     return getTopLevelStylesheet().getOutputProperties();
       }
   
       public void addVariable(Variable var) {
  
  
  
  1.35.4.4  +19 -1     
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Stylesheet.java
  
  Index: Stylesheet.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Stylesheet.java,v
  retrieving revision 1.35.4.3
  retrieving revision 1.35.4.4
  diff -u -r1.35.4.3 -r1.35.4.4
  --- Stylesheet.java   22 Apr 2002 16:39:00 -0000      1.35.4.3
  +++ Stylesheet.java   15 Jun 2002 16:39:47 -0000      1.35.4.4
  @@ -66,6 +66,7 @@
   
   import java.util.Vector;
   import java.util.Hashtable;
  +import java.util.Properties;
   import java.util.Enumeration;
   import java.util.StringTokenizer;
   import java.util.Iterator;
  @@ -132,6 +133,8 @@
   
       private boolean _forwardReference = false;
   
  +    private Properties _outputProperties = null;
  +
       public void setForwardReference() {
        _forwardReference = true;
       }
  @@ -148,6 +151,21 @@
        _simplified = true;
       }
       
  +    public void setOutputProperty(String key, String value) {
  +     if (_outputProperties == null) {
  +         _outputProperties = new Properties();
  +     }
  +     _outputProperties.setProperty(key, value);
  +    }
  +
  +    public void setOutputProperties(Properties props) {
  +     _outputProperties = props;
  +    }
  +
  +    public Properties getOutputProperties() {
  +     return _outputProperties;
  +    }
  +
       public void setMultiDocument(boolean flag) {     
        _multiDocument = flag;
       }
  
  
  
  1.16.4.1  +6 -1      
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Template.java
  
  Index: Template.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Template.java,v
  retrieving revision 1.16
  retrieving revision 1.16.4.1
  diff -u -r1.16 -r1.16.4.1
  --- Template.java     1 Feb 2002 20:07:08 -0000       1.16
  +++ Template.java     15 Jun 2002 16:39:47 -0000      1.16.4.1
  @@ -132,6 +132,11 @@
        return _name != null;
       }
   
  +    public boolean isRootTemplate() {
  +     final String match = getAttribute("match");
  +     return (match != null && match.equals("/"));
  +    }
  +
       public Pattern getPattern() {
        return _pattern;
       }
  
  
  
  1.35.4.2  +9 -1      
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/XSLTC.java
  
  Index: XSLTC.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/XSLTC.java,v
  retrieving revision 1.35.4.1
  retrieving revision 1.35.4.2
  diff -u -r1.35.4.1 -r1.35.4.2
  --- XSLTC.java        17 Apr 2002 20:25:26 -0000      1.35.4.1
  +++ XSLTC.java        15 Jun 2002 16:39:47 -0000      1.35.4.2
  @@ -72,6 +72,7 @@
   import java.util.Set;
   import java.util.HashSet;
   import java.util.Iterator;
  +import java.util.Properties;
   import java.util.Enumeration;
   import java.util.StringTokenizer;
   import java.util.Date;
  @@ -161,6 +162,13 @@
        */
       public void setOutputType(int type) {
        _outputType = type;
  +    }
  +
  +    /**
  +     * Only for user by the internal TrAX implementation.
  +     */
  +    public Properties getOutputProperties() {
  +     return _parser.getOutputProperties();
       }
   
       /**
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.3.8.3   +2 -2      
xml-xalan/java/src/org/apache/xalan/xsltc/trax/TemplatesHandlerImpl.java
  
  Index: TemplatesHandlerImpl.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/trax/TemplatesHandlerImpl.java,v
  retrieving revision 1.3.8.2
  retrieving revision 1.3.8.3
  diff -u -r1.3.8.2 -r1.3.8.3
  --- TemplatesHandlerImpl.java 15 Apr 2002 19:26:48 -0000      1.3.8.2
  +++ TemplatesHandlerImpl.java 15 Jun 2002 16:39:48 -0000      1.3.8.3
  @@ -167,7 +167,7 @@
                return null;
            }
   
  -         return(new TemplatesImpl(bytecodes, transletName));
  +         return new TemplatesImpl(bytecodes, transletName, 
getOutputProperties());
        }
        catch (CompilerException e) {
            return null;
  
  
  
  1.9.8.2   +8 -3      
xml-xalan/java/src/org/apache/xalan/xsltc/trax/TemplatesImpl.java
  
  Index: TemplatesImpl.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/trax/TemplatesImpl.java,v
  retrieving revision 1.9.8.1
  retrieving revision 1.9.8.2
  diff -u -r1.9.8.1 -r1.9.8.2
  --- TemplatesImpl.java        3 Apr 2002 19:26:50 -0000       1.9.8.1
  +++ TemplatesImpl.java        15 Jun 2002 16:39:48 -0000      1.9.8.2
  @@ -97,6 +97,8 @@
       // and _bytecodes arrays (above).
       private int _transletIndex = -1;
       
  +    private Properties _outputProperties;
  +
       // Our own private class loader - builds Class definitions from bytecodes
       private class TransletClassLoader extends ClassLoader {
   
  @@ -127,9 +129,12 @@
        * The bytecodes for the translet and auxiliary classes, plus the name of
        * the main translet class, must be supplied
        */
  -    protected TemplatesImpl(byte[][] bytecodes, String transletName) {
  +    protected TemplatesImpl(byte[][] bytecodes, String transletName,
  +     Properties outputProperties) 
  +    {
        _bytecodes = bytecodes;
        _name      = transletName;
  +     _outputProperties = outputProperties;
       }
   
       /**
  @@ -256,7 +261,7 @@
        */
       public Transformer newTransformer()
        throws TransformerConfigurationException {
  -        return(new TransformerImpl(getTransletInstance()));
  +        return new TransformerImpl(getTransletInstance(), _outputProperties);
       }
   
       /**
  
  
  
  1.33.8.3  +5 -3      
xml-xalan/java/src/org/apache/xalan/xsltc/trax/TransformerFactoryImpl.java
  
  Index: TransformerFactoryImpl.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/trax/TransformerFactoryImpl.java,v
  retrieving revision 1.33.8.2
  retrieving revision 1.33.8.3
  diff -u -r1.33.8.2 -r1.33.8.3
  --- TransformerFactoryImpl.java       15 Jun 2002 15:33:49 -0000      1.33.8.2
  +++ TransformerFactoryImpl.java       15 Jun 2002 16:39:48 -0000      1.33.8.3
  @@ -336,7 +336,8 @@
        }
   
        // Create a Transformer object and store for other calls
  -     Templates templates = new TemplatesImpl(bytecodes,_defaultTransletName);
  +     Templates templates = new TemplatesImpl(bytecodes, 
  +         _defaultTransletName, xsltc.getOutputProperties());
        _copyTransformer = templates.newTransformer();
        if (_uriResolver != null) _copyTransformer.setURIResolver(_uriResolver);
        return(_copyTransformer);
  @@ -519,7 +520,8 @@
            ErrorMsg err = new ErrorMsg(ErrorMsg.JAXP_COMPILE_ERR);
            throw new TransformerConfigurationException(err.toString());
        }
  -     return(new TemplatesImpl(bytecodes, transletName));
  +     return new TemplatesImpl(bytecodes, transletName, 
  +         xsltc.getOutputProperties());
       }
   
       /**
  
  
  
  1.32.8.3  +58 -71    
xml-xalan/java/src/org/apache/xalan/xsltc/trax/TransformerImpl.java
  
  Index: TransformerImpl.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/trax/TransformerImpl.java,v
  retrieving revision 1.32.8.2
  retrieving revision 1.32.8.3
  diff -u -r1.32.8.2 -r1.32.8.3
  --- TransformerImpl.java      5 Apr 2002 22:44:47 -0000       1.32.8.2
  +++ TransformerImpl.java      15 Jun 2002 16:39:48 -0000      1.32.8.3
  @@ -118,7 +118,7 @@
   
       private ErrorListener _errorListener = this;
       private URIResolver   _uriResolver = null;
  -    private Properties    _properties = null;
  +    private Properties    _properties, _propertiesClone;
   
       // Used for default output property settings
       private final static String EMPTY_STRING = "";
  @@ -138,9 +138,10 @@
        * Implements JAXP's Transformer constructor
        * Our Transformer objects always need a translet to do the actual work
        */
  -    protected TransformerImpl(Translet translet) {
  +    protected TransformerImpl(Translet translet, Properties 
outputProperties) {
        _translet = (AbstractTranslet)translet;
  -     _properties = createOutputProperties();
  +     _properties = createOutputProperties(outputProperties);
  +     _propertiesClone = (Properties) _properties.clone();
       }
   
       /**
  @@ -642,17 +643,12 @@
   
       /**
        * Implements JAXP's Transformer.getOutputProperties().
  -     * Returns a copy of the output properties for the transformation. This 
is
  -     * a set of layered properties. The first layer contains properties set 
by
  -     * calls to setOutputProperty() and setOutputProperties() on this class,
  -     * and the output settings defined in the stylesheet's <xsl:output>
  -     * element makes up the second level, while the default XSLT output
  -     * settings are returned on the third level.
  +     * Returns a copy of the output properties for the transformation. 
        *
        * @return Properties in effect for this Transformer
        */
       public Properties getOutputProperties() {
  -     return(_properties);
  +     return (Properties) _properties.clone();
       }
   
       /**
  @@ -670,7 +666,7 @@
            ErrorMsg err = new ErrorMsg(ErrorMsg.JAXP_UNKNOWN_PROP_ERR, name);
            throw new IllegalArgumentException(err.toString());
        }
  -     return(_properties.getProperty(name));
  +     return _properties.getProperty(name);
       }
   
       /**
  @@ -683,8 +679,25 @@
        * @throws IllegalArgumentException Never, errors are ignored
        */
       public void setOutputProperties(Properties properties)
  -     throws IllegalArgumentException {
  -     _properties.putAll(properties);
  +     throws IllegalArgumentException 
  +    {
  +     if (properties != null) {
  +         final Enumeration names = properties.propertyNames();
  +
  +         while (names.hasMoreElements()) {
  +             final String name = (String) names.nextElement();
  +             if (validOutputProperty(name)) {
  +                 _properties.setProperty(name, properties.getProperty(name));
  +             }
  +             else {
  +                 ErrorMsg err = new ErrorMsg(ErrorMsg.JAXP_UNKNOWN_PROP_ERR, 
name);
  +                 throw new IllegalArgumentException(err.toString());
  +             }
  +         }
  +     }
  +     else {
  +         _properties = _propertiesClone;
  +     }
       }
   
       /**
  @@ -766,66 +779,40 @@
        * Internal method to pass any properties to the translet prior to
        * initiating the transformation
        */
  -    private Properties createOutputProperties() {
  -     
  -     // Level3: Return the default property value
  -     // bug # 6751 fixed by removing setProperty lines for 
  -     //  OutputKeys.(DOCTYPE_PUBLIC|DOCTYPE_SYSTEM|CDATA_SECTION_ELEMENTS)
  -     //  instead of setting them to "" (EMPTY_STRING). Fix contributed
  -     //  by Derek Sayeau.   
  -     Properties third = new Properties();
  -     third.setProperty(OutputKeys.ENCODING, "UTF-8");
  -     third.setProperty(OutputKeys.METHOD, XML_STRING);
  -     third.setProperty(OutputKeys.INDENT, NO_STRING);
  -     third.setProperty(OutputKeys.MEDIA_TYPE, "text/xml");
  -     third.setProperty(OutputKeys.OMIT_XML_DECLARATION, NO_STRING);
  -     third.setProperty(OutputKeys.STANDALONE, NO_STRING);
  -     third.setProperty(OutputKeys.VERSION, "1.0");
  -
  -     // Level2: Return the property value is set in the translet
  -     // Creating these properties with the third-level properties as default
  -     Properties second = new Properties(third);
  -     if (_translet != null) {
  -         String value = _translet._encoding;
  -         if (value != null) second.setProperty(OutputKeys.ENCODING, value);
  -
  -         value = _translet._method;
  -         if (value != null) second.setProperty(OutputKeys.METHOD, value);
  -
  -         if (_translet._indent)
  -             second.setProperty(OutputKeys.INDENT, "yes");
  -         else
  -             second.setProperty(OutputKeys.INDENT, "no");
  -
  -         value = _translet._doctypePublic;
  -         if (value != null) 
  -             second.setProperty(OutputKeys.DOCTYPE_PUBLIC, value);
  -
  -         value = _translet._doctypeSystem;
  -         if (value != null) 
  -             second.setProperty(OutputKeys.DOCTYPE_SYSTEM, value);
  -
  -         value = makeCDATAString(_translet._cdata);
  -         if (value != null) 
  -             second.setProperty(OutputKeys.CDATA_SECTION_ELEMENTS,value);
  -
  -         value = _translet._mediaType;
  -         if (value != null) second.setProperty(OutputKeys.MEDIA_TYPE, value);
  -
  -         if (_translet._omitHeader)
  -             second.setProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
  -         else
  -             second.setProperty(OutputKeys.OMIT_XML_DECLARATION, "no");
  -
  -         value = _translet._standalone;
  -         if (value != null) second.setProperty(OutputKeys.STANDALONE, value);
  +    private Properties createOutputProperties(Properties outputProperties) {
  +     final Properties defaults = new Properties();
  +     defaults.setProperty(OutputKeys.ENCODING, "UTF-8");
  +     defaults.setProperty(OutputKeys.METHOD, XML_STRING);
  +     defaults.setProperty(OutputKeys.INDENT, NO_STRING);
  +     defaults.setProperty(OutputKeys.MEDIA_TYPE, "text/xml");
  +     defaults.setProperty(OutputKeys.OMIT_XML_DECLARATION, NO_STRING);
  +     defaults.setProperty(OutputKeys.STANDALONE, NO_STRING);
  +     defaults.setProperty(OutputKeys.VERSION, "1.0");
  +
  +     // Copy propeties set in stylesheet to base
  +     final Properties base = new Properties(defaults);
  +     if (outputProperties != null) {
  +         final Enumeration names = outputProperties.propertyNames();
  +         while (names.hasMoreElements()) {
  +             final String name = (String) names.nextElement();
  +             base.setProperty(name, outputProperties.getProperty(name));
  +         }
  +     }
   
  -         value = _translet._version;
  -         if (value != null) second.setProperty(OutputKeys.VERSION, value);
  +     // Update defaults based on output method
  +     final String method = base.getProperty(OutputKeys.METHOD);
  +     if (method != null) {
  +         if (method.equals("html")) {
  +             defaults.setProperty(OutputKeys.INDENT, "yes");
  +             defaults.setProperty(OutputKeys.VERSION, "4.0");
  +             defaults.setProperty(OutputKeys.MEDIA_TYPE, "text/html");
  +         }
  +         else if (method.equals("text")) {
  +             defaults.setProperty(OutputKeys.MEDIA_TYPE, "text/plain");
  +         }
        }
   
  -     // Creating the properties with the second-level properties as default
  -     return(new Properties(second));
  +     return base; 
       }
   
       /**
  
  
  

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

Reply via email to