zongaro     2004/04/10 12:01:00

  Modified:    java/src/org/apache/xalan/xsltc/compiler Stylesheet.java
  Log:
  Applying patch for bug 27932.
  
  Code was incorrectly calculating the set of templates to which an
  xsl:apply-imports instruction applies.  It should consider all templates that
  the current template rule could override, which means that if the template
  appeared in a stylesheet that was included in another stylesheet, any 
templates
  imported into the including stylesheet have to be considered as well.  The
  method Stylesheet.getMinimumDescendantPrecedence is responsible for this
  calculation.
  
  Reviewed by Joanne Tong (joannet () ca ! ibm ! com)
  
  Revision  Changes    Path
  1.60      +37 -7     
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.59
  retrieving revision 1.60
  diff -u -r1.59 -r1.60
  --- Stylesheet.java   16 Feb 2004 22:24:29 -0000      1.59
  +++ Stylesheet.java   10 Apr 2004 19:01:00 -0000      1.60
  @@ -59,11 +59,6 @@
   import org.apache.xalan.xsltc.runtime.AbstractTranslet;
   import org.apache.xml.dtm.DTM;
   
  -/**
  - * @author Jacek Ambroziak
  - * @author Santiago Pericas-Geertsen
  - * @author Morten Jorgensen
  - */
   public final class Stylesheet extends SyntaxTreeNode {
   
       /**
  @@ -153,7 +148,13 @@
        * Import precendence for this stylesheet.
        */
       private int _importPrecedence = 1;
  -    
  +
  +    /**
  +     * Minimum precendence of any descendant stylesheet by inclusion or
  +     * importation.
  +     */
  +    private int _minimumDescendantPrecedence = -1;
  +
       /**
        * Mapping between key names and Key objects (needed by Key/IdPattern).
        */
  @@ -343,6 +344,35 @@
       
       public int getImportPrecedence() {
        return _importPrecedence;
  +    }
  +
  +    /**
  +     * Get the minimum of the precedence of this stylesheet, any stylesheet
  +     * imported by this stylesheet and any include/import descendant of this
  +     * stylesheet.
  +     */
  +    public int getMinimumDescendantPrecedence() {
  +        if (_minimumDescendantPrecedence == -1) {
  +            // Start with precedence of current stylesheet as a basis.
  +            int min = getImportPrecedence();
  +
  +            // Recursively examine all imported/included stylesheets.
  +            final int inclImpCount = (_includedStylesheets != null)
  +                                          ? _includedStylesheets.size()
  +                                          : 0;
  +
  +            for (int i = 0; i < inclImpCount; i++) {
  +                int prec = ((Stylesheet)_includedStylesheets.elementAt(i))
  +                                              
.getMinimumDescendantPrecedence();
  +
  +                if (prec < min) {
  +                    min = prec;
  +                }
  +            }
  +
  +            _minimumDescendantPrecedence = min;
  +        }
  +        return _minimumDescendantPrecedence;
       }
   
       public boolean checkForLoop(String systemId) {
  
  
  

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

Reply via email to