code:   Attributes setPropertiesFromAttributes(
            StylesheetHandler handler, String rawName, Attributes attributes, 
            ElemTemplateElement target, boolean throwError)
              throws org.xml.sax.SAXException
    {
  
      XSLTElementDef def = getElemDef();
      AttributesImpl undefines = null;
      boolean isCompatibleMode = ((null != handler.getStylesheet() 
                                   && handler.getStylesheet().getCompatibleMode())
                                  || !throwError);
      if (isCompatibleMode)
        undefines = new AttributesImpl();
  
  
      // Keep track of which XSLTAttributeDefs have been processed, so 
      // I can see which default values need to be set.
      List processedDefs = new ArrayList();
  
      // Keep track of XSLTAttributeDefs that were invalid
      List errorDefs = new ArrayList();    
      int nAttrs = attributes.getLength();
  
      for (int i = 0; i < nAttrs; i++)
      {
        String attrUri = attributes.getURI(i);
        // Hack for Crimson.  -sb
        if((null != attrUri) && (attrUri.length() == 0)
                             && (attributes.getQName(i).startsWith("xmlns:") || 
                                 attributes.getQName(i).equals("xmlns")))
        {
          attrUri = org.apache.xalan.templates.Constants.S_XMLNAMESPACEURI;
        }
        String attrLocalName = attributes.getLocalName(i);
        XSLTAttributeDef attrDef = def.getAttributeDef(attrUri, attrLocalName);
  
        if (null == attrDef)
        {
          if (!isCompatibleMode)
          {
  
            // Then barf, because this element does not allow this attribute.
            handler.error(XSLTErrorResources.ER_ATTR_NOT_ALLOWED, new Object[]{attributes.getQName(i), rawName}, null);//"\""+attributes.getQName(i)+"\""
                          //+ " attribute is not allowed on the " + rawName
                         // + " element!", null);
          }
          else
          {
            undefines.addAttribute(attrUri, attrLocalName,
                                   attributes.getQName(i),
                                   attributes.getType(i),
                                   attributes.getValue(i));
          }
        }
        else
        {
          //handle secure processing
          if(handler.getStylesheetProcessor()==null)
              System.out.println("stylesheet processor null");
          if(attrDef.getName().compareTo("*")==0 && handler.getStylesheetProcessor().isSecureProcessing())
          {
              //foreign attributes are not allowed in secure processing mode
              // Then barf, because this element does not allow this attribute.
              handler.error(XSLTErrorResources.ER_ATTR_NOT_ALLOWED, new Object[]{attributes.getQName(i), rawName}, null);//"\""+attributes.getQName(i)+"\""
              //+ " attribute is not allowed on the " + rawName
              // + " element!", null);
          }
          else
          {
  
  
              boolean success = attrDef.setAttrValue(handler, attrUri, attrLocalName,
                                   attributes.getQName(i), attributes.getValue(i),
                                   target);
  
              // Now we only add the element if it passed a validation check
              if (success)
                  processedDefs.add(attrDef);
              else
                  errorDefs.add(attrDef);
          }
        }
      }
  
      XSLTAttributeDef[] attrDefs = def.getAttributes();
      int nAttrDefs = attrDefs.length;
  
      for (int i = 0; i < nAttrDefs; i++)
      {
        XSLTAttributeDef attrDef = attrDefs[i];
        String defVal = attrDef.getDefault();
  
        if (null != defVal)
        {
          if (!processedDefs.contains(attrDef))
          {
            attrDef.setDefAttrValue(handler, target);
          }
        }
  
        if (attrDef.getRequired())
        {
          if ((!processedDefs.contains(attrDef)) && (!errorDefs.contains(attrDef)))
            handler.error(
              XSLMessages.createMessage(
                XSLTErrorResources.ER_REQUIRES_ATTRIB, new Object[]{ rawName,
                                                                     attrDef.getName() }), null);
        }
      }
  
      return undefines;
    }
  