Examples of Attr


Examples of org.w3c.dom.Attr

     
      public void writeResponse(HttpOutputStream outputStream, HttpInputStream inputStream, Document doc) throws IOException {
         // log.severe(debug(inputStream));
         Element el = doc.getDocumentElement();

         Attr admin = doc.createAttribute(ADMIN_ROLE);
         Attr initiator = doc.createAttribute(INITIATOR_ROLE);
         Attr user = doc.createAttribute(USER_ROLE);
         if (this.authMethod != null) {
            String userName = extractUserName(inputStream);
            if (userName == null)
               userName = "";
            String roles = (String)this.roles.get(userName);
            if (roles == null) {
               admin.setValue("false");
               initiator.setValue("false");
               user.setValue("false");
            }
            else if (roles.indexOf(ADMIN_ROLE) > -1) {
               admin.setValue("true");
               initiator.setValue("true");
               user.setValue("true");
            }
            else if (roles.indexOf(INITIATOR_ROLE) > -1) {
               admin.setValue("false");
               initiator.setValue("true");
               user.setValue("true");
            }
            else {
               admin.setValue("false");
               initiator.setValue("false");
               user.setValue("true");
            }
         }
         else {
            admin.setValue("true");
            initiator.setValue("true");
            user.setValue("true");
         }
         el.setAttributeNode(admin);
         el.setAttributeNode(initiator);
         el.setAttributeNode(user);
         // outputStream.setHeader("Cache-Control", "no-cache");
View Full Code Here

Examples of org.w3c.dom.Attr

      NamedNodeMap attributes = node.getAttributes();
      if (attributes != null && attributes.getLength() > 0) {
         int attributeCount = attributes.getLength();
         for (int i = 0; i < attributeCount; i++) {
            Attr attribute = (Attr)attributes.item(i);

            if (attribute.getNodeName().equalsIgnoreCase("oid")) {
               //String val = attribute.getNodeValue();
               attribute.setNodeValue(getOid());
            }
            else if (attribute.getNodeName().equalsIgnoreCase("contentMime")) {
               //String contentMime = attribute.getNodeValue();
               attribute.setNodeValue(getContentMime());
            }
            else if (attribute.getNodeName().equalsIgnoreCase("contentMimeExtended")) {
               // String contentMimeExtended = attribute.getNodeValue();
               attribute.setNodeValue(getContentMimeExtended());
            }
            else if (attribute.getNodeName().equalsIgnoreCase("domain")) {
               // String domain = attribute.getNodeValue();
               attribute.setNodeValue(getDomain());
            }
         }
      }

      log.info("DOM parsed the XmlKey " + getOid());
View Full Code Here

Examples of org.w3c.dom.Attr

            }

            case Node.ELEMENT_NODE: {
                fOut.print('<');
                fOut.print(node.getNodeName());
                Attr attrs[] = sortAttributes(node.getAttributes());
                for (int i = 0; i < attrs.length; i++) {
                    Attr attr = attrs[i];
                    fOut.print(' ');
                    fOut.print(attr.getNodeName());
                    fOut.print("=\"");
                    normalizeAndPrint(attr.getNodeValue(), fOut);
                    fOut.print('"');
                }
                fOut.print('>');
                fOut.flush();
View Full Code Here

Examples of org.w3c.dom.Attr

    /** Returns a sorted list of attributes. */
    protected static Attr[] sortAttributes(NamedNodeMap attrs) {

        int len = (attrs != null) ? attrs.getLength() : 0;
        Attr array[] = new Attr[len];
        for (int i = 0; i < len; i++) {
            array[i] = (Attr)attrs.item(i);
        }
        for (int i = 0; i < len - 1; i++) {
            String name = array[i].getNodeName();
            int index = i;
            for (int j = i + 1; j < len; j++) {
                String curName = array[j].getNodeName();
                if (curName.compareTo(name) < 0) {
                    name = curName;
                    index = j;
                }
            }
            if (index != i) {
                Attr temp = array[i];
                array[i] = array[index];
                array[index] = temp;
            }
        }

View Full Code Here

Examples of org.w3c.dom.Attr

    NamedNodeMap m = element.getAttributes();
    // there may be no attributes defined (check for null attribute)
    String id=null;
    for (int i = 0; id==null && _attribute != null && i < _attribute.length; i++) {
      String n = _attribute[i].getName();
      Attr a = (Attr) (n==null?null:m.getNamedItem(n));
      // the attribute may not have any occurrences
      id = _attribute[i].getID(a, ctx);
    }
    return id;
  }
View Full Code Here

Examples of org.w3c.dom.Attr

 
  static boolean preserved(Node node, boolean def) {
    if (node==null) return def;
    switch (node.getNodeType()) {
    case Node.ATTRIBUTE_NODE:
      Attr a = (Attr) node;
      if (a.getNamespaceURI()!=null && a.getNamespaceURI().equals(XML) && a.getLocalName().equals("space"))
        return a.getValue().equals("preserve");
      return preserved(a.getOwnerElement(),def);
    case Node.ELEMENT_NODE:
      Element e = (Element) node;
      if (e.hasAttributeNS(XML,"space"))
        return e.getAttributeNS(XML,"space").equals("preserve");
      return preserved(e.getParentNode(),def);
View Full Code Here

Examples of org.w3c.dom.Attr

      if (def==null) {
        if (!attribute[i].getRef().startsWith("xml:"))
          Gloze.logger.warn("undefined attribute: "+attribute[i].getRef());
        continue;
      }     
      Attr a = (Attr) map.get(def.createURI(m,ctx)); //map.getNamedItem(name);
      // the attribute may not have any occurrences
      attribute[i].toRDF(subject, a, ctx);
    }   
  }
View Full Code Here

Examples of org.w3c.dom.Attr

  public void declareGlobalNS(Model model, Context ctx) {
    addPrefix("rdf",RDF.getURI(),model);
    if (_node instanceof Element) {
      NamedNodeMap m = ((Element)_node).getAttributes();
      for (int i=0; i<m.getLength(); i++) {
        Attr a = (Attr) m.item(i);
        if (a.getName().startsWith("xmlns:")) {
          String ns = a.getValue();
          addPrefixes(a.getName().substring("xmlns:".length()),ns,model);
        }
      }   
    }
   
    // add anonymous namespace declaration   
    if (_node instanceof Element) {
      NamedNodeMap m = ((Element)_node).getAttributes();
      for (int i=0; i<m.getLength(); i++) {
        Attr a = (Attr) m.item(i);
        if (a.getName().equals("xmlns")) {
          String ns = a.getValue();
          if (!model.getNsPrefixMap().containsValue(terminateNS(ns)))
            addPrefix(ctx.createNSPrefix(),ns,model);
          break;
        }
      }   
View Full Code Here

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

Examples of org.w3c.dom.Attr

                }
               
                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
TOP
Copyright © 2018 www.massapi.com. 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.