public void onElementStart ( @ Nullable final String sNamespacePrefix , @ Nonnull final String sTagName , @ Nullable final Map < QName , String > aAttrs , @ Nonnull final EXMLSerializeBracketMode eBracketMode ) { elementStartOpen ( sNamespacePrefix , sTagName ) ; if ( aAttrs != null && ! aAttrs . isEmpty ( ) ) { if ( m_bOrderAttributesAndNamespaces ) { // first separate in NS and non-NS attributes // Sort namespace attributes by assigned prefix final ICommonsSortedMap < QName , String > aNamespaceAttrs = new CommonsTreeMap <> ( CXML . getComparatorQNameForNamespacePrefix ( ) ) ; final ICommonsSortedMap < QName , String > aNonNamespaceAttrs = new CommonsTreeMap <> ( CXML . getComparatorQNameNamespaceURIBeforeLocalPart ( ) ) ; for ( final Map . Entry < QName , String > aEntry : aAttrs . entrySet ( ) ) { final QName aAttrName = aEntry . getKey ( ) ; if ( XMLConstants . XMLNS_ATTRIBUTE_NS_URI . equals ( aAttrName . getNamespaceURI ( ) ) ) aNamespaceAttrs . put ( aAttrName , aEntry . getValue ( ) ) ; else aNonNamespaceAttrs . put ( aAttrName , aEntry . getValue ( ) ) ; } // emit namespace attributes first for ( final Map . Entry < QName , String > aEntry : aNamespaceAttrs . entrySet ( ) ) { final QName aAttrName = aEntry . getKey ( ) ; elementAttr ( aAttrName . getPrefix ( ) , aAttrName . getLocalPart ( ) , aEntry . getValue ( ) ) ; } // emit non-namespace attributes afterwards for ( final Map . Entry < QName , String > aEntry : aNonNamespaceAttrs . entrySet ( ) ) { final QName aAttrName = aEntry . getKey ( ) ; elementAttr ( aAttrName . getPrefix ( ) , aAttrName . getLocalPart ( ) , aEntry . getValue ( ) ) ; } } else { // assuming that the order of the passed attributes is consistent! // Emit all attributes for ( final Map . Entry < QName , String > aEntry : aAttrs . entrySet ( ) ) { final QName aAttrName = aEntry . getKey ( ) ; elementAttr ( aAttrName . getPrefix ( ) , aAttrName . getLocalPart ( ) , aEntry . getValue ( ) ) ; } } } elementStartClose ( eBracketMode ) ; }
Start of an element .