mmidy       00/02/14 10:04:24

  Modified:    src/org/apache/xalan/xslt ElemAttribute.java
  Log:
  Override namespace prefix if there is a namespace attribute specified.
  
  Revision  Changes    Path
  1.8       +22 -15    xml-xalan/src/org/apache/xalan/xslt/ElemAttribute.java
  
  Index: ElemAttribute.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/src/org/apache/xalan/xslt/ElemAttribute.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- ElemAttribute.java        2000/01/26 20:57:24     1.7
  +++ ElemAttribute.java        2000/02/14 18:04:24     1.8
  @@ -121,11 +121,13 @@
       String attrName = m_name_avt.evaluate(execContext, sourceNode, this,
                                             new StringBuffer());
       String origAttrName = attrName;      // save original attribute name
  +    int indexOfNSSep = 0;
       if(null != attrName)
       {
  +      String attrNameSpace = null;
         if(null != m_namespace_avt)
         {
  -        String attrNameSpace = m_namespace_avt.evaluate(execContext, 
sourceNode, this,
  +        attrNameSpace = m_namespace_avt.evaluate(execContext, sourceNode, 
this,
                                                           new StringBuffer());
           if(null != attrNameSpace)
           {
  @@ -142,42 +144,47 @@
                                  processor.m_pendingAttributes, 
                                  nsDecl, attrNameSpace);
             }
  +          indexOfNSSep = origAttrName.indexOf(':');
  +          if(indexOfNSSep >= 0)          
  +            attrName = attrName.substring(indexOfNSSep+1);
             attrName = (prefix + ":"+attrName);       // add prefix to 
attribute name
           }
         }
         // Note we are using original attribute name for these tests. 
  -      if(null != processor.m_pendingElementName && 
!origAttrName.equals("xmlns"))
  +      else if(null != processor.m_pendingElementName && 
!origAttrName.equals("xmlns"))
         {
           // make sure that if a prefix is specified on the attribute name, it 
is valid
  -        int indexOfNSSep = origAttrName.indexOf(':');
  -        String ns ="" ;
  +        indexOfNSSep = origAttrName.indexOf(':');
           if(indexOfNSSep >= 0)
           {
             String nsprefix = origAttrName.substring(0, indexOfNSSep);
             // Catch the exception this may cause. We don't want to stop 
processing.
             try{
  -            ns = getNamespaceForPrefix(nsprefix);
  +            attrNameSpace = getNamespaceForPrefix(nsprefix);
             }
             catch(Exception ex) 
             {
               // Could not resolve prefix
  -            ns = null;
  +            attrNameSpace = null;
               processor.warn(XSLTErrorResources.WG_COULD_NOT_RESOLVE_PREFIX, 
new Object[]{nsprefix});            
             }
  -        } 
  -        if (indexOfNSSep<0 || ns != null)
  -        {  
  -          String val = childrenToString(processor, sourceTree, sourceNode, 
mode);
  -        
  -          addResultAttribute(processor.m_resultNameSpaces, 
  -                           processor.m_pendingAttributes, 
  -                           attrName, val);
  -        }  
  +        }
         }
         else
         {
  +        processor.warn(XSLTErrorResources.WG_ILLEGAL_ATTRIBUTE_NAME, new 
Object[]{origAttrName}); 
           // warn(templateChild, sourceNode, "Trying to add attribute after 
element child has been added, ignoring...");
         }
  +      if (indexOfNSSep<0 || attrNameSpace != null)
  +      {  
  +        String val = childrenToString(processor, sourceTree, sourceNode, 
mode);
  +        
  +        addResultAttribute(processor.m_resultNameSpaces, 
  +                           processor.m_pendingAttributes, 
  +                           attrName, val);
  +      }  
  +      
  +      
       }
     }
     
  
  
  

Reply via email to