santiagopg    2002/07/17 11:52:21

  Modified:    java/src/org/apache/xalan/xsltc/compiler Import.java
                        Include.java Stylesheet.java
  Log:
  Fix for Bugzilla 9171.
  
  Revision  Changes    Path
  1.15      +13 -10    
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Import.java
  
  Index: Import.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Import.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- Import.java       1 Feb 2002 20:07:08 -0000       1.14
  +++ Import.java       17 Jul 2002 18:52:20 -0000      1.15
  @@ -84,11 +84,12 @@
       private Stylesheet _imported = null;
   
       public Stylesheet getImportedStylesheet() {
  -     return(_imported);
  +     return _imported;
       }
   
       public void parseContents(final Parser parser) {
        final Stylesheet context = parser.getCurrentStylesheet();
  +
        try {
            String docToLoad = getAttribute("href");
            if (context.checkForLoop(docToLoad)) {
  @@ -117,7 +118,7 @@
            SyntaxTreeNode root = parser.parse(input);
   
            if (root == null) return;
  -         final Stylesheet _imported = parser.makeStylesheet(root);
  +         _imported = parser.makeStylesheet(root);
            if (_imported == null) return;
   
            _imported.setSourceLoader(loader);
  @@ -138,14 +139,16 @@
            while (elements.hasMoreElements()) {
                final Object element = elements.nextElement();
                if (element instanceof TopLevelElement) {
  -                 if (element instanceof Variable)
  -                     topStylesheet.addVariable((Variable)element);
  -                 else if (element instanceof Param)
  -                     topStylesheet.addParam((Param)element);
  -                 else
  -                     topStylesheet.addElement((TopLevelElement)element);
  +                 if (element instanceof Variable) {
  +                     topStylesheet.addVariable((Variable) element);
  +                 }
  +                 else if (element instanceof Param) {
  +                     topStylesheet.addParam((Param) element);
  +                 }
  +                 else {
  +                     topStylesheet.addElement((TopLevelElement) element);
  +                 }
                }
  -             
            }
        }
        catch (Exception e) {
  
  
  
  1.18      +13 -10    
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Include.java
  
  Index: Include.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Include.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- Include.java      18 Jun 2002 11:17:15 -0000      1.17
  +++ Include.java      17 Jul 2002 18:52:20 -0000      1.18
  @@ -84,11 +84,12 @@
       private Stylesheet _included = null;
   
       public Stylesheet getIncludedStylesheet() {
  -     return(_included);
  +     return _included;
       }
   
       public void parseContents(final Parser parser) {
        final Stylesheet context = parser.getCurrentStylesheet();
  +
        String docToLoad = getAttribute("href");
        try {
            if (context.checkForLoop(docToLoad)) {
  @@ -133,7 +134,7 @@
   
            final SyntaxTreeNode root = parser.parse(input);
            if (root == null) return;
  -         final Stylesheet _included = parser.makeStylesheet(root);
  +         _included = parser.makeStylesheet(root);
            if (_included == null) return;
   
            _included.setSourceLoader(loader);
  @@ -146,7 +147,6 @@
            // as the stylesheet that included it.
            final int precedence = context.getImportPrecedence();
            _included.setImportPrecedence(precedence);
  -
            parser.setCurrentStylesheet(_included);
            _included.parseContents(parser);
   
  @@ -155,12 +155,15 @@
            while (elements.hasMoreElements()) {
                final Object element = elements.nextElement();
                if (element instanceof TopLevelElement) {
  -                 if (element instanceof Variable)
  -                     topStylesheet.addVariable((Variable)element);
  -                 else if (element instanceof Param)
  -                     topStylesheet.addParam((Param)element);
  -                 else
  -                     topStylesheet.addElement((TopLevelElement)element);
  +                 if (element instanceof Variable) {
  +                     topStylesheet.addVariable((Variable) element);
  +                 }
  +                 else if (element instanceof Param) {
  +                     topStylesheet.addParam((Param) element);
  +                 }
  +                 else {
  +                     topStylesheet.addElement((TopLevelElement) element);
  +                 }
                }
            }
        }
  
  
  
  1.43      +7 -19     
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.42
  retrieving revision 1.43
  diff -u -r1.42 -r1.43
  --- Stylesheet.java   17 Jun 2002 18:37:11 -0000      1.42
  +++ Stylesheet.java   17 Jul 2002 18:52:20 -0000      1.43
  @@ -399,13 +399,12 @@
        * Parse all direct children of the <xsl:stylesheet/> element.
        */
       public final void parseOwnChildren(Parser parser) {
  -
        final Vector contents = getContents();
        final int count = contents.size();
   
        // We have to scan the stylesheet element's top-level elements for
  -     // variables and/or parameters before we parse the other elements...
  -     for (int i=0; i<count; i++) {
  +     // variables and/or parameters before we parse the other elements
  +     for (int i = 0; i < count; i++) {
            SyntaxTreeNode child = (SyntaxTreeNode)contents.elementAt(i);
            if ((child instanceof VariableBase) ||
                (child instanceof NamespaceAlias)) {
  @@ -414,22 +413,11 @@
            }
        }
   
  -     // Then we have to go through the included/imported stylesheets
  -     for (int i=0; i<count; i++) {
  -         SyntaxTreeNode child = (SyntaxTreeNode)contents.elementAt(i);
  -         if ((child instanceof Import) || (child instanceof Include)) {
  -             parser.getSymbolTable().setCurrentNode(child);
  -             child.parseContents(parser);            
  -         }
  -     }
  -
        // Now go through all the other top-level elements...
  -     for (int i=0; i<count; i++) {
  +     for (int i = 0; i < count; i++) {
            SyntaxTreeNode child = (SyntaxTreeNode)contents.elementAt(i);
  -         if (!(child instanceof VariableBase) &&
  -             !(child instanceof NamespaceAlias) &&
  -             !(child instanceof Import) &&
  -             !(child instanceof Include)) {
  +         if (!(child instanceof VariableBase) && 
  +             !(child instanceof NamespaceAlias)) {
                parser.getSymbolTable().setCurrentNode(child);
                child.parseContents(parser);
            }
  @@ -438,7 +426,7 @@
            // <xsl:apply-imports/> element was ever used in this stylesheet
            if (!_templateInlining && (child instanceof Template)) {
                Template template = (Template)child;
  -             String name = "template$dot$"+template.getPosition();
  +             String name = "template$dot$" + template.getPosition();
                template.setName(parser.getQName(name));
            }
        }
  
  
  

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

Reply via email to