本文整理汇总了Java中javax.xml.stream.XMLStreamReader.getPrefix方法的典型用法代码示例。如果您正苦于以下问题:Java XMLStreamReader.getPrefix方法的具体用法?Java XMLStreamReader.getPrefix怎么用?Java XMLStreamReader.getPrefix使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.xml.stream.XMLStreamReader
的用法示例。
在下文中一共展示了XMLStreamReader.getPrefix方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: printName
import javax.xml.stream.XMLStreamReader; //导入方法依赖的package包/类
protected static void printName(XMLStreamReader xmlr) {
if (xmlr.hasName()) {
String prefix = xmlr.getPrefix();
String uri = xmlr.getNamespaceURI();
String localName = xmlr.getLocalName();
printName(prefix, uri, localName);
}
}
示例2: assertNoPrefix
import javax.xml.stream.XMLStreamReader; //导入方法依赖的package包/类
/**
* Specific method makes sense, since earlier it was not clear whether null
* or empty string (or perhaps both) would be the right answer when there is
* no prefix.
* <p>
* However: as per javadocs of {@link XMLStreamReader#getPrefix}, from JDK
* 1.6 indicate, the current understanding is that <b>null</b> is the
* ultimate right answer here.
*/
protected static void assertNoPrefix(XMLStreamReader sr) throws XMLStreamException {
String prefix = sr.getPrefix();
if (prefix != null) {
if (prefix.length() != 0) {
Assert.fail("Current element should not have a prefix: got '" + prefix + "'");
} else {
Assert.fail("Expected null to signify missing prefix (see XMLStreamReader#getPrefix() JavaDocs): got empty String");
}
}
}