Package nu.xom

Examples of nu.xom.Attribute


  private void readAttribute(ArrayByteList src, Element dst, int type) throws BinaryParsingException {
    String qname = readString(src, 4, type);
    String namespaceURI = readName(src, 6, type);
    String value = readString(src, 4, src.get());
    Attribute.Type attrType = Util.getAttributeType(src.get());
    Attribute attr = this.nodeBuilder.createAttribute(qname, namespaceURI, value, attrType);
//    Attribute attr = new Attribute(qname, namespaceURI, value, attrType);
    dst.addAttribute(attr);   
  }
View Full Code Here


    if (uri == null) uri = "";
    if ("xml:id".equals(qname)) {
      type = Attribute.Type.ID; // avoids exception in Attribute.setType()
    }
   
    Attribute attr = (Attribute) attributes.get(qname, uri);
    if (attr == null) {
      attr = new Attribute(qname, uri, value, type);
      attributes.put(qname, uri, attr);
      return new Attribute(attr); // copy constructor is fast
    }
    attr = new Attribute(attr); // copy constructor is fast
    if (attr.getType() != type) attr.setType(type);
    attr.setValue(value);
    return attr;
  }
View Full Code Here

  }
 
  private void writeAttributes(Element elem) throws IOException {
    int count = elem.getAttributeCount();
    for (int i=0; i < count; i++) {
      Attribute attr = elem.getAttribute(i);
      try {
        writer.writeAttribute(
          attr.getNamespacePrefix(),
          attr.getNamespaceURI(),
          attr.getLocalName(),
          attr.getValue());
      } catch (XMLStreamException e) {
        wrapException(e);
      }
    }
  }
View Full Code Here

    }
    return value;
  }

  private Attribute convertAttributeNodeInfo(NodeInfo node) {
    return new Attribute(
      node.getDisplayName(), node.getURI(), node.getStringValue());     
  }
View Full Code Here

   
    return new NodeFactory() {   
      private int level = 0;
     
      public Nodes makeAttribute(String name, String URI, String value, Attribute.Type type) {
        log("", new Attribute(name, URI, value, type));
        return child.makeAttribute(name, URI, value, type);
      }
 
      public Nodes makeComment(String data) {
        log("", new Comment(data));
View Full Code Here

      }
    }
   
    private static void appendAttributes(Element elem, NodeFactory factory, Element result) {
      for (int i=0; i < elem.getAttributeCount(); i++) {
        Attribute attr = elem.getAttribute(i);
        appendNodes(result,
          factory.makeAttribute(
            attr.getQualifiedName(),
            attr.getNamespaceURI(),
            attr.getValue(),
            attr.getType()));
      }
    }
View Full Code Here

        throw new IllegalArgumentException("Unrecognized node type: " + node.getClass());
      item = new Element(item);

      // add copy of content to wrapper:
      if (node instanceof Attribute) {
        Attribute attr = (Attribute) node;         
        item.addAttribute((Attribute) attr.copy());
      } else if (node instanceof Document) {
        Document doc = (Document) node;         
        for (int j=0; j < doc.getChildCount(); j++) {
          item.appendChild(doc.getChild(j).copy());
        }
View Full Code Here

          expected = new Object[paths.size()];
         
          // precompute all the info necessary to run the bench
          for (int i=0; i < paths.size(); i++) {
            Element path = (Element) paths.get(i);
            Attribute ctxAttr = path.getAttribute("context");
           
            contexts[i] = ctxAttr == null ? doc : XQueryUtil.xquery(doc, ctxAttr.getValue()).get(0);
            selects[i] = path.getAttribute("select").getValue();
            types[i] = 0;
            if (path.getAttribute("type") != null) {
              String[] flavours = {"count", "string", "double", "boolean"};
              types[i] = java.util.Arrays.asList(flavours).indexOf(path.getAttribute("type").getValue());
View Full Code Here

  // TODO: obsolete?
  private void collect(Element elem) {
    startMakingElement(elem.getQualifiedName(), elem.getNamespaceURI());
   
    for (int i=0; i < elem.getAttributeCount(); i++) {
      Attribute a = elem.getAttribute(i);
      makeAttribute(a.getQualifiedName(), a.getNamespaceURI(),
          a.getValue(), a.getType());
    }
    for (int i=0; i < elem.getChildCount(); i++) {
      Node node = elem.getChild(i);
      if (node instanceof Element) {
        collect((Element) node); // recurse
View Full Code Here

      parent = (Element) parent.getParent();
    } while (parent != null);   
  }
 
  private static void incrementValue(Element elem, String name, int value) {
    Attribute attr = elem.getAttribute(name);
    if (attr == null) {
      attr = new Attribute(name, String.valueOf(value));
      elem.addAttribute(attr);
    } else {
      int v = Integer.parseInt(attr.getValue());
      attr.setValue(String.valueOf(v + value));
    }
  }
View Full Code Here

TOP

Related Classes of nu.xom.Attribute

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.