本文整理汇总了Java中javax.xml.stream.XMLStreamReader.getNamespaceURI方法的典型用法代码示例。如果您正苦于以下问题:Java XMLStreamReader.getNamespaceURI方法的具体用法?Java XMLStreamReader.getNamespaceURI怎么用?Java XMLStreamReader.getNamespaceURI使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.xml.stream.XMLStreamReader
的用法示例。
在下文中一共展示了XMLStreamReader.getNamespaceURI方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isCim14
import javax.xml.stream.XMLStreamReader; //导入方法依赖的package包/类
private static boolean isCim14(InputStream is) throws XMLStreamException {
// check the first root element is RDF and the second one belongs to CIM 14 namespace
XMLStreamReader xmlsr = XML_INPUT_FACTORY_SUPPLIER.get().createXMLStreamReader(is);
try {
int elemIndex = 0;
while (xmlsr.hasNext()) {
int eventType = xmlsr.next();
if (eventType == XMLEvent.START_ELEMENT) {
String ns = xmlsr.getNamespaceURI();
if (elemIndex == 0) {
if (!RDF_NS.equals(ns)) {
return false;
}
} else if (elemIndex == 1) {
return CIM14_NS.equals(ns);
} else {
throw new AssertionError();
}
elemIndex++;
}
}
} finally {
xmlsr.close();
}
return false;
}
示例2: decode
import javax.xml.stream.XMLStreamReader; //导入方法依赖的package包/类
public static final Message decode(SOAPVersion soapVersion, XMLStreamReader reader, @NotNull AttachmentSet attachmentSet) {
// Move to soap:Envelope and verify
if(reader.getEventType()!=XMLStreamConstants.START_ELEMENT)
XMLStreamReaderUtil.nextElementContent(reader);
XMLStreamReaderUtil.verifyReaderState(reader,XMLStreamConstants.START_ELEMENT);
if (SOAP_ENVELOPE.equals(reader.getLocalName()) && !soapVersion.nsUri.equals(reader.getNamespaceURI())) {
throw new VersionMismatchException(soapVersion, soapVersion.nsUri, reader.getNamespaceURI());
}
XMLStreamReaderUtil.verifyTag(reader, soapVersion.nsUri, SOAP_ENVELOPE);
return new StreamMessage(soapVersion, reader, attachmentSet);
}
示例3: verifyTag
import javax.xml.stream.XMLStreamReader; //导入方法依赖的package包/类
public static void verifyTag(XMLStreamReader reader, String namespaceURI, String localName) {
if (!localName.equals(reader.getLocalName()) || !namespaceURI.equals(reader.getNamespaceURI())) {
throw new XMLStreamReaderException(
"xmlreader.unexpectedState.tag",
"{" + namespaceURI + "}" + localName,
"{" + reader.getNamespaceURI() + "}" + reader.getLocalName());
}
}
示例4: AttributesImpl
import javax.xml.stream.XMLStreamReader; //导入方法依赖的package包/类
public AttributesImpl(XMLStreamReader reader) {
if (reader == null) {
// this is the case when we call getAttributes() on the
// reader when it is not on a start tag
atInfos = new AttributeInfo[0];
} else {
// this is the normal case
int index = 0;
int namespaceCount = reader.getNamespaceCount();
int attributeCount = reader.getAttributeCount();
atInfos = new AttributeInfo[namespaceCount + attributeCount];
for (int i=0; i<namespaceCount; i++) {
String namespacePrefix = reader.getNamespacePrefix(i);
// will be null if default prefix. QName can't take null
if (namespacePrefix == null) {
namespacePrefix = "";
}
atInfos[index++] = new AttributeInfo(
new QName(XMLNS_NAMESPACE_URI,
namespacePrefix,
"xmlns"),
reader.getNamespaceURI(i));
}
for (int i=0; i<attributeCount; i++) {
atInfos[index++] = new AttributeInfo(
reader.getAttributeName(i),
reader.getAttributeValue(i));
}
}
}
示例5: 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);
}
}
示例6: printNamespace
import javax.xml.stream.XMLStreamReader; //导入方法依赖的package包/类
protected static void printNamespace(XMLStreamReader xmlr, int index) {
String prefix = xmlr.getNamespacePrefix(index);
String uri = xmlr.getNamespaceURI(index);
System.out.print(" ");
if (prefix == null)
System.out.print("xmlns='" + uri + "'");
else
System.out.print("xmlns:" + prefix + "='" + uri + "'");
}
示例7: assertNoNsURI
import javax.xml.stream.XMLStreamReader; //导入方法依赖的package包/类
/**
* Similar to {@link #assertNoPrefix}, but here we do know that unbound
* namespace URI should be indicated as empty String.
*/
protected static void assertNoNsURI(XMLStreamReader sr) throws XMLStreamException {
String uri = sr.getNamespaceURI();
if (uri == null) {
Assert.fail("Expected empty String to indicate \"no namespace\": got null");
} else if (uri.length() != 0) {
Assert.fail("Expected empty String to indicate \"no namespace\": got '" + uri + "'");
}
}
示例8: getQName
import javax.xml.stream.XMLStreamReader; //导入方法依赖的package包/类
public static QName getQName(XMLStreamReader reader, String tag){
String localName = XmlUtil.getLocalPart(tag);
String pfix = XmlUtil.getPrefix(tag);
String uri = reader.getNamespaceURI(fixNull(pfix));
return new QName(uri, localName);
}
示例9: StreamHeader
import javax.xml.stream.XMLStreamReader; //导入方法依赖的package包/类
/**
* Creates a {@link StreamHeader}.
*
* @param reader
* The parser that points to the start tag of the header.
* By the end of this method, the parser will point at
* the end tag of this element.
*/
protected StreamHeader(XMLStreamReader reader) throws XMLStreamException {
_localName = reader.getLocalName();
_namespaceURI = reader.getNamespaceURI();
attributes = processHeaderAttributes(reader);
// cache the body
_mark = XMLStreamBuffer.createNewBufferFromXMLStreamReader(reader);
}