Package dk.brics.xmlgraph

Examples of dk.brics.xmlgraph.Node


   * @return a new XML graph
   */
  private XMLGraph safeCloneGraph(XMLGraph xg) {
      final XMLGraph output = xg.clone();
      for (int i=0; i<xg.getNodes().size(); i++) {
          Node node = output.getNode(i);
          node.process(new NodeProcessor<Object>() {
              @Override
              public Object process(AttributeNode n) {
                  n.setName(n.getName().clone(), output);
                  return this;
              }
View Full Code Here


                } else {
                    schemaName = name;
                    quantifier = Quantifier.One;
                }
               
                Node base = g.getTypemap().get(schemaName);
               
                // add datatypes on-the-fly when needed
                if (base == null) {
                    if (XMLSchemaDatatypes.isDatatype(schemaName)) {
                        base = new TextNode(XMLSchemaDatatypes.getDatatype(schemaName, origin), new Origin("", -1, -1));
                        xg.addNode(base);
                        g.getTypemap().put(schemaName, base);
                    }
                }
               
                // if still not found, it does not exist
                if (base == null) {
                    throw new XMLException("Could not find schema for type " + schemaName + " referred to at " + origin, origin);
                }
               
                Node result;
                OneOrMoreNode on;
                SequenceNode empty;
                switch (quantifier) {
                case One:
                    result = base;
View Full Code Here

        }
        // update ingoing edges
        for (Node node : xg.getNodes()) {
            if (node instanceof SingleContentNode) {
                SingleContentNode sc = (SingleContentNode)node;
                Node content = xg.getNode(sc.getContent());
                if (content instanceof ElementNode || content instanceof AttributeNode) {
                    sc.setContent(pred.get(content).getIndex());
                }
            }
            else if (node instanceof MultiContentNode) {
                MultiContentNode mc = (MultiContentNode)node;
                LinkedList<Integer> newcontent = new LinkedList<Integer>();
                LinkedList<Integer> removedcontent = new LinkedList<Integer>();
                for (int child : mc.getContents()) {
                    Node content = xg.getNode(child);
                    if (content instanceof ElementNode || content instanceof AttributeNode) {
                        Node p = pred.get(content);
                        if (p != mc) { // predecessor might be this node -- don't change that
                            newcontent.add(p.getIndex());
                            removedcontent.add(child);
                        }
                    }
                }
                mc.getContents().removeAll(removedcontent);
View Full Code Here

  }
  final public Automaton apply(XMLGraph g) {
    graph = g;
    Automaton result = Automaton.makeEmpty();
    for (int root : g.getRoots()) {
      Node node = g.getNode(root);
      Automaton c = node.process(proc);
      result = result.union(c);
    }
    return result;
  }
View Full Code Here

                } else {
                    schemaName = name;
                    quantifier = Quantifier.One;
                }
               
                Node base = g.getTypemap().get(schemaName);
               
                // add datatypes on-the-fly when needed
                if (base == null) {
                    if (XMLSchemaDatatypes.isDatatype(schemaName)) {
                        base = new TextNode(XMLSchemaDatatypes.getDatatype(schemaName, origin), new Origin("", -1, -1));
                        xg.addNode(base);
                        g.getTypemap().put(schemaName, base);
                    }
                }
               
                // if still not found, it does not exist
                if (base == null) {
                    throw new XMLException("Could not find schema for type " + schemaName + " referred to at " + origin, origin);
                }
               
                Node result;
                OneOrMoreNode on;
                SequenceNode empty;
                switch (quantifier) {
                case One:
                    result = base;
View Full Code Here

        }
        while (!queue.isEmpty()) {
            int p = queue.remove();
            inqueue.remove(p);
            int index = priority2node.get(p);
            Node node = xg.getNode(index);
            T src = map.get(index);
            transfer(src, node);
        }
    }
View Full Code Here

        }
        while (!queue.isEmpty()) {
            int p = queue.remove();
            inqueue.remove(p);
            int index = priority2node.get(p);
            Node node = xg.getNode(index);
            T oldValue = map.get(index);
            T newValue = transfer(node, oldValue);
            if (!oldValue.equals(newValue)) {
                map.put(index, newValue);
                for (int pred : backedges.getView(index)) {
View Full Code Here

      nodes.add(xg.getNode(root));
      queue.add(new NodeDepthPair(xg.getNode(root), 0));
    }
    while (!queue.isEmpty()) {
      NodeDepthPair pair = queue.removeFirst();
      Node node = pair.node;
      int d = pair.depth;
      for (int child : getSuccessors(node)) {
        Node childnode = xg.getNode(child);
        if (nodes.contains(childnode))
          continue;
        nodes.add(childnode);
        if (d < depth) {
          queue.add(new NodeDepthPair(childnode, d+1));
View Full Code Here

    lowlink[v] = index;
    index += 1;
    stack.push(v);
    onstack.set(v);
    for (int child : node.getContents()) {
      Node childnode = graph.getNode(child);
      if (reducible(childnode)) {
        if (vindex[child] == -1) {
          tarjan((MultiContentNode)childnode);
          lowlink[v] = Math.min(lowlink[v], lowlink[child]);
        }
View Full Code Here

      @Override
      public Object process(ChoiceNode n) {
        if (!n.isGap() || !n.isOpen())
          return n;
        //String type = gaptypes == null ? null : gaptypes.get(n.getName());
        Node typeNode = schema.getGapTypeNodes().get(n.getName());
        Set<Integer> cs = new LinkedHashSet<Integer>(n.getContents());
        if (typeNode == null) {
          // close the gap if no annotation is present
          if (g.getOpenTemplateGaps().remove(n.getName())) {
            cs.add(b.getEmptySequence().getIndex());
            g.getClosedTemplateGaps().add(n.getName());
            n.setContentAndStatus(false, n.isRemoved(), cs, g);
          }
        } else {
          cs.add(typeNode.getIndex());
          if (g.getOpenAttributeGaps().remove(n.getName())) {
            g.getClosedAttributeGaps().add(n.getName());
          }
          if (g.getOpenTemplateGaps().remove(n.getName())) {
            g.getClosedTemplateGaps().add(n.getName());
View Full Code Here

TOP

Related Classes of dk.brics.xmlgraph.Node

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.