Java 类javax.xml.stream.events.Namespace 实例源码

项目:OpenJSharp    文件:StAXEventConnector.java   
private void handleEndElement(EndElement event) throws SAXException {
    if(!seenText && predictor.expectText()) {
        visitor.text("");
    }

    // fire endElement
    QName qName = event.getName();
    tagName.uri = fixNull(qName.getNamespaceURI());
    tagName.local = qName.getLocalPart();
    visitor.endElement(tagName);

    // end namespace bindings
    for( Iterator<Namespace> i = event.getNamespaces(); i.hasNext();) {
        String prefix = fixNull(i.next().getPrefix());  // be defensive
        visitor.endPrefixMapping(prefix);
    }

    seenText = false;
}
项目:OpenJSharp    文件:StAXEventConnector.java   
private void handleStartElement(StartElement event) throws SAXException {
    // start namespace bindings
    for (Iterator i = event.getNamespaces(); i.hasNext();) {
        Namespace ns = (Namespace)i.next();
        visitor.startPrefixMapping(
            fixNull(ns.getPrefix()),
            fixNull(ns.getNamespaceURI()));
    }

    // fire startElement
    QName qName = event.getName();
    tagName.uri = fixNull(qName.getNamespaceURI());
    String localName = qName.getLocalPart();
    tagName.uri = fixNull(qName.getNamespaceURI());
    tagName.local = localName;
    tagName.atts = getAttributes(event);
    visitor.startElement(tagName);

    seenText = false;
}
项目:openjdk-jdk10    文件:StAXEventConnector.java   
private void handleEndElement(EndElement event) throws SAXException {
    if(!seenText && predictor.expectText()) {
        visitor.text("");
    }

    // fire endElement
    QName qName = event.getName();
    tagName.uri = fixNull(qName.getNamespaceURI());
    tagName.local = qName.getLocalPart();
    visitor.endElement(tagName);

    // end namespace bindings
    for( Iterator<Namespace> i = event.getNamespaces(); i.hasNext();) {
        String prefix = fixNull(i.next().getPrefix());  // be defensive
        visitor.endPrefixMapping(prefix);
    }

    seenText = false;
}
项目:openjdk-jdk10    文件:StAXEventConnector.java   
private void handleStartElement(StartElement event) throws SAXException {
    // start namespace bindings
    for (Iterator i = event.getNamespaces(); i.hasNext();) {
        Namespace ns = (Namespace)i.next();
        visitor.startPrefixMapping(
            fixNull(ns.getPrefix()),
            fixNull(ns.getNamespaceURI()));
    }

    // fire startElement
    QName qName = event.getName();
    tagName.uri = fixNull(qName.getNamespaceURI());
    String localName = qName.getLocalPart();
    tagName.uri = fixNull(qName.getNamespaceURI());
    tagName.local = localName;
    tagName.atts = getAttributes(event);
    visitor.startElement(tagName);

    seenText = false;
}
项目:openjdk9    文件:StAXEventConnector.java   
private void handleEndElement(EndElement event) throws SAXException {
    if(!seenText && predictor.expectText()) {
        visitor.text("");
    }

    // fire endElement
    QName qName = event.getName();
    tagName.uri = fixNull(qName.getNamespaceURI());
    tagName.local = qName.getLocalPart();
    visitor.endElement(tagName);

    // end namespace bindings
    for( Iterator<Namespace> i = event.getNamespaces(); i.hasNext();) {
        String prefix = fixNull(i.next().getPrefix());  // be defensive
        visitor.endPrefixMapping(prefix);
    }

    seenText = false;
}
项目:openjdk9    文件:StAXEventConnector.java   
private void handleStartElement(StartElement event) throws SAXException {
    // start namespace bindings
    for (Iterator i = event.getNamespaces(); i.hasNext();) {
        Namespace ns = (Namespace)i.next();
        visitor.startPrefixMapping(
            fixNull(ns.getPrefix()),
            fixNull(ns.getNamespaceURI()));
    }

    // fire startElement
    QName qName = event.getName();
    tagName.uri = fixNull(qName.getNamespaceURI());
    String localName = qName.getLocalPart();
    tagName.uri = fixNull(qName.getNamespaceURI());
    tagName.local = localName;
    tagName.atts = getAttributes(event);
    visitor.startElement(tagName);

    seenText = false;
}
项目:spring4-understanding    文件:StaxEventXMLReader.java   
private void handleStartElement(StartElement startElement) throws SAXException {
    if (getContentHandler() != null) {
        QName qName = startElement.getName();
        if (hasNamespacesFeature()) {
            for (Iterator i = startElement.getNamespaces(); i.hasNext();) {
                Namespace namespace = (Namespace) i.next();
                startPrefixMapping(namespace.getPrefix(), namespace.getNamespaceURI());
            }
            for (Iterator i = startElement.getAttributes(); i.hasNext();){
                Attribute attribute = (Attribute) i.next();
                QName attributeName = attribute.getName();
                startPrefixMapping(attributeName.getPrefix(), attributeName.getNamespaceURI());
            }

            getContentHandler().startElement(qName.getNamespaceURI(), qName.getLocalPart(), toQualifiedName(qName),
                    getAttributes(startElement));
        }
        else {
            getContentHandler().startElement("", "", toQualifiedName(qName), getAttributes(startElement));
        }
    }
}
项目:spring4-understanding    文件:StaxEventXMLReader.java   
private void handleEndElement(EndElement endElement) throws SAXException {
    if (getContentHandler() != null) {
        QName qName = endElement.getName();
        if (hasNamespacesFeature()) {
            getContentHandler().endElement(qName.getNamespaceURI(), qName.getLocalPart(), toQualifiedName(qName));
            for (Iterator i = endElement.getNamespaces(); i.hasNext();) {
                Namespace namespace = (Namespace) i.next();
                endPrefixMapping(namespace.getPrefix());
            }
        }
        else {
            getContentHandler().endElement("", "", toQualifiedName(qName));
        }

    }
}
项目:spring4-understanding    文件:XMLEventStreamReader.java   
@SuppressWarnings("rawtypes")
private Namespace getNamespace(int index) {
    Iterator namespaces;
    if (this.event.isStartElement()) {
        namespaces = this.event.asStartElement().getNamespaces();
    }
    else if (this.event.isEndElement()) {
        namespaces = this.event.asEndElement().getNamespaces();
    }
    else {
        throw new IllegalStateException();
    }
    int count = 0;
    while (namespaces.hasNext()) {
        Namespace namespace = (Namespace) namespaces.next();
        if (count == index) {
            return namespace;
        }
        else {
            count++;
        }
    }
    throw new IllegalArgumentException();
}
项目:xmlsec-gost    文件:XMLSecurityStreamReader.java   
@SuppressWarnings("unchecked")
@Override
public int getNamespaceCount() {
    XMLSecEvent xmlSecEvent = getCurrentEvent();
    switch (xmlSecEvent.getEventType()) {
        case START_ELEMENT:
            return xmlSecEvent.asStartElement().getOnElementDeclaredNamespaces().size();
        case END_ELEMENT:
            int count = 0;
            Iterator<Namespace> namespaceIterator = xmlSecEvent.asEndElement().getNamespaces();
            while (namespaceIterator.hasNext()) {
                namespaceIterator.next();
                count++;
            }
            return count;
        default:
            throw new IllegalStateException(ERR_STATE_NOT_ELEM);
    }
}
项目:xmlsec-gost    文件:XMLSecurityStreamReader.java   
@SuppressWarnings("unchecked")
@Override
public String getNamespacePrefix(int index) {
    XMLSecEvent xmlSecEvent = getCurrentEvent();
    switch (xmlSecEvent.getEventType()) {
        case START_ELEMENT:
            return xmlSecEvent.asStartElement().getOnElementDeclaredNamespaces().get(index).getPrefix();
        case END_ELEMENT:
            int count = 0;
            Iterator<Namespace> namespaceIterator = xmlSecEvent.asEndElement().getNamespaces();
            while (namespaceIterator.hasNext()) {
                Namespace namespace = namespaceIterator.next();
                if (count == index) {
                    return namespace.getPrefix();
                }
                count++;
            }
            throw new ArrayIndexOutOfBoundsException(index);
        default:
            throw new IllegalStateException(ERR_STATE_NOT_ELEM);
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:StAXEventConnector.java   
private void handleEndElement(EndElement event) throws SAXException {
    if(!seenText && predictor.expectText()) {
        visitor.text("");
    }

    // fire endElement
    QName qName = event.getName();
    tagName.uri = fixNull(qName.getNamespaceURI());
    tagName.local = qName.getLocalPart();
    visitor.endElement(tagName);

    // end namespace bindings
    for( Iterator<Namespace> i = event.getNamespaces(); i.hasNext();) {
        String prefix = fixNull(i.next().getPrefix());  // be defensive
        visitor.endPrefixMapping(prefix);
    }

    seenText = false;
}
项目:lookaside_java-1.8.0-openjdk    文件:StAXEventConnector.java   
private void handleStartElement(StartElement event) throws SAXException {
    // start namespace bindings
    for (Iterator i = event.getNamespaces(); i.hasNext();) {
        Namespace ns = (Namespace)i.next();
        visitor.startPrefixMapping(
            fixNull(ns.getPrefix()),
            fixNull(ns.getNamespaceURI()));
    }

    // fire startElement
    QName qName = event.getName();
    tagName.uri = fixNull(qName.getNamespaceURI());
    String localName = qName.getLocalPart();
    tagName.uri = fixNull(qName.getNamespaceURI());
    tagName.local = localName;
    tagName.atts = getAttributes(event);
    visitor.startElement(tagName);

    seenText = false;
}
项目:spring    文件:StaxEventXMLReader.java   
private void handleStartElement(StartElement startElement) throws SAXException {
    if (getContentHandler() != null) {
        QName qName = startElement.getName();
        if (hasNamespacesFeature()) {
            for (Iterator i = startElement.getNamespaces(); i.hasNext();) {
                Namespace namespace = (Namespace) i.next();
                startPrefixMapping(namespace.getPrefix(), namespace.getNamespaceURI());
            }
            for (Iterator i = startElement.getAttributes(); i.hasNext();){
                Attribute attribute = (Attribute) i.next();
                QName attributeName = attribute.getName();
                startPrefixMapping(attributeName.getPrefix(), attributeName.getNamespaceURI());
            }

            getContentHandler().startElement(qName.getNamespaceURI(), qName.getLocalPart(), toQualifiedName(qName),
                    getAttributes(startElement));
        }
        else {
            getContentHandler().startElement("", "", toQualifiedName(qName), getAttributes(startElement));
        }
    }
}
项目:spring    文件:StaxEventXMLReader.java   
private void handleEndElement(EndElement endElement) throws SAXException {
    if (getContentHandler() != null) {
        QName qName = endElement.getName();
        if (hasNamespacesFeature()) {
            getContentHandler().endElement(qName.getNamespaceURI(), qName.getLocalPart(), toQualifiedName(qName));
            for (Iterator i = endElement.getNamespaces(); i.hasNext();) {
                Namespace namespace = (Namespace) i.next();
                endPrefixMapping(namespace.getPrefix());
            }
        }
        else {
            getContentHandler().endElement("", "", toQualifiedName(qName));
        }

    }
}
项目:spring    文件:XMLEventStreamReader.java   
@SuppressWarnings("rawtypes")
private Namespace getNamespace(int index) {
    Iterator namespaces;
    if (this.event.isStartElement()) {
        namespaces = this.event.asStartElement().getNamespaces();
    }
    else if (this.event.isEndElement()) {
        namespaces = this.event.asEndElement().getNamespaces();
    }
    else {
        throw new IllegalStateException();
    }
    int count = 0;
    while (namespaces.hasNext()) {
        Namespace namespace = (Namespace) namespaces.next();
        if (count == index) {
            return namespace;
        }
        else {
            count++;
        }
    }
    throw new IllegalArgumentException();
}
项目:infobip-open-jdk-8    文件:StAXEventConnector.java   
private void handleEndElement(EndElement event) throws SAXException {
    if(!seenText && predictor.expectText()) {
        visitor.text("");
    }

    // fire endElement
    QName qName = event.getName();
    tagName.uri = fixNull(qName.getNamespaceURI());
    tagName.local = qName.getLocalPart();
    visitor.endElement(tagName);

    // end namespace bindings
    for( Iterator<Namespace> i = event.getNamespaces(); i.hasNext();) {
        String prefix = fixNull(i.next().getPrefix());  // be defensive
        visitor.endPrefixMapping(prefix);
    }

    seenText = false;
}
项目:infobip-open-jdk-8    文件:StAXEventConnector.java   
private void handleStartElement(StartElement event) throws SAXException {
    // start namespace bindings
    for (Iterator i = event.getNamespaces(); i.hasNext();) {
        Namespace ns = (Namespace)i.next();
        visitor.startPrefixMapping(
            fixNull(ns.getPrefix()),
            fixNull(ns.getNamespaceURI()));
    }

    // fire startElement
    QName qName = event.getName();
    tagName.uri = fixNull(qName.getNamespaceURI());
    String localName = qName.getLocalPart();
    tagName.uri = fixNull(qName.getNamespaceURI());
    tagName.local = localName;
    tagName.atts = getAttributes(event);
    visitor.startElement(tagName);

    seenText = false;
}
项目:teiid    文件:XMLEventStreamReader.java   
private Namespace getNamespace(int index) {
    Iterator namespaces;
    if (event.isStartElement()) {
        namespaces = event.asStartElement().getNamespaces();
    }
    else if (event.isEndElement()) {
        namespaces = event.asEndElement().getNamespaces();
    }
    else {
        throw new IllegalStateException();
    }
    int count = 0;
    while (namespaces.hasNext()) {
        Namespace namespace = (Namespace) namespaces.next();
        if (count == index) {
            return namespace;
        }
        else {
            count++;
        }
    }
    throw new IllegalArgumentException();
}
项目:cxf-plus    文件:StAXEventConnector.java   
private void handleEndElement(EndElement event) throws SAXException {
    if(!seenText && predictor.expectText()) {
        visitor.text("");
    }

    // fire endElement
    QName qName = event.getName();
    tagName.uri = fixNull(qName.getNamespaceURI());
    tagName.local = qName.getLocalPart();
    visitor.endElement(tagName);

    // end namespace bindings
    for( Iterator<Namespace> i = event.getNamespaces(); i.hasNext();) {
        String prefix = fixNull(i.next().getPrefix());  // be defensive
        visitor.endPrefixMapping(prefix);
    }

    seenText = false;
}
项目:cxf-plus    文件:StAXEventConnector.java   
private void handleStartElement(StartElement event) throws SAXException {
    // start namespace bindings
    for (Iterator i = event.getNamespaces(); i.hasNext();) {
        Namespace ns = (Namespace)i.next();
        visitor.startPrefixMapping(
            fixNull(ns.getPrefix()),
            fixNull(ns.getNamespaceURI()));
    }

    // fire startElement
    QName qName = event.getName();
    tagName.uri = fixNull(qName.getNamespaceURI());
    String localName = qName.getLocalPart();
    tagName.uri = fixNull(qName.getNamespaceURI());
    tagName.local = localName;
    tagName.atts = getAttributes(event);
    visitor.startElement(tagName);

    seenText = false;
}
项目:bagri    文件:XmlStaxParser.java   
@SuppressWarnings("unchecked")
private void startElement(XmlParserContext ctx, StartElement element) throws BagriException {
    ctx.appendCharacters();

    ctx.addData(element.getName().toString()); // getLocalPart());
    ctx.addElement(); 

    for (Iterator<Namespace> itr = element.getNamespaces(); itr.hasNext();) {
        Namespace ns = itr.next();
        // TODO: process default namespace properly
        String namespace = ns.getValue();
        if (namespace != null) {
            String prefix = ns.getName().getLocalPart();
            ctx.addNamespace(prefix, namespace);
        }
    }

    for (Iterator<Attribute> itr = element.getAttributes(); itr.hasNext();) {
        Attribute a = itr.next();
        //if (!a.getName().getPrefix().isEmpty()) {
        //  String prefix = model.translateNamespace(a.getName().getNamespaceURI(), a.getName().getPrefix());
        //  ctx.addNamespace(prefix, a.getName().getNamespaceURI());
        //}
        ctx.addAttribute(a.getName(), a.getValue()); 
    }
}
项目:common_utils    文件:StaxEventContentHandler.java   
/**
 * Create and return a list of {@code NameSpace} objects from the {@code NamespaceContext}.
 */
private List<Namespace> createNamespaces(SimpleNamespaceContext namespaceContext) {
    if (namespaceContext == null) {
        return null;
    }

    List<Namespace> namespaces = new ArrayList<Namespace>();
    String defaultNamespaceUri = namespaceContext.getNamespaceURI(XMLConstants.DEFAULT_NS_PREFIX);
    if (StringUtils.hasLength(defaultNamespaceUri)) {
        namespaces.add(this.eventFactory.createNamespace(defaultNamespaceUri));
    }
    for (Iterator<String> iterator = namespaceContext.getBoundPrefixes(); iterator.hasNext(); ) {
        String prefix = iterator.next();
        String namespaceUri = namespaceContext.getNamespaceURI(prefix);
        namespaces.add(this.eventFactory.createNamespace(prefix, namespaceUri));
    }
    return namespaces;
}
项目:class-guard    文件:StaxEventXMLReader.java   
private void handleStartElement(StartElement startElement) throws SAXException {
    if (getContentHandler() != null) {
        QName qName = startElement.getName();
        if (hasNamespacesFeature()) {
            for (Iterator i = startElement.getNamespaces(); i.hasNext();) {
                Namespace namespace = (Namespace) i.next();
                startPrefixMapping(namespace.getPrefix(), namespace.getNamespaceURI());
            }
            for (Iterator i = startElement.getAttributes(); i.hasNext();){
                Attribute attribute = (Attribute) i.next();
                QName attributeName = attribute.getName();
                startPrefixMapping(attributeName.getPrefix(), attributeName.getNamespaceURI());
            }

            getContentHandler().startElement(qName.getNamespaceURI(), qName.getLocalPart(), toQualifiedName(qName),
                    getAttributes(startElement));
        }
        else {
            getContentHandler().startElement("", "", toQualifiedName(qName), getAttributes(startElement));
        }
    }
}
项目:class-guard    文件:StaxEventXMLReader.java   
private void handleEndElement(EndElement endElement) throws SAXException {
    if (getContentHandler() != null) {
        QName qName = endElement.getName();
        if (hasNamespacesFeature()) {
            getContentHandler().endElement(qName.getNamespaceURI(), qName.getLocalPart(), toQualifiedName(qName));
            for (Iterator i = endElement.getNamespaces(); i.hasNext();) {
                Namespace namespace = (Namespace) i.next();
                endPrefixMapping(namespace.getPrefix());
            }
        }
        else {
            getContentHandler().endElement("", "", toQualifiedName(qName));
        }

    }
}
项目:class-guard    文件:XMLEventStreamReader.java   
@SuppressWarnings("rawtypes")
private Namespace getNamespace(int index) {
    Iterator namespaces;
    if (this.event.isStartElement()) {
        namespaces = this.event.asStartElement().getNamespaces();
    }
    else if (this.event.isEndElement()) {
        namespaces = this.event.asEndElement().getNamespaces();
    }
    else {
        throw new IllegalStateException();
    }
    int count = 0;
    while (namespaces.hasNext()) {
        Namespace namespace = (Namespace) namespaces.next();
        if (count == index) {
            return namespace;
        }
        else {
            count++;
        }
    }
    throw new IllegalArgumentException();
}
项目:class-guard    文件:StaxEventContentHandler.java   
/**
 * Create and return a list of {@code NameSpace} objects from the {@code NamespaceContext}.
 */
private List<Namespace> createNamespaces(SimpleNamespaceContext namespaceContext) {
    if (namespaceContext == null) {
        return null;
    }

    List<Namespace> namespaces = new ArrayList<Namespace>();
    String defaultNamespaceUri = namespaceContext.getNamespaceURI(XMLConstants.DEFAULT_NS_PREFIX);
    if (StringUtils.hasLength(defaultNamespaceUri)) {
        namespaces.add(this.eventFactory.createNamespace(defaultNamespaceUri));
    }
    for (Iterator iterator = namespaceContext.getBoundPrefixes(); iterator.hasNext();) {
        String prefix = (String) iterator.next();
        String namespaceUri = namespaceContext.getNamespaceURI(prefix);
        namespaces.add(this.eventFactory.createNamespace(prefix, namespaceUri));
    }
    return namespaces;
}
项目:OLD-OpenJDK8    文件:StAXEventConnector.java   
private void handleEndElement(EndElement event) throws SAXException {
    if(!seenText && predictor.expectText()) {
        visitor.text("");
    }

    // fire endElement
    QName qName = event.getName();
    tagName.uri = fixNull(qName.getNamespaceURI());
    tagName.local = qName.getLocalPart();
    visitor.endElement(tagName);

    // end namespace bindings
    for( Iterator<Namespace> i = event.getNamespaces(); i.hasNext();) {
        String prefix = fixNull(i.next().getPrefix());  // be defensive
        visitor.endPrefixMapping(prefix);
    }

    seenText = false;
}
项目:OLD-OpenJDK8    文件:StAXEventConnector.java   
private void handleStartElement(StartElement event) throws SAXException {
    // start namespace bindings
    for (Iterator i = event.getNamespaces(); i.hasNext();) {
        Namespace ns = (Namespace)i.next();
        visitor.startPrefixMapping(
            fixNull(ns.getPrefix()),
            fixNull(ns.getNamespaceURI()));
    }

    // fire startElement
    QName qName = event.getName();
    tagName.uri = fixNull(qName.getNamespaceURI());
    String localName = qName.getLocalPart();
    tagName.uri = fixNull(qName.getNamespaceURI());
    tagName.local = localName;
    tagName.atts = getAttributes(event);
    visitor.startElement(tagName);

    seenText = false;
}
项目:woodstox    文件:CompactNsContext.java   
@Override
public Iterator<Namespace> getNamespaces()
{
    if (mNsList == null) {
        int firstLocal = mFirstLocalNs;
        int len = mNsLength - firstLocal;
        if (len == 0) { // can this happen?
            return DataUtil.emptyIterator();
        }
        if (len == 2) { // only one NS
            return DataUtil.<Namespace>singletonIterator(NamespaceEventImpl.constructNamespace
                    (mLocation,
                            mNamespaces[firstLocal],
                            mNamespaces[firstLocal+1]));
        }
        ArrayList<Namespace> l = new ArrayList<Namespace>(len >> 1);
        String[] ns = mNamespaces;
        for (len = mNsLength; firstLocal < len;
             firstLocal += 2) {
            l.add(NamespaceEventImpl.constructNamespace(mLocation, ns[firstLocal],
                                          ns[firstLocal+1]));
        }
        mNsList = l;
    }
    return mNsList.iterator();
}
项目:woodstox    文件:MergedNsContext.java   
@Override
public void outputNamespaceDeclarations(Writer w) throws IOException
{
    for (int i = 0, len = mNamespaces.size(); i < len; ++i) {
        Namespace ns = mNamespaces.get(i);
        w.write(' ');
        w.write(XMLConstants.XMLNS_ATTRIBUTE);
        if (!ns.isDefaultNamespaceDeclaration()) {
            w.write(':');
            w.write(ns.getPrefix());
        }
        w.write("=\"");
        w.write(ns.getNamespaceURI());
        w.write('"');
    }
}
项目:woodstox    文件:MergedNsContext.java   
private Map<String,Namespace> buildByPrefixMap()
{
    int len = mNamespaces.size();
    if (len == 0) {
        return Collections.emptyMap();
    }

    LinkedHashMap<String,Namespace> m = new LinkedHashMap<String,Namespace>(1 + len + (len>>1));
    for (int i = 0; i < len; ++i) {
        Namespace ns = mNamespaces.get(i);
        String prefix = ns.getPrefix();
        if (prefix == null) { // shouldn't happen but...
            prefix = "";
        }
        m.put(prefix, ns);
    }
    return m;
}
项目:woodstox    文件:MergedNsContext.java   
private Map<String,Namespace> buildByNsURIMap()
{
    int len = mNamespaces.size();
    if (len == 0) {
        return Collections.emptyMap();
    }

    LinkedHashMap<String,Namespace> m = new LinkedHashMap<String,Namespace>(1 + len + (len>>1));
    for (int i = 0; i < len; ++i) {
        Namespace ns = mNamespaces.get(i);
        String uri = ns.getNamespaceURI();
        if (uri == null) { // shouldn't happen but...
            uri = "";
        }
        m.put(uri, ns);
    }
    return m;
}
项目:SplitCharater    文件:ElementImpl.java   
/**
 * Constructor.
 */
ElementImpl(final QName name, final boolean isStartElement, Iterator namespaces, final Location location) {
    super(isStartElement ? START_ELEMENT : END_ELEMENT, location);
    fName = name;
    if (namespaces != null && namespaces.hasNext()) {
        fNamespaces = new ArrayList();
        do {
            Namespace ns = (Namespace) namespaces.next();
            fNamespaces.add(ns);
        }
        while (namespaces.hasNext());
    }
    else {
        fNamespaces = Collections.EMPTY_LIST;
    }
}
项目:bazel    文件:XmlResourceValues.java   
public static Map<String, String> parseTagAttributes(StartElement start) {
  // Using a map to deduplicate xmlns declarations on the attributes.
  Map<String, String> attributeMap = new LinkedHashMap<>();
  Iterator<Attribute> attributes = iterateAttributesFrom(start);
  while (attributes.hasNext()) {
    Attribute attribute = attributes.next();
    QName name = attribute.getName();
    // Name used as the resource key, so skip it here.
    if (ATTR_NAME.equals(name)) {
      continue;
    }
    String value = escapeXmlValues(attribute.getValue()).replace("\"", "&quot;");
    if (!name.getNamespaceURI().isEmpty()) {
      attributeMap.put(name.getPrefix() + ":" + attribute.getName().getLocalPart(), value);
    } else {
      attributeMap.put(attribute.getName().getLocalPart(), value);
    }
    Iterator<Namespace> namespaces = iterateNamespacesFrom(start);
    while (namespaces.hasNext()) {
      Namespace namespace = namespaces.next();
      attributeMap.put("xmlns:" + namespace.getPrefix(), namespace.getNamespaceURI());
    }
  }
  return attributeMap;
}
项目:openjdk-icedtea7    文件:StAXEventConnector.java   
private void handleEndElement(EndElement event) throws SAXException {
    if(!seenText && predictor.expectText()) {
        visitor.text("");
    }

    // fire endElement
    QName qName = event.getName();
    tagName.uri = fixNull(qName.getNamespaceURI());
    tagName.local = qName.getLocalPart();
    visitor.endElement(tagName);

    // end namespace bindings
    for( Iterator<Namespace> i = event.getNamespaces(); i.hasNext();) {
        String prefix = fixNull(i.next().getPrefix());  // be defensive
        visitor.endPrefixMapping(prefix);
    }

    seenText = false;
}
项目:openjdk-icedtea7    文件:StAXEventConnector.java   
private void handleStartElement(StartElement event) throws SAXException {
    // start namespace bindings
    for (Iterator i = event.getNamespaces(); i.hasNext();) {
        Namespace ns = (Namespace)i.next();
        visitor.startPrefixMapping(
            fixNull(ns.getPrefix()),
            fixNull(ns.getNamespaceURI()));
    }

    // fire startElement
    QName qName = event.getName();
    tagName.uri = fixNull(qName.getNamespaceURI());
    String localName = qName.getLocalPart();
    tagName.uri = fixNull(qName.getNamespaceURI());
    tagName.local = localName;
    tagName.atts = getAttributes(event);
    visitor.startElement(tagName);

    seenText = false;
}
项目:lams    文件:JaxbProcessor.java   
private StartElement withNamespace(StartElement startElement) {
    // otherwise, wrap the start element event to provide a default namespace mapping
    final List<Namespace> namespaces = new ArrayList<Namespace>();
    namespaces.add( xmlEventFactory.createNamespace( "", namespaceUri ) );
    Iterator<?> originalNamespaces = startElement.getNamespaces();
    while ( originalNamespaces.hasNext() ) {
        namespaces.add( (Namespace) originalNamespaces.next() );
    }
    return xmlEventFactory.createStartElement(
            new QName( namespaceUri, startElement.getName().getLocalPart() ),
            startElement.getAttributes(),
            namespaces.iterator()
    );
}
项目:OpenJSharp    文件:StartElementEvent.java   
public void addNamespaces(Iterator namespaces){
    if(namespaces != null) {
        while(namespaces.hasNext()){
            Namespace namespace = (Namespace)namespaces.next();
            _namespaces.add(namespace);
        }
    }
}
项目:OpenJSharp    文件:StAXEventAllocatorBase.java   
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);
    }
}