本文整理汇总了Java中org.xml.sax.helpers.NamespaceSupport.processName方法的典型用法代码示例。如果您正苦于以下问题:Java NamespaceSupport.processName方法的具体用法?Java NamespaceSupport.processName怎么用?Java NamespaceSupport.processName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.xml.sax.helpers.NamespaceSupport
的用法示例。
在下文中一共展示了NamespaceSupport.processName方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testProcessName
import org.xml.sax.helpers.NamespaceSupport; //导入方法依赖的package包/类
@Test
public void testProcessName() {
NamespaceSupport nssupport = new NamespaceSupport();
nssupport.pushContext();
nssupport.declarePrefix("", "http://www.java.com");
nssupport.declarePrefix("dc", "http://www.purl.org/dc");
String[] parts = new String[3];
nssupport.processName("dc:name1", parts, false);
Assert.assertTrue(parts[0].equals("http://www.purl.org/dc"));
Assert.assertTrue(parts[1].equals("name1"));
Assert.assertTrue(parts[2].equals("dc:name1"));
nssupport.processName("name2", parts, false);
Assert.assertTrue(parts[0].equals("http://www.java.com"));
Assert.assertTrue(parts[1].equals("name2"));
Assert.assertTrue(parts[2].equals("name2"));
}
示例2: testPopContext
import org.xml.sax.helpers.NamespaceSupport; //导入方法依赖的package包/类
@Test
public void testPopContext() {
String[] parts = new String[3];
NamespaceSupport nssupport = new NamespaceSupport();
nssupport.pushContext();
nssupport.declarePrefix("dc", "http://www.purl.org/dc");
Assert.assertEquals(nssupport.getPrefix("http://www.purl.org/dc"), "dc");
nssupport.popContext();
Assert.assertNull(nssupport.getPrefix("http://www.purl.org/dc"));
nssupport.processName("dc:name1", parts, false);
Assert.assertNull(parts[0]);
Assert.assertNull(parts[1]);
Assert.assertNull(parts[2]);
}
示例3: testNamespaceDeclUris
import org.xml.sax.helpers.NamespaceSupport; //导入方法依赖的package包/类
@Test
public void testNamespaceDeclUris() {
String[] parts = new String[3];
NamespaceSupport nssupport = new NamespaceSupport();
nssupport.pushContext();
Assert.assertFalse(nssupport.isNamespaceDeclUris());
nssupport.declarePrefix("xmlns", "");
nssupport.processName("xmlns:name", parts, true);
Assert.assertNull(parts[0]);
Assert.assertNull(parts[1]);
Assert.assertNull(parts[2]);
nssupport.reset();
nssupport.setNamespaceDeclUris(true);
nssupport.declarePrefix("xmlns", "");
nssupport.processName("xmlns:name", parts, true);
Assert.assertTrue(parts[0].equals(NamespaceSupport.NSDECL));
Assert.assertTrue(parts[1].equals("name"));
Assert.assertTrue(parts[2].equals("xmlns:name"));
nssupport.reset();
nssupport.setNamespaceDeclUris(true);
nssupport.declarePrefix("xml", "");
nssupport.processName("xml:name", parts, true);
Assert.assertTrue(parts[0].equals(NamespaceSupport.XMLNS));
Assert.assertTrue(parts[1].equals("name"));
Assert.assertTrue(parts[2].equals("xml:name"));
}
示例4: testcase02
import org.xml.sax.helpers.NamespaceSupport; //导入方法依赖的package包/类
/**
* Test for NamespaceSupport.getDeclaredPrefixes() and support.processName().
*/
@Test
public void testcase02() {
String[] parts = new String[3];
NamespaceSupport support = new NamespaceSupport();
support.pushContext();
support.declarePrefix(DC_PREFIX, PURL_URI);
parts = support.processName("dc:title", parts, false);
support.popContext();
assertEquals(parts, new String[]{PURL_URI, "title", "dc:title"});
}
示例5: testcase03
import org.xml.sax.helpers.NamespaceSupport; //导入方法依赖的package包/类
/**
* Test for NamespaceSupport.getDeclaredPrefixes() and support.processName().
*/
@Test
public void testcase03() {
String[] parts = new String[3];
NamespaceSupport support = new NamespaceSupport();
support.pushContext();
support.declarePrefix(EMPTY_PREFIX, W3_URI);
parts = support.processName("a", parts, false);
support.popContext();
assertEquals(parts, new String[]{W3_URI, "a", "a"});
}