Package org.w3c.dom

Examples of org.w3c.dom.NamedNodeMap


      }

      StringBuffer sb = new StringBuffer();
      sb.append('<').append(name);

      NamedNodeMap attrs = n.getAttributes();
      if (attrs != null)
      {
         for(int i = 0; i < attrs.getLength(); i++)
         {
            Node attr = attrs.item(i);
            sb.append(' ').
               append(attr.getNodeName()).
               append("=\"").
               append(attr.getNodeValue()).
               append("\"");
View Full Code Here


      {
         throw new XMLRuntimeException("nodes have different node names");
      }

      int attrCount = 0;
      NamedNodeMap attrs = node.getAttributes();
      if (attrs != null)
      {
         attrCount = attrs.getLength();
      }

      int attrCount2 = 0;
      NamedNodeMap attrs2 = node2.getAttributes();
      if (attrs2 != null)
      {
         attrCount2 = attrs2.getLength();
      }

      if (attrCount != attrCount2)
      {
         throw new XMLRuntimeException("nodes hava a different number of attributes");
      }

      outer: for(int i = 0; i < attrCount; i++)
      {
         Node n = attrs.item(i);
         String name = n.getNodeName();
         String value = n.getNodeValue();

         for(int j = 0; j < attrCount; j++)
         {
            Node n2 = attrs2.item(j);
            String name2 = n2.getNodeName();
            String value2 = n2.getNodeValue();

            if (name.equals(name2) && value.equals(value2))
            {
View Full Code Here

    //
    // %ISSUE% What about inherited namespaces in this case?
    // Do we need to special-case initialize them into the DTM model?
    if(ELEMENT_NODE == m_root.getNodeType())
    {
      NamedNodeMap attrs=m_root.getAttributes();
      int attrsize=(attrs==null) ? 0 : attrs.getLength();
      if(attrsize>0)
      {
        int attrIndex=NULL; // start with no previous sib
        for(int i=0;i<attrsize;++i)
        {
          // No need to force nodetype in this case;
          // addNode() will take care of switching it from
          // Attr to Namespace if necessary.
          attrIndex=addNode(attrs.item(i),0,attrIndex,NULL);
          m_firstch.setElementAt(DTM.NULL,attrIndex);
        }
        // Terminate list of attrs, and make sure they aren't
        // considered children of the element
        m_nextsib.setElementAt(DTM.NULL,attrIndex);
View Full Code Here

        if(ELEMENT_NODE == nexttype)
          {
            int attrIndex=NULL; // start with no previous sib
            // Process attributes _now_, rather than waiting.
            // Simpler control flow, makes NS cache available immediately.
            NamedNodeMap attrs=next.getAttributes();
            int attrsize=(attrs==null) ? 0 : attrs.getLength();
            if(attrsize>0)
              {
                for(int i=0;i<attrsize;++i)
                  {
                    // No need to force nodetype in this case;
                    // addNode() will take care of switching it from
                    // Attr to Namespace if necessary.
                    attrIndex=addNode(attrs.item(i),
                                      nextindex,attrIndex,NULL);
                    m_firstch.setElementAt(DTM.NULL,attrIndex);

                    // If the xml: prefix is explicitly declared
                    // we don't need to synthesize one.
        //
        // NOTE that XML Namespaces were not originally
        // defined as being namespace-aware (grrr), and
        // while the W3C is planning to fix this it's
        // safer for now to test the QName and trust the
        // parsers to prevent anyone from redefining the
        // reserved xmlns: prefix
                    if(!m_processedFirstElement
                       && "xmlns:xml".equals(attrs.item(i).getNodeName()))
                      m_processedFirstElement=true;
                  }
                // Terminate list of attrs, and make sure they aren't
                // considered children of the element
              } // if attrs exist
View Full Code Here

    {
      DocumentType doctype = doc.getDoctype();
 
      if (null != doctype)
      {
        NamedNodeMap entities = doctype.getEntities();
        if(null == entities)
          return url;
        Entity entity = (Entity) entities.getNamedItem(name);
        if(null == entity)
          return url;
       
        String notationName = entity.getNotationName();
 
View Full Code Here

       while (it.hasPrevious()) {
       Element ele=(Element)it.previous();
        if (!ele.hasAttributes()) {
          continue;
        }
    NamedNodeMap attrs = ele.getAttributes();
       int attrsLength = attrs.getLength();
        for (int i = 0; i < attrsLength; i++) {
            Attr N = (Attr) attrs.item(i);
            if (!Constants.NamespaceSpecNS.equals(N.getNamespaceURI())) {
               //Not a namespace definition, ignore.
               continue;
            }
View Full Code Here

    // System.out.println("During the traversal, I encountered " +
    // XMLUtils.getXPath(E));
    // result will contain the attrs which have to be outputted
    SortedSet result = this.result;      
      result.clear();
    NamedNodeMap attrs=null;
       
    int attrsLength = 0;
        if (E.hasAttributes()) {
            attrs = E.getAttributes();
          attrsLength = attrs.getLength();
        }
    //The prefix visibly utilized(in the attribute or in the name) in the element
    SortedSet visiblyUtilized =(SortedSet) _inclusiveNSSet.clone();
         
    for (int i = 0; i < attrsLength; i++) {
      Attr N = (Attr) attrs.item(i);
      String NName=N.getLocalName();
      String NNodeValue=N.getNodeValue();
           
      if (!XMLNS_URI.equals(N.getNamespaceURI())) {
        //Not a namespace definition.
View Full Code Here

  final Iterator handleAttributes(Element E, NameSpaceSymbTable ns)
      throws CanonicalizationException {
    // result will contain the attrs which have to be outputted
    SortedSet result = this.result;      
      result.clear();
    NamedNodeMap attrs = null;
    int attrsLength = 0;
        if (E.hasAttributes()) {
            attrs = E.getAttributes();          
          attrsLength = attrs.getLength();
        }
    //The prefix visibly utilized(in the attribute or in the name) in the element
    Set visiblyUtilized =null;
    //It's the output selected.
    boolean isOutputElement = isVisible(E);     
    if (isOutputElement) {
      visiblyUtilized =  (Set) this._inclusiveNSSet.clone();
    }
   
    for (int i = 0; i < attrsLength; i++) {
      Attr N = (Attr) attrs.item(i);
      String NName=N.getLocalName();
      String NNodeValue=N.getNodeValue();
      if ( !isVisible(N) )  {
        //The node is not in the nodeset(if there is a nodeset)
        continue;
View Full Code Here

         return null;
      }
      // result will contain the attrs which have to be outputted      
      final SortedSet result = this.result;      
      result.clear();
      NamedNodeMap attrs = E.getAttributes();
      int attrsLength = attrs.getLength();     
           
      for (int i = 0; i < attrsLength; i++) {
         Attr N = (Attr) attrs.item(i);
         String NName=N.getLocalName();
         String NValue=N.getValue();
         String NUri =N.getNamespaceURI();

         if (!XMLNS_URI.equals(NUri)) {
View Full Code Here

                        // non default namespace
                        return namespace;
                    }
                }
                if (this.hasAttributes()) {
                    NamedNodeMap map = this.getAttributes();
                    int length = map.getLength();
                    for (int i=0;i<length;i++) {
                        Node attr = map.item(i);
                        String attrPrefix = attr.getPrefix();
                        String value = attr.getNodeValue();
                        namespace = attr.getNamespaceURI();
                        if (namespace !=null && namespace.equals("http://www.w3.org/2000/xmlns/")) {
                            // at this point we are dealing with DOM Level 2 nodes only
View Full Code Here

TOP

Related Classes of org.w3c.dom.NamedNodeMap

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.