public Element cloneSvgElement ( Element source ) { if ( source == null || source . getNodeName ( ) == null ) { return null ; } if ( "#text" . equals ( source . getNodeName ( ) ) ) { return Document . get ( ) . createTextNode ( source . getNodeValue ( ) ) . cast ( ) ; } Element clone = createElementNS ( Dom . NS_SVG , source . getNodeName ( ) , Dom . createUniqueId ( ) ) ; cloneAttributes ( source , clone ) ; for ( int i = 0 ; i < source . getChildCount ( ) ; i ++ ) { Element child = source . getChild ( i ) . cast ( ) ; clone . appendChild ( cloneSvgElement ( child ) ) ; } return clone ; }
Clone a single SVG element .