public DTDAttribute addNsDefault ( InputProblemReporter rep , PrefixedName attrName , int valueType , DefaultAttrValue defValue , boolean fullyValidate ) throws XMLStreamException { /* Let's simplify handling a bit: although theoretically all * combinations of value can be used, let's really only differentiate * between CDATA and 'other' (for which let's use NMTOKEN) */ DTDAttribute nsAttr ; switch ( valueType ) { case DTDAttribute . TYPE_CDATA : nsAttr = new DTDCdataAttr ( attrName , defValue , - 1 , mNsAware , mXml11 ) ; break ; default : // something else, default to NMTOKEN then nsAttr = new DTDNmTokenAttr ( attrName , defValue , - 1 , mNsAware , mXml11 ) ; break ; } // Ok. So which prefix are we to bind? Need to access by prefix... String prefix = attrName . getPrefix ( ) ; if ( prefix == null || prefix . length ( ) == 0 ) { // defult NS -> "" prefix = "" ; } else { // non-default, use the local name prefix = attrName . getLocalName ( ) ; } if ( mNsDefaults == null ) { mNsDefaults = new HashMap < String , DTDAttribute > ( ) ; } else { if ( mNsDefaults . containsKey ( prefix ) ) { return null ; } } mNsDefaults . put ( prefix , nsAttr ) ; return nsAttr ; }
Method called to add a definition of a namespace - declaration pseudo - attribute with a default value .