ilene       2002/09/25 07:20:49

  Modified:    java/src/org/apache/xalan/transformer ResultTreeHandler.java
  Log:
  Patch for bugzilla #4344.  The testcases, copyerr04-07 were already
  working correctly in that when an attempt was made to add an attribute
  after child elements, or before an element was produced, the attribute was 
  ignored.  However, Dave M.  said that a warning was also needed.  So,
  I have added a warning message for these cases.  Also, similar behaviour
  was being seen for testcases attribset19,35,36 and attribseterr08.  This
  was being handled in ElemAttribute.execute, but I've commented out the
  code there since it will get caught in  ResultTreeHandler.execute in the
  same place the copyerr tests get handled.
  
  The negative testcases, copyerr04-07, attribset08 should  be moved
  to the positive bucket (possibly with a few tweaks) since they all run to
  completion.
  
  Revision  Changes    Path
  1.57      +31 -21    
xml-xalan/java/src/org/apache/xalan/transformer/ResultTreeHandler.java
  
  Index: ResultTreeHandler.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/transformer/ResultTreeHandler.java,v
  retrieving revision 1.56
  retrieving revision 1.57
  diff -u -r1.56 -r1.57
  --- ResultTreeHandler.java    19 Jul 2002 19:57:54 -0000      1.56
  +++ ResultTreeHandler.java    25 Sep 2002 14:20:49 -0000      1.57
  @@ -58,6 +58,8 @@
   
   import java.util.Enumeration;
   
  +import org.apache.xalan.processor.StylesheetHandler;
  +import org.apache.xalan.res.XSLTErrorResources;
   import org.apache.xalan.templates.Stylesheet;
   import org.apache.xalan.templates.StylesheetRoot;
   import org.apache.xalan.templates.ElemTemplate;
  @@ -1429,34 +1431,42 @@
       // an error? Technically, this can't happen unless the stylesheet
       // is unreasonable... but it's unclear whether silent or noisy
       // failure is called for.
  +    // Will add an "else" and emit a warning message.  This should
  +    // cover testcases such as copyerr04-07, attribset19,34,35, 
  +    // attribseterr08...(is)
       if (m_elemIsPending)
       {
  -      // %REVIEW% %OPT% Is this ever needed?????
  -      // The check is not needed. See Bugzilla 10306. 
  -      // if (!m_nsDeclsHaveBeenAdded)
  -     addNSDeclsToAttrs();
  +        // %REVIEW% %OPT% Is this ever needed?????
  +        // The check is not needed. See Bugzilla 10306. 
  +        // if (!m_nsDeclsHaveBeenAdded)
  +        addNSDeclsToAttrs();
   
  -      if (null == uri)  // defensive, should not really need this.
  -     uri = "";
  +        if (null == uri) { // defensive, should not really need this.
  +            uri = "";
  +        }
   
  -      try
  -      {
  -     if (!rawName.equals("xmlns"))  // don't handle xmlns default namespace.
  -       ensurePrefixIsDeclared(uri, rawName);
  -      }
  -      catch (org.xml.sax.SAXException se)
  -      {
  -     throw new TransformerException(se);
  -      }
  +        try {
  +            if (!rawName.equals("xmlns")) { // don't handle xmlns default 
namespace.
  +                ensurePrefixIsDeclared(uri, rawName);
  +            }    
  +        } catch (org.xml.sax.SAXException se) {
  +            throw new TransformerException(se);
  +        }
         
  -      if (DEBUG)
  -     System.out.println("ResultTreeHandler#addAttribute Adding attr: "
  +        if (DEBUG) {
  +            System.out.println("ResultTreeHandler#addAttribute Adding attr: "
                           + localName + ", " + uri);
  -
  -      if (!isDefinedNSDecl(rawName, value))
  -     m_attributes.addAttribute(uri, localName, rawName, type, value);
  +        }
  +        
  +        if (!isDefinedNSDecl(rawName, value)) {
  +            m_attributes.addAttribute(uri, localName, rawName, type, value);
  +        }
  +    } else {
  +        m_transformer.getMsgMgr().warn(m_stylesheetRoot,
  +                                   
XSLTErrorResources.WG_ILLEGAL_ATTRIBUTE_POSITION,
  +                                   new Object[]{ localName });
       }
  -  }
  +}
   
     /**
      * Return whether or not a namespace declaration is defined
  
  
  

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

Reply via email to