*/
@Test
public void testXPathwithAlienNodes() throws Exception {
try {
OdfPresentationDocument odpWithSlides = OdfPresentationDocument.loadDocument(ResourceUtilities.getAbsolutePath(SOURCE_FILE_1));
OdfFileDom contentDom = odpWithSlides.getContentDom();
XPath xpath = contentDom.getXPath();
// Test scenario 1 - see comment above
Iterator<String> prefixes = contentDom.getPrefixes("urn:oasis:names:tc:opendocument:xmlns:office:1.0");
// The first prefix have to be "office"
String prefix = prefixes.next();
Assert.assertTrue(prefix.equals("office") || prefix.equals("daisy"));
if(prefix.equals("office")){
prefix = prefixes.next();
Assert.assertTrue(prefix.equals("daisy"));
}else if(prefix.equals("daisy")){
prefix = prefixes.next();
Assert.assertTrue(prefix.equals("office"));
}else{
Assert.fail();
}
// There should be no further prefix
Assert.assertFalse(prefixes.hasNext());
Iterator<String> prefixes2 = contentDom.getPrefixes("urn://some-test-odfdom-namespace");
prefix = prefixes2.next();
Assert.assertTrue(prefix.equals("prefixOne") || prefix.equals("prefixTwo"));
if(prefix.equals("prefixOne")){
prefix = prefixes2.next();
Assert.assertTrue(prefix.equals("prefixTwo"));
}else if(prefix.equals("prefixTwo")){
prefix = prefixes2.next();
Assert.assertTrue(prefix.equals("prefixOne"));
}else{
Assert.fail();
}
// There should be no further prefix
Assert.assertFalse(prefixes.hasNext());
Node node = contentDom.getRootElement();
odpWithSlides.save(ResourceUtilities.newTestOutputFile("XPathTest-ForeignPrefix-output.odp"));
if (node instanceof OdfAlienElement) {
Assert.fail("The none OOO default prefix for office: was not exchanged!");
}