morten      01/09/25 13:38:41

  Modified:    java/src/org/apache/xalan/xsltc/compiler Output.java
                        Parser.java Stylesheet.java
  Log:
  Fix to make sure the one, and only one, xsl:output element is compiled
  per translet (import precedence taken into account).
  PR:           bugzilla 3099
  Obtained from:        n/a
  Submitted by: [EMAIL PROTECTED]
  Reviewed by:  [EMAIL PROTECTED]
  
  Revision  Changes    Path
  1.8       +16 -4     
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.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- Output.java       2001/08/16 12:17:15     1.7
  +++ Output.java       2001/09/25 20:38:41     1.8
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: Output.java,v 1.7 2001/08/16 12:17:15 morten Exp $
  + * @(#)$Id: Output.java,v 1.8 2001/09/25 20:38:41 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -76,6 +76,8 @@
   
   final class Output extends TopLevelElement {
   
  +    // TODO: use three-value variables for boolean values: true/false/default
  +
       // These attributes are extracted from the xsl:output element. They also
       // appear as fields (with the same type, only public) in the translet
       private String  _version;
  @@ -115,11 +117,18 @@
        _disabled = true;
       }
   
  +    public boolean enabled() {
  +     return !_disabled;
  +    }
  +
       /**
        * Scans the attribute list for the xsl:output instruction
        */
       public void parseContents(Parser parser) {
   
  +     // Ask the parser if it wants this <xsl:output> element
  +     parser.setOutput(this);
  +
        // Do nothing if other <xsl:output> element has higher precedence
        if (_disabled) return;
   
  @@ -165,7 +174,12 @@
   
        // Get the indent setting - only has effect for xml and html output
        attrib = getAttribute("indent");
  -     if ((attrib != null) && (attrib.equals("yes"))) _indent = true;
  +     if ((attrib != null) && (!attrib.equals(EMPTYSTRING))) {
  +         if (attrib.equals("yes")) _indent = true;
  +     }
  +     else if (_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.
  @@ -173,8 +187,6 @@
        if (_mediaType.equals(Constants.EMPTYSTRING)) _mediaType = null;
   
        // parseChildren(parser); - the element is always empty
  -
  -     parser.setOutput(this);
       }
   
       /**
  
  
  
  1.26      +16 -4     
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.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- Parser.java       2001/09/18 08:25:34     1.25
  +++ Parser.java       2001/09/25 20:38:41     1.26
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: Parser.java,v 1.25 2001/09/18 08:25:34 morten Exp $
  + * @(#)$Id: Parser.java,v 1.26 2001/09/25 20:38:41 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -166,10 +166,22 @@
       }
   
       public void setOutput(Output output) {
  -     if (_output == null)
  +     if (_output != null) {
  +         if (_output.getImportPrecedence() <= output.getImportPrecedence()) {
  +             _output.disable();
  +             _output = output;
  +         }
  +         else {
  +             output.disable();
  +         }
  +     }
  +     else {
            _output = output;
  -     else
  -         output.disable();
  +     }
  +    }
  +
  +    public Output getOutput() {
  +     return _output;
       }
   
       public void addVariable(Variable var) {
  
  
  
  1.20      +3 -2      
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.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- Stylesheet.java   2001/09/25 16:38:10     1.19
  +++ Stylesheet.java   2001/09/25 20:38:41     1.20
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: Stylesheet.java,v 1.19 2001/09/25 16:38:10 morten Exp $
  + * @(#)$Id: Stylesheet.java,v 1.20 2001/09/25 20:38:41 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -458,7 +458,8 @@
            }
            else if (element instanceof Output) {
                // save the element for later to pass to compileConstructor 
  -             lastOutputElement = (Output)element;
  +             Output output = (Output)element;
  +             if (output.enabled()) lastOutputElement = output;
            }
            else {
                // Global variables and parameters are handled elsewhere.
  
  
  

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

Reply via email to