当前位置: 首页>>代码示例>>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;未经允许,请勿转载。