Package nu.xom

Examples of nu.xom.Element


  }
 
  /** {@inheritDoc} */
  public Element startMakingElement(String qname, String namespaceURI) {
    String localName = getLocalName(qname);
    Element first = current.getFirstChildElement(localName, namespaceURI);
    if (first == null) {
      first = new Element(qname, namespaceURI);
      incrementValue(first, "descendants-or-self", 0);
      incrementValue(first, "instances", 0);
      incrementValue(first, "children", 0);
      incrementValue(first, "attributes", 0);
      current.appendChild(first);
    }
   
    incrementValue(first, "descendants-or-self", 1);
    incrementValue(first, "instances", 1);
    Element parent = (Element) first.getParent();
    incrementValue(parent, "children", 1);
    incrementDescendantOrSelf(parent);
     
    current = first; // recurse down
   
    return new Element(DUMMY);
  }
View Full Code Here


  }
 
  /** {@inheritDoc} */
  public Nodes makeAttribute(String qname, String namespaceURI, String value, Attribute.Type type) {
    String localName = makeAttributeName(getLocalName(qname));
    Element first = current.getFirstChildElement(localName, namespaceURI);
    if (first == null) {
      first = new Element(makeAttributeName(qname), namespaceURI);
      current.appendChild(first);
    }
   
    incrementValue(first, "instances", 1);
    Element parent = (Element) first.getParent();
    incrementValue(parent, "attributes", 1);
    incrementDescendantOrSelf(parent);

    return NONE;
  }
View Full Code Here

            int i = 0;
            while (true) {
              if (i % step == 0) System.out.println("t="+ t + ", index=" + i);
              Document doc;
              if (xmlDoc == null) {
                Element root = new Element("root");
                Element child = new Element("child");
                root.appendChild(child);
                for (int j=0; j < 10000; j++) child.appendChild("xxxxxxxxxxxxxxxxxx" + j);
                doc = new Document(root);
              }
              else {
                doc = xmlDoc;
                if (config.getCompressionLevel() == -1) doc = new Document(doc);
View Full Code Here

  /** {@inheritDoc} */
  public Element makeRootElement(String qname, String namespaceURI) {
    for (int i=0; i < receivers.length; i++) {
      if (exceptions[i] != null) continue; // ignore failed factory
      try {
        Element elem = receivers[i].makeRootElement(qname, namespaceURI);
        if (elem == null) throw new NullPointerException(
            "Factory failed to create root element.");
        stacks[i].add(elem); // push
        ((Document)currents[i]).setRootElement(elem);
        currents[i] = elem; // recurse down
        addAttributesAndNamespaces[i] = true;
      } catch (RuntimeException e) {
        onException(i, e);
      }
    }
   
    return new Element(qname, namespaceURI);
  }
View Full Code Here

  /** {@inheritDoc} */
  public Element startMakingElement(String qname, String namespaceURI) {
    for (int i=0; i < receivers.length; i++) {
      if (exceptions[i] != null) continue; // ignore failed factory
      try {
        Element elem = receivers[i].startMakingElement(qname, namespaceURI);
        stacks[i].add(elem); // push even if it's null
        if (elem != null) {
          currents[i].insertChild(elem, currents[i].getChildCount());
          currents[i] = elem; // recurse down
        }
        addAttributesAndNamespaces[i] = elem != null;
      } catch (RuntimeException e) {
        onException(i, e);
      }
    }
   
    return new Element(qname, namespaceURI);
  }
View Full Code Here

  /** {@inheritDoc} */
  public Nodes finishMakingElement(Element unused) {
    for (int i=0; i < receivers.length; i++) {
      if (exceptions[i] != null) continue; // ignore failed factory
      try {
        Element elem = (Element) stacks[i].remove(stacks[i].size()-1); // pop
        if (elem == null) {
          continue; // skip element
        }
        ParentNode parent = elem.getParent();
        if (parent == null) throwTamperedWithParent();
        currents[i] = parent; // recurse up
       
        Nodes nodes = receivers[i].finishMakingElement(elem);
        if (nodes.size()==1 && nodes.get(0)==elem) { // same node? (common case)
View Full Code Here

  public XMLMatrix(File file, boolean append) throws ParsingException, IOException {
    this.file = file;
    if (append && file.exists()) {
      this.doc = BuilderPool.GLOBAL_POOL.getBuilder(false).build(file);
    } else {
      this.doc = new Document(new Element(file.getName()));
    }
  }
View Full Code Here

  }
 
  public void put(String rowName, String columnName, String value) {
    Elements rows = doc.getRootElement().getChildElements(rowName);
    if (rows.size() == 0) {
      doc.getRootElement().appendChild(new Element(rowName));
      rows = doc.getRootElement().getChildElements(rowName);
    }
   
    Elements cols = rows.get(0).getChildElements(columnName);
    if (cols.size() == 0) {
      rows.get(0).appendChild(new Element(columnName));
      cols = rows.get(0).getChildElements(columnName);
    }
   
    Element col = cols.get(0);
    col.removeChildren();
    col.appendChild(value);
  }
View Full Code Here

   *         type ID).
   */

  public NodeInfo selectID(String id) {
    if (idIndex == null) {
      Element elem;
      switch (nodeKind) {
        case Type.DOCUMENT :
          elem = ((Document) node).getRootElement();
          break;
        case Type.ELEMENT :
View Full Code Here

    }


    public void testBadXPathExpression() {
       
        Element parent = new Element("Test");
       
        try {
            parent.query("This is not an XPath expression");
            fail("Allowed malformed query");
        }
        catch (XPathException success) {
            assertNotNull(success.getMessage());
       
View Full Code Here

TOP

Related Classes of nu.xom.Element

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.