Package javax.xml.stream.events

Examples of javax.xml.stream.events.Namespace


    }

    public void addNamespaces(Iterator namespaces){
        if(namespaces != null) {
            while(namespaces.hasNext()){
                Namespace namespace = (Namespace)namespaces.next();
                _namespaces.add(namespace);
            }
        }
    }
View Full Code Here


                List<Namespace> declaredNs = null;
                if(namespaces.hasNext()) {
                    declaredNs = new ArrayList<Namespace>();
                }
                while(namespaces.hasNext()) {
                    Namespace next = (Namespace)namespaces.next();
                    contentHandler.startPrefixMapping(next.getPrefix(), next.getNamespaceURI());
                    declaredNs.add(next);
                }
                if(declaredNs != null) {
                    this.namespaces.put(depth, declaredNs);
                }
View Full Code Here

            if(attrs.hasNext() || namespaces.hasNext()) {

                ArrayList<Attribute> attributesList = new ArrayList<Attribute>();

                while(namespaces.hasNext()) {
                    Namespace next = (Namespace)namespaces.next();
                    String uri = XMLConstants.XMLNS_URL;
                    String localName = next.getPrefix();
                    String qName;
                    if(null == localName || localName.length() == 0) {
                        localName = XMLConstants.XMLNS;
                        qName = XMLConstants.XMLNS;
                    } else {
                        qName = XMLConstants.XMLNS + XMLConstants.COLON + localName;
                    }
                    String value = next.getNamespaceURI();
                    attributesList.add(new Attribute(uri, localName, qName, value));
                }

                while(attrs.hasNext()) {
                    javax.xml.stream.events.Attribute next = (javax.xml.stream.events.Attribute)attrs.next();
                    String uri = next.getName().getNamespaceURI();
                    String localName = next.getName().getLocalPart();
                    String prefix = next.getName().getPrefix();
                    String qName;
                    if(null == prefix || prefix.length() == 0) {
                        qName = localName;
                    } else {
                        qName = prefix + XMLConstants.COLON + localName;
                    }
                    String value = next.getValue();
                    attributesList.add(new Attribute(uri, localName, qName, value));
                }

                attributes = attributesList.toArray(new Attribute[attributesList.size()]);
            }else{
View Full Code Here

            case XMLEvent.END_ELEMENT:
                writer.writeEndElement();
                break;
           
            case XMLEvent.NAMESPACE: {
                Namespace ns = (Namespace) event;
                writer.writeNamespace(ns.getPrefix(), ns.getNamespaceURI());
                break;
            }
           
            case XMLEvent.START_ELEMENT: {
                StartElement se = event.asStartElement();
                QName n = se.getName();
                writer.writeStartElement(n.getPrefix(), n.getLocalPart(),
                                          n.getNamespaceURI());
                Iterator<?> it = se.getNamespaces();
                while (it.hasNext()) {
                    Namespace ns = (Namespace) it.next();
                    writer.writeNamespace(ns.getPrefix(), ns.getNamespaceURI());
                }
                it = se.getAttributes();
                while (it.hasNext()) {
                    Attribute attr = (Attribute) it.next();
                    QName name = attr.getName();
View Full Code Here

        }

        String xmlns = "http://schemas.xmlsoap.org/wsdl/";
        ite = ele.getNamespaces();
        while (ite.hasNext()) {
            Namespace ns = (Namespace) ite.next();
            String name = ns.getPrefix();
            if (!StringUtils.isEmpty(name)) {
                Attr attr = element.getOwnerDocument().createAttributeNS(xmlns, name);
                attr.setValue(ns.getNamespaceURI());
                element.setAttributeNodeNS(attr);
            } else {
                xmlns = ns.getNamespaceURI();
            }
        }

        if (currentElement == null) {
            doc.appendChild(element);
View Full Code Here

  {
    Logger logger = Logger.getLogger(SBMLReader.class);
    ReadingParser namespaceParser = null;

    while (nam.hasNext()) {
      Namespace namespace = (Namespace) nam.next();
      boolean isLastNamespace = !nam.hasNext();
      namespaceParser = initializedParsers.get(namespace.getNamespaceURI());
     
      logger.debug("processNamespaces : " + namespace.getNamespaceURI());
     
      // Calling the currentNode parser to store all the declared namespaces
      parser.processNamespace(currentNode.getLocalPart(),
          namespace.getNamespaceURI(),
          namespace.getName().getPrefix(),
          namespace.getName().getLocalPart(),
          hasAttributes, isLastNamespace,
          sbmlElements.peek());
     
      // Calling each corresponding parser, in case they want to initialize things for the currentNode
      if ((namespaceParser != null) && !namespaceParser.getClass().equals(parser.getClass())) {
       
        logger.debug("processNamespaces 2e parser : " + namespaceParser);
       
        namespaceParser.processNamespace(currentNode.getLocalPart(),
            namespace.getNamespaceURI(),
            namespace.getName().getPrefix(),
            namespace.getName().getLocalPart(),
            hasAttributes, isLastNamespace,
            sbmlElements.peek());
      } else if (namespaceParser == null) {
        logger.warn(String.format("Cannot find a parser for the %s namespace", namespace.getNamespaceURI()));
      }
    }

  }
View Full Code Here

  {
    Logger logger = Logger.getLogger(SBMLReader.class);
    ReadingParser namespaceParser = null;

    while (nam.hasNext()) {
      Namespace namespace = (Namespace) nam.next();
      boolean isLastNamespace = !nam.hasNext();
      namespaceParser = initializedParsers.get(namespace.getNamespaceURI());
     
      logger.debug("processNamespaces : " + namespace.getNamespaceURI());
     
      // Calling the currentNode parser to store all the declared namespaces
      parser.processNamespace(currentNode.getLocalPart(),
          namespace.getNamespaceURI(),
          namespace.getName().getPrefix(),
          namespace.getName().getLocalPart(),
          hasAttributes, isLastNamespace,
          sbmlElements.peek());
     
      // Calling each corresponding parser, in case they want to initialize things for the currentNode
      if ((namespaceParser != null) && !namespaceParser.getClass().equals(parser.getClass())) {
       
        logger.debug("processNamespaces 2e parser : " + namespaceParser);
       
        namespaceParser.processNamespace(currentNode.getLocalPart(),
            namespace.getNamespaceURI(),
            namespace.getName().getPrefix(),
            namespace.getName().getLocalPart(),
            hasAttributes, isLastNamespace,
            sbmlElements.peek());
      } else if (namespaceParser == null) {
        logger.warn(String.format("Cannot find a parser for the %s namespace", namespace.getNamespaceURI()));
      }
    }

  }
View Full Code Here

   
    /** Fills in the list of declared prefixes. */
    private void fillDeclaredPrefixes(Iterator namespaces) {
        fDeclaredPrefixes.clear();
        while (namespaces.hasNext()) {
            Namespace ns = (Namespace) namespaces.next();
            String prefix = ns.getPrefix();
            fDeclaredPrefixes.add(prefix != null ? prefix : "");
        }
    }
View Full Code Here

            }
            writer.write(name.getLocalPart());
            // Write namespace declarations.
            Iterator nsIter = getNamespaces();
            while (nsIter.hasNext()) {
                Namespace ns = (Namespace) nsIter.next();
                writer.write(' ');
                ns.writeAsEncodedUnicode(writer);
            }
            // Write attributes
            Iterator attrIter = getAttributes();
            while (attrIter.hasNext()) {
                Attribute attr = (Attribute) attrIter.next();
View Full Code Here

                List<Namespace> declaredNs = null;
                if(namespaces.hasNext()) {
                    declaredNs = new ArrayList<Namespace>();
                }
                while(namespaces.hasNext()) {
                    Namespace next = (Namespace)namespaces.next();
                    contentHandler.startPrefixMapping(next.getPrefix(), next.getNamespaceURI());
                    declaredNs.add(next);
                }
                if(declaredNs != null) {
                    this.namespaces.put(depth, declaredNs);
                }
View Full Code Here

TOP

Related Classes of javax.xml.stream.events.Namespace

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.