當前位置: 首頁>>代碼示例>>Java>>正文


Java XMLStreamReader.getNamespaceURI方法代碼示例

本文整理匯總了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;
}
 
開發者ID:powsybl,項目名稱:powsybl-core,代碼行數:27,代碼來源:CIM1Importer.java

示例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);
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:12,代碼來源:StreamSOAPCodec.java

示例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());
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:9,代碼來源:XMLStreamReaderUtil.java

示例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));
        }
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:34,代碼來源:XMLStreamReaderUtil.java

示例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);
  }
}
 
開發者ID:ModelWriter,項目名稱:Tarski,代碼行數:9,代碼來源:XMLStreamHelper.java

示例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 + "'");
}
 
開發者ID:ModelWriter,項目名稱:Tarski,代碼行數:10,代碼來源:XMLStreamHelper.java

示例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 + "'");
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:13,代碼來源:BaseStAXUT.java

示例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);
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:7,代碼來源:ParserUtil.java

示例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);
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:16,代碼來源:StreamHeader.java


注:本文中的javax.xml.stream.XMLStreamReader.getNamespaceURI方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。