sboag       00/12/01 16:28:18

  Modified:    java/src/org/apache/xalan/templates ElemLiteralResult.java
                        ElemTemplateElement.java Stylesheet.java
                        XMLNSDecl.java
  Log:
  Fix handling of xsl:exclude-result-prefixes attribute.
  
  Revision  Changes    Path
  1.13      +26 -128   
xml-xalan/java/src/org/apache/xalan/templates/ElemLiteralResult.java
  
  Index: ElemLiteralResult.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/templates/ElemLiteralResult.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- ElemLiteralResult.java    2000/12/01 17:50:14     1.12
  +++ ElemLiteralResult.java    2000/12/02 00:28:17     1.13
  @@ -182,12 +182,37 @@
     }
     
     /**
  +   * Get whether or not the passed URL is contained flagged by
  +   * the "extension-element-prefixes" property.
  +   * @see <a 
href="http://www.w3.org/TR/xslt#extension-element";>extension-element in XSLT 
Specification</a>
  +   *
  +   * @param prefix non-null reference to prefix that might be excluded.
  +   *
  +   * @return true if the prefix should normally be excluded.
  +   */
  +  public boolean containsExcludeResultPrefix(String prefix)
  +  {
  +
  +    if (null == m_excludeResultPrefixes)
  +      return super.containsExcludeResultPrefix(prefix);
  +
  +    if (prefix.length() == 0)
  +      prefix = Constants.ATTRVAL_DEFAULT_PREFIX;
  +
  +    if(m_excludeResultPrefixes.contains(prefix))
  +      return true;
  +    else
  +      return super.containsExcludeResultPrefix(prefix);
  +  }
  +  
  +  /**
      * Augment resolvePrefixTables, resolving the namespace aliases once 
      * the superclass has resolved the tables.
      */
     public void resolvePrefixTables() throws TransformerException
     {
       super.resolvePrefixTables();
  +        
       StylesheetRoot stylesheet = getStylesheetRoot();
       if((null != m_namespace) && (m_namespace.length() > 0))
       {
  @@ -438,139 +463,12 @@
      * imported or included by children of that xsl:stylesheet element.
      * @see <a 
href="http://www.w3.org/TR/xslt#literal-result-element";>literal-result-element 
in XSLT Specification</a>
      *
  -   * NEEDSDOC @param v
  +   * @param v vector of prefixes that are resolvable to strings.
      */
     public void setExcludeResultPrefixes(StringVector v)
     {
       m_excludeResultPrefixes = v;
     }
  -
  -  /**
  -   * Tell if the result namespace decl should be excluded.  Should be called 
before
  -   * namespace aliasing (I think).
  -   *
  -   * NEEDSDOC @param prefix
  -   * NEEDSDOC @param uri
  -   *
  -   * NEEDSDOC ($objectName$) @return
  -   *
  -   * @throws TransformerException
  -   */
  -  private boolean excludeResultNSDecl(String prefix, String uri)
  -          throws TransformerException
  -  {
  -
  -    if (null != m_excludeResultPrefixes)
  -    {
  -      if (m_excludeResultPrefixes.contains(prefix))
  -        return true;
  -    }
  -
  -    return false;
  -  }
  -
  -  /*
  -   * Combine the parent's namespaces with this namespace
  -   * for fast processing, taking care to reference the
  -   * parent's namespace if this namespace adds nothing new.
  -   * (Recursive method, walking the elements depth-first,
  -   * processing parents before children).
  -   * Overide super method to handle exclude-result-prefix attribute.
  -   *
  -   * @throws TransformerException
  -   *
  -  public void resolvePrefixTables() throws TransformerException
  -  {
  -
  -    // Always start with a fresh prefix table!
  -    m_prefixTable = null;
  -
  -    Vector m_declaredPrefixes = getDeclaredPrefixes();
  -
  -    // If we have declared declarations, then we look for 
  -    // a parent that has namespace decls, and add them 
  -    // to this element's decls.  Otherwise we just point 
  -    // to the parent that has decls.
  -    if (null != m_declaredPrefixes)
  -    {
  -
  -      // Add this element's declared prefixes to the 
  -      // prefix table.
  -      int n = m_declaredPrefixes.size();
  -
  -      for (int i = 0; i < n; i++)
  -      {
  -        XMLNSDecl decl = (XMLNSDecl) m_declaredPrefixes.elementAt(i);
  -        String prefix = decl.getPrefix();
  -        String uri = decl.getURI();
  -        boolean shouldExclude = excludeResultNSDecl(prefix, uri);
  -
  -        // Create a new prefix table if one has not already been created.
  -        if (null == m_prefixTable)
  -          m_prefixTable = new Vector();
  -
  -        m_prefixTable.addElement(new XMLNSDecl(prefix, uri, shouldExclude));
  -      }
  -    }
  -
  -    ElemTemplateElement parent = (ElemTemplateElement) this.getParentNode();
  -
  -    if (null != parent)
  -    {
  -
  -      // The prefix table of the parent should never be null!
  -      Vector prefixes = parent.m_prefixTable;
  -
  -      if (null == m_excludeResultPrefixes && null == m_prefixTable)
  -      {
  -
  -        // Nothing to combine, so just use parent's table!
  -        this.m_prefixTable = parent.m_prefixTable;
  -      }
  -      else
  -      {
  -        if (null == m_prefixTable)
  -          m_prefixTable = new Vector();
  -
  -        // Add the prefixes from the parent's prefix table.
  -        int n = prefixes.size();
  -
  -        for (int i = 0; i < n; i++)
  -        {
  -          XMLNSDecl decl = (XMLNSDecl) prefixes.elementAt(i);
  -          boolean isexcluded = decl.getIsExcluded();
  -
  -          if (!isexcluded)
  -          {
  -            boolean shouldExclude = excludeResultNSDecl(decl.getPrefix(),
  -                                                        decl.getURI());
  -
  -            if (shouldExclude != isexcluded)
  -            {
  -              decl = new XMLNSDecl(decl.getPrefix(), decl.getURI(),
  -                                   shouldExclude);
  -            }
  -          }
  -
  -          m_prefixTable.addElement(decl);
  -        }
  -      }
  -    }
  -    else if (null == m_prefixTable)
  -    {
  -
  -      // Must be stylesheet element without any result prefixes!
  -      m_prefixTable = new Vector();
  -    }
  -
  -    // Resolve the children's prefix tables.
  -    for (ElemTemplateElement child = m_firstChild; child != null;
  -            child = child.m_nextSibling)
  -    {
  -      child.resolvePrefixTables();
  -    }
  -  }
  -  */
   
     /**
      * Copy a Literal Result Element into the Result tree, copy the
  
  
  
  1.26      +21 -2     
xml-xalan/java/src/org/apache/xalan/templates/ElemTemplateElement.java
  
  Index: ElemTemplateElement.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/templates/ElemTemplateElement.java,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- ElemTemplateElement.java  2000/12/01 17:50:15     1.25
  +++ ElemTemplateElement.java  2000/12/02 00:28:17     1.26
  @@ -761,6 +761,25 @@
     {
       return m_prefixTable;
     }
  +  
  +  /**
  +   * Get whether or not the passed URL is contained flagged by
  +   * the "extension-element-prefixes" property.  This method is overridden 
  +   * by [EMAIL PROTECTED] ElemLiteralResult#containsExcludeResultPrefix}.
  +   * @see <a 
href="http://www.w3.org/TR/xslt#extension-element";>extension-element in XSLT 
Specification</a>
  +   *
  +   * @param prefix non-null reference to prefix that might be excluded.
  +   *
  +   * @return true if the prefix should normally be excluded.
  +   */
  +  public boolean containsExcludeResultPrefix(String prefix)
  +  {
  +    ElemTemplateElement parent = this.getParentElem();
  +    if(null != parent)
  +      return parent.containsExcludeResultPrefix(prefix);
  +      
  +    return false;
  +  }
   
     /**
      * Tell if the result namespace decl should be excluded.  Should be called 
before
  @@ -787,13 +806,13 @@
                 || uri.equals("http://xsl.lotus.com";))
           return true;
   
  -      if (getStylesheet().containsExcludeResultPrefix(prefix))
  +      if (containsExcludeResultPrefix(prefix))
           return true;
       }
   
       return false;
     }
  -
  +  
     /**
      * Combine the parent's namespaces with this namespace
      * for fast processing, taking care to reference the
  
  
  
  1.18      +2 -2      
xml-xalan/java/src/org/apache/xalan/templates/Stylesheet.java
  
  Index: Stylesheet.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/templates/Stylesheet.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- Stylesheet.java   2000/11/30 09:57:32     1.17
  +++ Stylesheet.java   2000/12/02 00:28:17     1.18
  @@ -383,9 +383,9 @@
      * the "extension-element-prefixes" property.
      * @see <a 
href="http://www.w3.org/TR/xslt#extension-element";>extension-element in XSLT 
Specification</a>
      *
  -   * NEEDSDOC @param prefix
  +   * @param prefix non-null reference to prefix that might be excluded.
      *
  -   * NEEDSDOC ($objectName$) @return
  +   * @return true if the prefix should normally be excluded.
      */
     public boolean containsExcludeResultPrefix(String prefix)
     {
  
  
  
  1.4       +8 -9      
xml-xalan/java/src/org/apache/xalan/templates/XMLNSDecl.java
  
  Index: XMLNSDecl.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/templates/XMLNSDecl.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- XMLNSDecl.java    2000/10/30 18:50:08     1.3
  +++ XMLNSDecl.java    2000/12/02 00:28:17     1.4
  @@ -60,16 +60,15 @@
    * Represents an xmlns declaration
    */
   public class XMLNSDecl
  -     implements java.io.Serializable // 20001009 jkess
  +        implements java.io.Serializable // 20001009 jkess
   {
   
     /**
      * Constructor XMLNSDecl
      *
  -   *
  -   * NEEDSDOC @param prefix
  -   * NEEDSDOC @param uri
  -   * NEEDSDOC @param isExcluded
  +   * @param prefix non-null reference to prefix, using "" for default 
namespace.
  +   * @param uri non-null reference to namespace URI.
  +   * @param isExcluded true if this namespace declaration should normally be 
excluded.
      */
     public XMLNSDecl(String prefix, String uri, boolean isExcluded)
     {
  @@ -79,7 +78,7 @@
       m_isExcluded = isExcluded;
     }
   
  -  /** NEEDSDOC Field m_prefix          */
  +  /** non-null reference to prefix, using "" for default namespace. */
     private String m_prefix;
   
     /**
  @@ -92,7 +91,7 @@
       return m_prefix;
     }
   
  -  /** NEEDSDOC Field m_uri          */
  +  /** non-null reference to namespace URI  */
     private String m_uri;
   
     /**
  @@ -104,14 +103,14 @@
       return m_uri;
     }
   
  -  /** NEEDSDOC Field m_isExcluded          */
  +  /** true if this namespace declaration should normally be excluded.  */
     private boolean m_isExcluded;
   
     /**
      * Tell if this declaration should be excluded from the
      * result namespace.
      *
  -   * NEEDSDOC ($objectName$) @return
  +   * @return true if this namespace declaration should normally be excluded.
      */
     public boolean getIsExcluded()
     {
  
  
  

Reply via email to