boolean setAttrValue ( StylesheetHandler handler , String attrUri , String attrLocalName , String attrRawName , String attrValue , ElemTemplateElement elem ) throws org . xml . sax . SAXException { if ( attrRawName . equals ( "xmlns" ) || attrRawName . startsWith ( "xmlns:" ) ) return true ; String setterString = getSetterMethodName ( ) ; // If this is null, then it is a foreign namespace and we // do not process it. if ( null != setterString ) { try { Method meth ; Object [ ] args ; if ( setterString . equals ( S_FOREIGNATTR_SETTER ) ) { // workaround for possible crimson bug if ( attrUri == null ) attrUri = "" ; // First try to match with the primative value. Class sclass = attrUri . getClass ( ) ; Class [ ] argTypes = new Class [ ] { sclass , sclass , sclass , sclass } ; meth = elem . getClass ( ) . getMethod ( setterString , argTypes ) ; args = new Object [ ] { attrUri , attrLocalName , attrRawName , attrValue } ; } else { Object value = processValue ( handler , attrUri , attrLocalName , attrRawName , attrValue , elem ) ; // If a warning was issued because the value for this attribute was // invalid, then the value will be null. Just return if ( null == value ) return false ; // First try to match with the primative value. Class [ ] argTypes = new Class [ ] { getPrimativeClass ( value ) } ; try { meth = elem . getClass ( ) . getMethod ( setterString , argTypes ) ; } catch ( NoSuchMethodException nsme ) { Class cl = ( ( Object ) value ) . getClass ( ) ; // If this doesn't work, try it with the non-primative value; argTypes [ 0 ] = cl ; meth = elem . getClass ( ) . getMethod ( setterString , argTypes ) ; } args = new Object [ ] { value } ; } meth . invoke ( elem , args ) ; } catch ( NoSuchMethodException nsme ) { if ( ! setterString . equals ( S_FOREIGNATTR_SETTER ) ) { handler . error ( XSLTErrorResources . ER_FAILED_CALLING_METHOD , new Object [ ] { setterString } , nsme ) ; //"Failed calling " + setterString + " method!", nsme); return false ; } } catch ( IllegalAccessException iae ) { handler . error ( XSLTErrorResources . ER_FAILED_CALLING_METHOD , new Object [ ] { setterString } , iae ) ; //"Failed calling " + setterString + " method!", iae); return false ; } catch ( InvocationTargetException nsme ) { handleError ( handler , XSLTErrorResources . WG_ILLEGAL_ATTRIBUTE_VALUE , new Object [ ] { Constants . ATTRNAME_NAME , getName ( ) } , nsme ) ; return false ; } } return true ; }
Set a value on an attribute .