Package org.w3c.dom

Examples of org.w3c.dom.Attr


    * @return returns a negative integer, zero, or a positive integer as obj0 is less than, equal to, or greater than obj1
    *
    */
   public int compare(Object obj0, Object obj1) {

      Attr attr0 = (Attr) obj0;
      Attr attr1 = (Attr) obj1;
      String namespaceURI0 = attr0.getNamespaceURI();     
      String namespaceURI1 = attr1.getNamespaceURI();
     
      boolean isNamespaceAttr0 =
        XMLNS.equals(namespaceURI0);
      boolean isNamespaceAttr1 =
        XMLNS.equals(namespaceURI1);

      if (isNamespaceAttr0) {
         if (isNamespaceAttr1) {

            // both are namespaces
            String localname0 = attr0.getLocalName();
            String localname1 = attr1.getLocalName();

            if (localname0.equals("xmlns")) {
               localname0 = "";
            }

            if (localname1.equals("xmlns")) {
               localname1 = "";
            }

            return localname0.compareTo(localname1);
         }
         // attr0 is a namespace, attr1 is not
         return ATTR0_BEFORE_ATTR1;
        
      }
      if (isNamespaceAttr1) {

            // attr1 is a namespace, attr0 is not
            return ATTR1_BEFORE_ATTR0;
      }

      // none is a namespae
     
      if (namespaceURI0 == null) {
        if (namespaceURI1 == null) {
          /*
           String localName0 = attr0.getLocalName();
           String localName1 = attr1.getLocalName();
           return localName0.compareTo(localName1);
           */
         
          String name0 = attr0.getName();
          String name1 = attr1.getName();
          return name0.compareTo(name1);
        }
        return ATTR0_BEFORE_ATTR1;
       
      }
      if (namespaceURI1 == null) {
          return ATTR1_BEFORE_ATTR0;
      }
      int a = namespaceURI0.compareTo(namespaceURI1);
         
      if (a != 0) {
        return a;
      }
      /*
      String localName0 = ;
      String localName1 =;*/
     
      return (attr0.getLocalName())
              .compareTo( attr1.getLocalName());
        
   }
View Full Code Here


                }
               
                NamedNodeMap attributes = (node.hasAttributes()) ? node.getAttributes() : null;
                if (attributes != null) {
                    for (int i = 0; i < attributes.getLength(); ++i) {
                        Attr attr = (Attr) attributes.item(i);
                        fLocator.fRelatedNode = attr;
                        DOMNormalizer.isAttrValueWF( fErrorHandler, fError, fLocator,
                                      attributes, attr, attr.getValue(), xml11Version);
                        if (verifyNames) {
                            wellformed = CoreDocumentImpl.isXMLName( attr.getNodeName(), xml11Version);
                            if (!wellformed) {
                                    String msg =
                                        DOMMessageFormatter.formatMessage(
                                            DOMMessageFormatter.DOM_DOMAIN,
                                            "wf-invalid-character-in-node-name",
View Full Code Here

        //     <attribute name='URI' type='anyURI' use='required'/>
        // </complexType>
        CipherReference newCipherReference(Element element) throws
                XMLEncryptionException {

      Attr URIAttr =
        element.getAttributeNodeNS(null, EncryptionConstants._ATT_URI);
      CipherReference result = new CipherReferenceImpl(URIAttr);

      // Find any Transforms
View Full Code Here

         // Parse
         NodeList list = sec.getElementsByTagName("role");
         int l = list.getLength();
         for(int i = 0; i<l;i++) {
            Element role = (Element)list.item(i);
            Attr na = role.getAttributeNode("name");
            if (na == null)
               throw new SAXException("There must exist a name attribute of role");
            String n = na.getValue();
            boolean r = role.getAttributeNode("read") != null ? Boolean.valueOf( role.getAttributeNode("read").getValue() ).booleanValue() : false;
            boolean w = role.getAttributeNode("write") != null ? Boolean.valueOf( role.getAttributeNode("write").getValue() ).booleanValue() : false;
            boolean c = role.getAttributeNode("create") != null ? Boolean.valueOf( role.getAttributeNode("create").getValue() ).booleanValue() : false;
            addRole(n,r,w,c);
View Full Code Here

         
          Iterator attrs = this.handleAttributesSubtree(currentElement,ns);
          if (attrs!=null) {
            //we output all Attrs which are available
            while (attrs.hasNext()) {
              Attr attr = (Attr) attrs.next();
              outputAttrToWriter(attr.getNodeName(),attr.getNodeValue(), writer);
            }
          }
          writer.write('>');       
          sibling= currentNode.getFirstChild();
          if (sibling==null) {
View Full Code Here

     
      Iterator attrs = handleAttributes(currentElement,ns);
      if (attrs!=null) {
        //we output all Attrs which are available
        while (attrs.hasNext()) {
          Attr attr = (Attr) attrs.next();
          outputAttrToWriter(attr.getNodeName(),attr.getNodeValue(), writer);
        }
      }
      if (currentNodeIsVisible) {
        writer.write('>');
      }
View Full Code Here

          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;
            }

            String NName=N.getLocalName();
            String NValue=N.getNodeValue();
            if (XML.equals(NName)
                    && Constants.XML_LANG_SPACE_SpecNS.equals(NValue)) {
               continue;
            }           
            ns.addMapping(NName,NValue,N);            
        }        
       }
        Attr nsprefix;
        if (((nsprefix=ns.getMappingWithoutRendered("xmlns"))!=null)
                && "".equals(nsprefix.getValue())) {
             ns.addMappingAndRender("xmlns","",nullNode);
        }
     }
View Full Code Here

      CipherReference cr = _cipherData.getCipherReference();

      // Need to wrap the uri in an Attribute node so that we can
      // Pass to the resource resolvers

      Attr uriAttr = cr.getURIAsAttr();
      XMLSignatureInput input = null;

      try {
        ResourceResolver resolver =
          ResourceResolver.getInstance(uriAttr, null);
View Full Code Here

        }
    //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.
        //The Element is output element, add his prefix(if used) to visibyUtilized
        String prefix = N.getPrefix();
        if ( (prefix != null) && (!prefix.equals(XML) && !prefix.equals(XMLNS)) ) {
            visiblyUtilized.add(prefix);
        }         
        //Add to the result.
         result.add(N);       
        continue;
      }
 
      if (ns.addMapping(NName, NNodeValue,N)) {
        //New definition check if it is relative.
                if (C14nHelper.namespaceIsRelative(NNodeValue)) {
                    Object exArgs[] = {E.getTagName(), NName,
                            N.getNodeValue()};
                    throw new CanonicalizationException(
                            "c14n.Canonicalizer.RelativeNamespace", exArgs);
                }
            }
    }   
             
    if (E.getNamespaceURI() != null) {
      String prefix = E.getPrefix();
      if ((prefix == null) || (prefix.length() == 0)) {
        visiblyUtilized.add(XMLNS);
      } else {
        visiblyUtilized.add(prefix);
      }
    } else {
      visiblyUtilized.add(XMLNS);
    }
                 
    //This can be optimezed by I don't have time
    Iterator it=visiblyUtilized.iterator();
    while (it.hasNext()) {
      String s=(String)it.next();                 
      Attr key=ns.getMapping(s);
      if (key==null) {
        continue;
      }
      result.add(key);
    }
View Full Code Here

    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;
      }     
           
      if (!XMLNS_URI.equals(N.getNamespaceURI())) {
        //Not a namespace definition.
        if (isOutputElement) {
          //The Element is output element, add his prefix(if used) to visibyUtilized
          String prefix = N.getPrefix();
          if ((prefix != null) && (!prefix.equals(XML) && !prefix.equals(XMLNS)) ){
              visiblyUtilized.add(prefix);
          }         
          //Add to the result.
            result.add(N);
        }
        continue;
      }
           
     
      if (ns.addMapping(NName, NNodeValue,N)) {
                //New definiton check if it is relative
                if (C14nHelper.namespaceIsRelative(NNodeValue)) {
                    Object exArgs[] = {E.getTagName(), NName,
                            N.getNodeValue()};
                    throw new CanonicalizationException(
                            "c14n.Canonicalizer.RelativeNamespace", exArgs);
                }   
            }
    }

    if (isOutputElement) {                
           //The element is visible, handle the xmlns definition   
           Attr xmlns = E.getAttributeNodeNS(XMLNS_URI, XMLNS);
           if ((xmlns!=null) &&  (!isVisible(xmlns))) {
              //There is a definition but the xmlns is not selected by the xpath.
              //then xmlns=""
              ns.addMapping(XMLNS,"",nullNode);                              
            }

      if (E.getNamespaceURI() != null) {
        String prefix = E.getPrefix();
        if ((prefix == null) || (prefix.length() == 0)) {
          visiblyUtilized.add(XMLNS);
        } else {
          visiblyUtilized.add( prefix);
        }
      } else {
        visiblyUtilized.add(XMLNS);
      }                 
      //This can be optimezed by I don't have time
      //visiblyUtilized.addAll(this._inclusiveNSSet);
      Iterator it=visiblyUtilized.iterator();
      while (it.hasNext()) {
        String s=(String)it.next();                   
        Attr key=ns.getMapping(s);
        if (key==null) {
          continue;
        }
        result.add(key);
      }
    } else /*if (_circunvented)*/ {     
      Iterator it=this._inclusiveNSSet.iterator();
      while (it.hasNext()) {
        String s=(String)it.next();       
        Attr key=ns.getMappingWithoutRendered(s);
        if (key==null) {
          continue;
        }
        result.add(key);               
      }
View Full Code Here

TOP

Related Classes of org.w3c.dom.Attr

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.