Source:
public void testCustomElements ( ) throws java.io.IOException , javax.xml.parsers.ParserConfigurationException , org.xml.sax.SAXException { java.lang.String main = "" + ( ( ( ( ( ( ( ( ( "<manifest\n" + " xmlns:android=\"http://schemas.android.com/apk/res/android\"\n" ) + " package=\"com.example.lib3\">\n" ) + "\n" ) + " <fantasy android:name=\"fantasyOne\" \n" ) + " no-ns-attribute=\"no-ns\" >\n" ) + " </fantasy>\n" ) + " <application android:label=\"@string/lib_name\" />\n" ) + "\n" ) + "</manifest>" ) ; java.lang.String library = "" + ( ( ( ( ( ( ( ( ( ( ( ( ( ( "<manifest\n" + " xmlns:android=\"http://schemas.android.com/apk/res/android\"\n" ) + " xmlns:acme=\"http://acme.org/schemas\"\n" ) + " package=\"com.example.lib3\">\n" ) + "\n" ) + " <activity android:name=\"activityOne\" />\n" ) + " <fantasy android:name=\"fantasyTwo\" \n" ) + " no-ns-attribute=\"no-ns\" >\n" ) + " </fantasy>\n" ) + " <acme:another acme:name=\"anotherOne\" \n" ) + " acme:ns-attribute=\"ns-value\" >\n" ) + " <some-child acme:child-attr=\"foo\" /> \n" ) + " </acme:another>\n" ) + "\n" ) + "</manifest>" ) ; com.android.manifmerger.XmlDocument mainDocument = com.android.manifmerger.TestUtils.xmlDocumentFromString ( new com.android.manifmerger.TestUtils.TestSourceLocation ( getClass ( ) , "main" ) , main ) ; com.android.manifmerger.XmlDocument libraryDocument = com.android.manifmerger.TestUtils.xmlDocumentFromString ( new com.android.manifmerger.TestUtils.TestSourceLocation ( getClass ( ) , "library" ) , library ) ; com.android.manifmerger.MergingReport.Builder mergingReportBuilder = new com.android.manifmerger.MergingReport.Builder ( mLogger ) ; com.google.common.base.Optional < com.android.manifmerger.XmlDocument > mergedDocument = mainDocument.merge ( libraryDocument , mergingReportBuilder ) ; assertTrue ( mergedDocument.isPresent ( ) ) ; java.util.logging.Logger.getAnonymousLogger ( ) . info ( mergedDocument.get ( ) . prettyPrint ( ) ) ; com.android.manifmerger.XmlElement rootNode = mergedDocument.get ( ) . getRootNode ( ) ; assertTrue ( rootNode.getNodeByTypeAndKey ( ManifestModel.NodeTypes.APPLICATION , null ) . isPresent ( ) ) ; com.google.common.base.Optional < com.android.manifmerger.XmlElement > activityOne = rootNode.getNodeByTypeAndKey ( ManifestModel.NodeTypes.ACTIVITY , "com.example.lib3.activityOne" ) ; assertTrue ( activityOne.isPresent ( ) ) ; boolean foundFantasyOne = false ; boolean foundFantasyTwo = false ; boolean foundAnother = false ; org.w3c.dom.NodeList childNodes = rootNode.getXml ( ) . getChildNodes ( ) ; for ( int i = 0 ; i < ( childNodes.getLength ( ) ) ; i ++ ) { org.w3c.dom.Node item = childNodes.item ( i ) ; if ( item.getNodeName ( ) . equals ( "fantasy" ) ) { java.lang.String name = ( ( org.w3c.dom.Element ) ( item ) ) . getAttributeNS ( SdkConstants.ANDROID_URI , "name" ) ; if ( name.equals ( "fantasyOne" ) ) foundFantasyOne = true ; if ( name.equals ( "fantasyTwo" ) ) foundFantasyTwo = true ; } if ( item.getNodeName ( ) . equals ( "acme:another" ) ) { foundAnother = true ; } } assertTrue ( foundAnother ) ; assertTrue ( foundFantasyOne ) ; assertTrue ( foundFantasyTwo ) ; }

Target:
public void testCustomElements ( ) throws java.io.IOException , javax.xml.parsers.ParserConfigurationException , org.xml.sax.SAXException { java.lang.String main = "" + ( ( ( ( ( ( ( ( ( "<manifest\n" + " xmlns:android=\"http://schemas.android.com/apk/res/android\"\n" ) + " package=\"com.example.lib3\">\n" ) + "\n" ) + " <fantasy android:name=\"fantasyOne\" \n" ) + " no-ns-attribute=\"no-ns\" >\n" ) + " </fantasy>\n" ) + " <application android:label=\"@string/lib_name\" />\n" ) + "\n" ) + "</manifest>" ) ; java.lang.String library = "" + ( ( ( ( ( ( ( ( ( ( ( ( ( ( "<manifest\n" + " xmlns:android=\"http://schemas.android.com/apk/res/android\"\n" ) + " xmlns:acme=\"http://acme.org/schemas\"\n" ) + " package=\"com.example.lib3\">\n" ) + "\n" ) + " <activity android:name=\"activityOne\" />\n" ) + " <fantasy android:name=\"fantasyTwo\" \n" ) + " no-ns-attribute=\"no-ns\" >\n" ) + " </fantasy>\n" ) + " <acme:another acme:name=\"anotherOne\" \n" ) + " acme:ns-attribute=\"ns-value\" >\n" ) + " <some-child acme:child-attr=\"foo\" /> \n" ) + " </acme:another>\n" ) + "\n" ) + "</manifest>" ) ; com.android.manifmerger.XmlDocument mainDocument = com.android.manifmerger.TestUtils.xmlDocumentFromString ( new com.android.manifmerger.TestUtils.TestSourceLocation ( getClass ( ) , "main" ) , main ) ; com.android.manifmerger.XmlDocument libraryDocument = com.android.manifmerger.TestUtils.xmlDocumentFromString ( new com.android.manifmerger.TestUtils.TestSourceLocation ( getClass ( ) , "library" ) , library ) ; com.android.manifmerger.MergingReport.Builder mergingReportBuilder = new com.android.manifmerger.MergingReport.Builder ( mLogger ) ; com.google.common.base.Optional < com.android.manifmerger.XmlDocument > mergedDocument = mainDocument.merge ( libraryDocument , mergingReportBuilder ) ; assertTrue ( mergedDocument.isPresent ( ) ) ; com.android.manifmerger.XmlElement rootNode = mergedDocument.get ( ) . getRootNode ( ) ; assertTrue ( rootNode.getNodeByTypeAndKey ( ManifestModel.NodeTypes.APPLICATION , null ) . isPresent ( ) ) ; com.google.common.base.Optional < com.android.manifmerger.XmlElement > activityOne = rootNode.getNodeByTypeAndKey ( ManifestModel.NodeTypes.ACTIVITY , "com.example.lib3.activityOne" ) ; assertTrue ( activityOne.isPresent ( ) ) ; boolean foundFantasyOne = false ; boolean foundFantasyTwo = false ; boolean foundAnother = false ; org.w3c.dom.NodeList childNodes = rootNode.getXml ( ) . getChildNodes ( ) ; for ( int i = 0 ; i < ( childNodes.getLength ( ) ) ; i ++ ) { org.w3c.dom.Node item = childNodes.item ( i ) ; if ( item.getNodeName ( ) . equals ( "fantasy" ) ) { java.lang.String name = ( ( org.w3c.dom.Element ) ( item ) ) . getAttributeNS ( SdkConstants.ANDROID_URI , "name" ) ; if ( name.equals ( "fantasyOne" ) ) foundFantasyOne = true ; if ( name.equals ( "fantasyTwo" ) ) foundFantasyTwo = true ; } if ( item.getNodeName ( ) . equals ( "acme:another" ) ) { foundAnother = true ; } } assertTrue ( foundAnother ) ; assertTrue ( foundFantasyOne ) ; assertTrue ( foundFantasyTwo ) ; org.w3c.dom.Element validated = com.android.manifmerger.XmlDocumentTest.validate ( mergedDocument.get ( ) . prettyPrint ( ) ) ; org.w3c.dom.Node namedItem = validated.getAttributes ( ) . getNamedItem ( "xmlns:acme" ) ; assertEquals ( namedItem.getNodeValue ( ) , "http://acme.org/schemas" ) ; }