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


Java XMLStreamReader.getNamespaceCount方法代碼示例

本文整理匯總了Java中javax.xml.stream.XMLStreamReader.getNamespaceCount方法的典型用法代碼示例。如果您正苦於以下問題:Java XMLStreamReader.getNamespaceCount方法的具體用法?Java XMLStreamReader.getNamespaceCount怎麽用?Java XMLStreamReader.getNamespaceCount使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.xml.stream.XMLStreamReader的用法示例。


在下文中一共展示了XMLStreamReader.getNamespaceCount方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testNamespaceCount

import javax.xml.stream.XMLStreamReader; //導入方法依賴的package包/類
@Test
public void testNamespaceCount() {
    try {
        XMLInputFactory xif = XMLInputFactory.newInstance();
        xif.setProperty(XMLInputFactory.IS_NAMESPACE_AWARE, Boolean.TRUE);
        InputStream is = new java.io.ByteArrayInputStream(getXML().getBytes());
        XMLStreamReader sr = xif.createXMLStreamReader(is);
        while (sr.hasNext()) {
            int eventType = sr.next();
            if (eventType == XMLStreamConstants.START_ELEMENT) {
                if (sr.getLocalName().equals(rootElement)) {
                    int count = sr.getNamespaceCount();
                    Assert.assertTrue(count == 1);
                }
            }
        }
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:21,代碼來源:NamespaceTest.java

示例2: testNamespaceCount

import javax.xml.stream.XMLStreamReader; //導入方法依賴的package包/類
@Test
public void testNamespaceCount() {
    is = new java.io.ByteArrayInputStream(getXML().getBytes());
    try {
        XMLStreamReader sr = factory.createFilteredReader(factory.createXMLStreamReader(is), (StreamFilter) filter);
        while (sr.hasNext()) {
            int eventType = sr.next();
            if (eventType == XMLStreamConstants.START_ELEMENT) {
                if (sr.getLocalName().equals(rootElement)) {
                    int count = sr.getNamespaceCount();
                    Assert.assertTrue(count == 3);
                }
            }
        }
    } catch (Exception ex) {
        Assert.fail("Exception: " + ex.getMessage());
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:19,代碼來源:Bug6481678.java

示例3: storeElementWithInScopeNamespaces

import javax.xml.stream.XMLStreamReader; //導入方法依賴的package包/類
private void storeElementWithInScopeNamespaces(XMLStreamReader reader) {
    storeQualifiedName(T_ELEMENT_LN,
            reader.getPrefix(), reader.getNamespaceURI(), reader.getLocalName());

    if (reader.getNamespaceCount() > 0) {
        storeNamespaceAttributes(reader);
    }

    if (reader.getAttributeCount() > 0) {
        storeAttributes(reader);
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:13,代碼來源:StreamReaderBufferCreator.java

示例4: storeElement

import javax.xml.stream.XMLStreamReader; //導入方法依賴的package包/類
private void storeElement(XMLStreamReader reader) {
    storeQualifiedName(T_ELEMENT_LN,
            reader.getPrefix(), reader.getNamespaceURI(), reader.getLocalName());

    if (reader.getNamespaceCount() > 0) {
        storeNamespaceAttributes(reader);
    }

    if (reader.getAttributeCount() > 0) {
        storeAttributes(reader);
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:13,代碼來源:StreamReaderBufferCreator.java

示例5: addNamespaces

import javax.xml.stream.XMLStreamReader; //導入方法依賴的package包/類
protected void addNamespaces(StartElementEvent event,XMLStreamReader streamReader){
    Namespace namespace = null;
    for(int i=0; i<streamReader.getNamespaceCount(); i++){
        namespace = factory.createNamespace(streamReader.getNamespacePrefix(i),
                            streamReader.getNamespaceURI(i));
        event.addNamespace(namespace);
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:9,代碼來源:StAXEventAllocatorBase.java

示例6: 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

示例7: fillDeclaredPrefixes

import javax.xml.stream.XMLStreamReader; //導入方法依賴的package包/類
/** Fills in the list of declared prefixes. */
private void fillDeclaredPrefixes(XMLStreamReader reader) {
    fDeclaredPrefixes.clear();
    final int len = reader.getNamespaceCount();
    for (int i = 0; i < len; ++i) {
        String prefix = reader.getNamespacePrefix(i);
        fDeclaredPrefixes.add(prefix != null ? prefix : "");
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:10,代碼來源:StAXSchemaParser.java

示例8: storeNamespaceAttributes

import javax.xml.stream.XMLStreamReader; //導入方法依賴的package包/類
private void storeNamespaceAttributes(XMLStreamReader reader) {
    int count = reader.getNamespaceCount();
    for (int i = 0; i < count; i++) {
        storeNamespaceAttribute(reader.getNamespacePrefix(i), reader.getNamespaceURI(i));
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:7,代碼來源:StreamReaderBufferCreator.java

示例9: printNamespaces

import javax.xml.stream.XMLStreamReader; //導入方法依賴的package包/類
protected static void printNamespaces(XMLStreamReader xmlr) {
  for (int i = 0; i < xmlr.getNamespaceCount(); i++) {
    printNamespace(xmlr, i);
  }
}
 
開發者ID:ModelWriter,項目名稱:Tarski,代碼行數:6,代碼來源:XMLStreamHelper.java


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