Package dk.brics.xmlgraph

Examples of dk.brics.xmlgraph.ChoiceNode


        private dk.brics.xmlgraph.Node wrapChoice(dk.brics.xmlgraph.Node n) {
          if (!(n instanceof ChoiceNode)) {
            Collection<Integer> cs = new ArrayList<Integer>();
            cs.add(n.getIndex());
            n = new ChoiceNode(cs, n.getOrigin());
            xg.addNode(n);
          }
          return n;
       
       
        @Override
        public void visit(Text n) {
          dk.brics.xmlgraph.Node tn = new TextNode(Automaton.makeString(n.getString()), n.getOrigin());
          xg.addNode(tn);
          if (wrapchoices)
            tn = wrapChoice(tn);
          m.parent.addContent(tn.getIndex());
          push(n.getNextSibling(), m.parent);
        }
       
        @Override
        public void visit(Element n) {
          List<Integer> cs = new ArrayList<Integer>();
          contents.put(n, cs); // contents added later
          SequenceNode content = new SequenceNode(cs, n.getOrigin());
          xg.addNode(content);
          dk.brics.xmlgraph.Node sn = content;
          if (wrapchoices)
            sn = wrapChoice(sn);
          dk.brics.xmlgraph.Node en = new ElementNode(Automaton.makeString(n.getExpandedName()),
              sn.getIndex(), false, n.getOrigin());
          xg.addNode(en);
          if (wrapchoices)
            en = wrapChoice(en);
          m.parent.addContent(en.getIndex());
          push(n.getNextSibling(), m.parent);
          push(n.getFirstAttr(), content);
          push(n.getFirstChild(), content);
        }

        @Override
        public void visit(TemplateGap n) {
          if (gaps != GapConversion.IGNORE) {
            dk.brics.xmlgraph.Node cn = new ChoiceNode(n.getGap(), gaps == GapConversion.OPEN, false, Collections.<Integer>emptyList(), n.getOrigin());
            xg.addNode(cn);
            m.parent.addContent(cn.getIndex());
            tgaps.add(n.getGap());
            addGapType(n.getGap(), n.getType(), n.getOrigin());
          }
          push(n.getNextSibling(), m.parent);
        }
       
        @Override
        public void visit(Attribute n) {
          dk.brics.xmlgraph.Node vn = new TextNode(Automaton.makeString(n.getValue()), n.getOrigin());
          xg.addNode(vn);
          if (wrapchoices)
            vn = wrapChoice(vn);
          dk.brics.xmlgraph.Node an = new AttributeNode(Automaton.makeString(n.getExpandedName()),
              vn.getIndex(), n.getOrigin());
          xg.addNode(an);
          if (wrapchoices)
            an = wrapChoice(an);
          m.parent.addContent(an.getIndex());
          push(n.getNextAttr(), m.parent);
        }
       
        @Override
        public void visit(AttributeGap n) {
          if (gaps != GapConversion.IGNORE) {
            dk.brics.xmlgraph.Node cn = new ChoiceNode(n.getGap(), gaps == GapConversion.OPEN, false, Collections.<Integer>emptyList(), n.getOrigin());
            xg.addNode(cn);
            dk.brics.xmlgraph.Node an = new AttributeNode(Automaton.makeString(n.getExpandedName()),
                cn.getIndex(), n.getOrigin());
            xg.addNode(an);
            if (wrapchoices)
              an = wrapChoice(an);
            m.parent.addContent(an.getIndex());
            agaps.add(n.getGap());
View Full Code Here


                case ZeroOrMore:
                    empty = new SequenceNode(Collections.<Integer>emptyList(), origin);
                    on = new OneOrMoreNode(base.getIndex(), origin);
                    xg.addNode(empty);
                    xg.addNode(on);
                    result = new ChoiceNode(set(empty.getIndex(), on.getIndex()), origin);
                    xg.addNode(result);
                    break;
                case ZeroOrOne:
                default:
                    empty = new SequenceNode(Collections.<Integer>emptyList(), origin);
                    xg.addNode(empty);
                    result = new ChoiceNode(set(base.getIndex(), empty.getIndex()), origin);
                    xg.addNode(result);
                    break;
                }
               
                g.getTypemap().put(name, result);
View Full Code Here

        for (Node node : new ArrayList<Node>(xg.getNodes())) {
            if (node instanceof ElementNode) {
                ElementNode en = (ElementNode)node;
                LinkedHashSet<Integer> cs1 = new LinkedHashSet<Integer>();
                cs1.add(en.getIndex());
                ChoiceNode ch1 = new ChoiceNode(cs1, node.getOrigin());
                pred.put(en, ch1);
                xg.addNode(ch1);
               
                LinkedHashSet<Integer> cs2 = new LinkedHashSet<Integer>();
                cs2.add(en.getContent());
                ChoiceNode ch2 = new ChoiceNode(cs2, node.getOrigin());
                succ.put(en, ch2);
                xg.addNode(ch2);
               
                en.setContent(ch2.getIndex());
            }
            else if (node instanceof AttributeNode) {
                AttributeNode an = (AttributeNode)node;
                LinkedHashSet<Integer> cs = new LinkedHashSet<Integer>();
                cs.add(an.getIndex());
                ChoiceNode ch = new ChoiceNode(cs, node.getOrigin());
                pred.put(an, ch);
                xg.addNode(ch);
            }
        }
        // update ingoing edges
View Full Code Here

                case ZeroOrMore:
                    empty = new SequenceNode(Collections.<Integer>emptyList(), origin);
                    on = new OneOrMoreNode(base.getIndex(), origin);
                    xg.addNode(empty);
                    xg.addNode(on);
                    result = new ChoiceNode(set(empty.getIndex(), on.getIndex()), origin);
                    xg.addNode(result);
                    break;
                case ZeroOrOne:
                default:
                    empty = new SequenceNode(Collections.<Integer>emptyList(), origin);
                    xg.addNode(empty);
                    result = new ChoiceNode(set(base.getIndex(), empty.getIndex()), origin);
                    xg.addNode(result);
                    break;
                }
               
                g.getTypemap().put(name, result);
View Full Code Here

            if (sn.getContents().size() == 0)
                return EPresence.EMPTY;
            else
                return null;
        } else if (node instanceof ChoiceNode) {
            ChoiceNode cn = (ChoiceNode)node;
            if (cn.isGap() && cn.isOpen())
                return gaps;
            else
                return null;
        } else {
            return null;
View Full Code Here

          if (!(node instanceof AttributeNode))
            continue;
          AttributeNode attr = (AttributeNode)node;
          if (g.getNode(attr.getContent()) instanceof TextNode)
            continue;
          ChoiceNode content = (ChoiceNode)g.getNode(attr.getContent());
          if (content.isGap() && content.isOpen() && g.getOpenAttributeGaps().contains(content.getName())) {
            addempty=true;
            break;
          }
        }
        if (addempty) {
View Full Code Here

//    this.config = config;
    global_xg = fg.getXMLGraph().clone();
    empty_xpath = new HashSet<Statement>();
    check_fails = new HashSet<Statement>();
    final StatementNodes stm_nodes = new StatementNodes();
    ChoiceNode dummy_root_content = new ChoiceNode(new ArrayList<Integer>(), null);
    global_xg.addNode(dummy_root_content);
    ElementNode dummy_root = new ElementNode(Automaton.makeEmpty(), dummy_root_content.getIndex(), false, null);
    global_xg.addNode(dummy_root);
    emptySequence = new SequenceNode(new ArrayList<Integer>(), null);
    global_xg.addNode(emptySequence);
    stm_nodes.setEmptySequenceNode(emptySequence);
    for (Statement s : fg.getNodes()) {
      s.visitBy(new BasicStatementVisitor() {
        @Override
        public void visitSetStm(SetStm s) {
          TextNode tn = new TextNode(Automaton.makeEmpty(), s.getOrigin());
          global_xg.addNode(tn);
          stm_nodes.setSetTextNode(s, tn);
        }
       
        @Override
        public void visitInsertStm(InsertStm s) {
          SequenceNode seq = new SequenceNode(new ArrayList<Integer>(), s.getOrigin());
          ChoiceNode left = new ChoiceNode(new LinkedHashSet<Integer>(), s.getOrigin());
          ChoiceNode right = new ChoiceNode(new LinkedHashSet<Integer>(), s.getOrigin());
          TextNode tn = new TextNode(Automaton.makeEmpty(), s.getOrigin());
         
          global_xg.addNode(seq);
          global_xg.addNode(left);
          global_xg.addNode(right);
          global_xg.addNode(tn);
         
          seq.addContent(left.getIndex());
          seq.addContent(right.getIndex());
         
          stm_nodes.setInsertLeftSide(s, left);
          stm_nodes.setInsertRightSide(s, right);
          stm_nodes.setInsertSequenceNode(s, seq);
          stm_nodes.setInsertTextNode(s, tn);
        }
       
        @Override
        public void visitConcatStm(ConcatStm s) {
          ChoiceNode cn = new ChoiceNode(new LinkedHashSet<Integer>(), s.getOrigin());
          SequenceNode sn = new SequenceNode(new ArrayList<Integer>(), s.getOrigin());
          OneOrMoreNode on = new OneOrMoreNode(cn.getIndex(), s.getOrigin());
          TextNode tn = new TextNode(Automaton.makeEmpty(), s.getOrigin());
         
          global_xg.addNode(cn);
          global_xg.addNode(sn);
          global_xg.addNode(on);
          global_xg.addNode(tn);
         
          on.setContent(cn.getIndex());
         
          stm_nodes.setConcatOneOrMoreNode(s, on);
          stm_nodes.setConcatTextNode(s, tn);
          stm_nodes.setConcatChoiceNode(s, cn);
          stm_nodes.setConcatSequenceNode(s, sn);
        }
       
        @Override
        public void visitConstStm(ConstStm s) {
          TemplateConstant t = s.getConst();
          try {
            stm_nodes.setTemplateConstantXMLFragment(t, t.getFragment());
          } catch (XMLTemplateException e) {
            Throwable tr = e;
            if (tr.getCause() != null)
              tr = tr.getCause();
            String msg = tr.getMessage();
            if (msg.endsWith("."))
              msg = msg.substring(0, msg.length() - 1);
           
            if (System.getProperty("dk.brics.xact.analysis.tolerate-errors") != null) {
              // error recovery if enabled
              System.err.println("Error: " + msg + " at " + s.getOrigin());
              Node empty = new ChoiceNode(new LinkedHashSet<Integer>(), s.getOrigin());
              global_xg.addNode(empty);
              stm_nodes.setTemplateConstantXMLFragment(t, new XMLGraphFragment(empty, new HashSet<String>(), new HashSet<String>(), new HashMap<String,String>()));
            } else {
              throw new XMLAnalysisException(msg, s.getOrigin());
            }
          }
        }

        @Override
        public void visitGetStm(GetStm s) {
          ChoiceNode cn = new ChoiceNode(new HashSet<Integer>(), s.getOrigin());
          global_xg.addNode(cn);
          stm_nodes.setGetChoiceNode(s, cn);
          switch (s.getKind()) {
          case GETNEXTATTR:
          case GETNEXTATTRIBUTE:
          case GETNEXTSIBLING:
          case GETFIRSTELEMENT:
              SequenceNode sq = new SequenceNode(new ArrayList<Integer>(), s.getOrigin());
              global_xg.addNode(sq);
              stm_nodes.setGetEmptySequence(s, sq);
//            OneOrMoreNode on = new OneOrMoreNode(cn.getIndex(), s.getOrigin());
//            global_xg.addNode(on);
//            stm_nodes.setGetOneOrMoreNode(s, on);
            break;
          }
        }
       
        @Override
        public void visitGapifyStm(GapifyStm s) {
          ChoiceNode cn = new ChoiceNode(s.getGapName(), false, false, new HashSet<Integer>(), s.getOrigin());
          global_xg.addNode(cn);
          stm_nodes.setGapifyChoiceNode(s, cn);
        }

        @Override
        public void visitPlugStm(PlugStm s) {
          switch (s.getKind()) {
          case CLOSE:
            SequenceNode sn = new SequenceNode(new ArrayList<Integer>(), s.getOrigin());
            global_xg.addNode(sn);
            stm_nodes.setPlugSequenceNode(s, sn);
            break;
           
          case PLUGMULTI:
          case PLUG: {
            TextNode tn = new TextNode(Automaton.makeEmpty(), s.getOrigin());
            global_xg.addNode(tn);
            stm_nodes.setPlugTextNode(s, tn);
            break;
          }
           
          case PLUGWRAP: {
            ChoiceNode top = new ChoiceNode(new LinkedHashSet<Integer>(), s.getOrigin());
            SequenceNode empty = new SequenceNode(new ArrayList<Integer>(), s.getOrigin());
            OneOrMoreNode on = new OneOrMoreNode(-1, s.getOrigin());
            ChoiceNode content = new ChoiceNode(new LinkedHashSet<Integer>(), s.getOrigin());
            TextNode tn = new TextNode(Automaton.makeEmpty(), s.getOrigin());
           
            global_xg.addNode(top);
            global_xg.addNode(empty);
            global_xg.addNode(on);
            global_xg.addNode(content);
            global_xg.addNode(tn);
           
            top.getContents().add(empty.getIndex());
            top.getContents().add(on.getIndex());
            on.setContent(content.getIndex());
            content.getContents().add(tn.getIndex());
           
            stm_nodes.setPlugWrapTopNode(s, top);
            stm_nodes.setPlugWrapContentNode(s, content);
            stm_nodes.setPlugTextNode(s, tn);
            break;
          }
          }
        }
       
        @Override
        public void visitRemoveStm(RemoveStm s) {
          SequenceNode sn = new SequenceNode(new ArrayList<Integer>(), s.getOrigin());
          global_xg.addNode(sn);
          stm_nodes.setRemoveSequenceNode(s, sn);
        }
       
        @Override
        public void visitNodeStm(NodeStm s) {
          switch (s.getKind()) {
          case ATTRIBUTE: {
            SequenceNode seq = new SequenceNode(new LinkedList<Integer>(), s.getOrigin());
            ChoiceNode left = new ChoiceNode(new LinkedHashSet<Integer>(), s.getOrigin());
            AttributeNode attr = new AttributeNode(s.getName(), 0, s.getOrigin());
            TextNode text = new TextNode(s.getValue(), s.getOrigin());

            global_xg.addNode(seq);
            global_xg.addNode(left);
            global_xg.addNode(text);
            global_xg.addNode(attr);
           
            seq.addContent(left.getIndex());
            left.getContents().add(attr.getIndex());
            attr.setContent(text.getIndex());
           
            stm_nodes.setStmNode(s, seq);
           
            if (s.getNextNode() != null) {
              ChoiceNode next = new ChoiceNode(new LinkedHashSet<Integer>(), s.getOrigin());
              global_xg.addNode(next);
              seq.addContent(next.getIndex());
              stm_nodes.setStmNextNode(s, next);
            }
            break;
          }
          case ELEMENT: {
            SequenceNode seq = new SequenceNode(new LinkedList<Integer>(), s.getOrigin());
            ChoiceNode left1 = new ChoiceNode(new LinkedHashSet<Integer>(), s.getOrigin());
            ChoiceNode left2 = new ChoiceNode(new LinkedHashSet<Integer>(), s.getOrigin());
            SequenceNode left3 = new SequenceNode(new LinkedList<Integer>(), s.getOrigin());
            ElementNode element = new ElementNode(s.getName(), 0, false, s.getOrigin());
           
            global_xg.addNode(seq);
            global_xg.addNode(left1);
            global_xg.addNode(left2);
            global_xg.addNode(left3);
            global_xg.addNode(element);
           
            seq.getContents().add(left1.getIndex());
            left1.getContents().add(element.getIndex());
            element.setContent(left2.getIndex());
            left2.getContents().add(left3.getIndex());
           
            stm_nodes.setStmNode(s, seq);
            if (s.getNextNode() != null) {
              ChoiceNode next = new ChoiceNode(new LinkedHashSet<Integer>(), s.getOrigin());
              global_xg.addNode(next);
              seq.addContent(next.getIndex());
              stm_nodes.setStmNextNode(s, next);
            }
            if (s.getFirstAttr() != null) {
              ChoiceNode attr = new ChoiceNode(new LinkedHashSet<Integer>(), s.getOrigin());
              global_xg.addNode(attr);
              left3.addContent(attr.getIndex());
              stm_nodes.setStmFirstAttribute(s, attr);
            }
            if (s.getFirstChild() != null) {
              ChoiceNode child = new ChoiceNode(new LinkedHashSet<Integer>(), s.getOrigin());
              global_xg.addNode(child);
              left3.addContent(child.getIndex());
              stm_nodes.setStmFirstChild(s, child);
            }
            break;
          }
          case TEXT: {
            SequenceNode seq = new SequenceNode(new ArrayList<Integer>(), s.getOrigin());
            TextNode tn = new TextNode(s.getValue(), s.getOrigin());
           
            global_xg.addNode(seq);
            global_xg.addNode(tn);
           
            seq.addContent(tn.getIndex());
            stm_nodes.setStmNode(s, seq);
           
            if (s.getNextNode() != null) {
              ChoiceNode next = new ChoiceNode(new LinkedHashSet<Integer>(), s.getOrigin());
              global_xg.addNode(next);
              seq.addContent(next.getIndex());
              stm_nodes.setStmNextNode(s, next);
            }
            break;
          }
          case TEMPLATEGAP:
          case ATTRIBUTEGAP: {
            SequenceNode seq = new SequenceNode(new LinkedList<Integer>(), s.getOrigin());
            ChoiceNode cn = new ChoiceNode(s.getGap(), false, false, new LinkedHashSet<Integer>(), s.getOrigin());

            global_xg.addNode(seq);
            global_xg.addNode(cn);
           
            seq.addContent(cn.getIndex());
            stm_nodes.setStmNode(s, seq);
            stm_nodes.setStmGap(s, cn);
           
            if (s.getNextNode() != null) {
              ChoiceNode next = new ChoiceNode(new LinkedHashSet<Integer>(), s.getOrigin());
              global_xg.addNode(next);
              seq.addContent(next.getIndex());
              stm_nodes.setStmNextNode(s, next);
            }
            break;
          }
          case COMMENT:
          case PROCESSINGINSTRUCTION: {
            SequenceNode sn = new SequenceNode(new LinkedList<Integer>(), s.getOrigin());
            global_xg.addNode(sn);
            stm_nodes.setStmNode(s, sn);
            if (s.getNextNode() != null) {
              ChoiceNode next = new ChoiceNode(new LinkedHashSet<Integer>(), s.getOrigin());
              global_xg.addNode(next);
              sn.addContent(next.getIndex());
              stm_nodes.setStmNextNode(s, next);
            }
            break;
          }
          default:
            throw new RuntimeException("unknown node stm kind: " + s.getKind());
          }
        }
       
        @Override
        public void visitCopyStm(CopyStm s) {
          SequenceNode seq = new SequenceNode(new LinkedList<Integer>(), s.getOrigin());
          ChoiceNode left1 = new ChoiceNode(new LinkedHashSet<Integer>(), s.getOrigin());
          global_xg.addNode(seq);
          global_xg.addNode(left1);
          stm_nodes.setCopyTopNode(s, seq);
          stm_nodes.setCopyLeftChoice(s, left1);
          seq.addContent(left1.getIndex());
         
          if (s.getNextNode() != null) {
            ChoiceNode next = new ChoiceNode(new LinkedHashSet<Integer>(), s.getOrigin());
            global_xg.addNode(next);
            seq.addContent(next.getIndex());
            stm_nodes.setCopyNextNode(s, next);
          }
          switch (s.getKind()) {
          case ELEMENT: { // element nodes are handled specially
            ChoiceNode left2 = new ChoiceNode(new LinkedHashSet<Integer>(), s.getOrigin());
            SequenceNode left3 = new SequenceNode(new LinkedList<Integer>(), s.getOrigin());
            ElementNode element = new ElementNode(Automaton.makeEmpty(), 0, false, s.getOrigin());
           
            global_xg.addNode(left2);
            global_xg.addNode(left3);
            global_xg.addNode(element);
           
            stm_nodes.setCopyElementNode(s, element);
           
            left1.getContents().add(element.getIndex());
            element.setContent(left2.getIndex());
            left2.getContents().add(left3.getIndex());
            if (s.getFirstAttr() != null) {
              ChoiceNode attr = new ChoiceNode(new LinkedHashSet<Integer>(), s.getOrigin());
              global_xg.addNode(attr);
              left3.addContent(attr.getIndex());
              stm_nodes.setCopyFirstAttribute(s, attr);
            }
            if (s.getFirstChild() != null) {
              ChoiceNode child = new ChoiceNode(new LinkedHashSet<Integer>(), s.getOrigin());
              global_xg.addNode(child);
              left3.addContent(child.getIndex());
              stm_nodes.setCopyFirstChild(s, child);
            }
            break;
          }
          case ATTRIBUTE:
          case ATTRNODE:
            break;
          case PROCESSINGINSTRUCTION:
          case COMMENT:
            break;
          case ATTRIBUTEGAP:
          case TEMPLATEGAP:
            break;
          case TEXT:
          case TEMPNODE:
            break;
          }//switch
        }
        @Override
        public void visitValidateStm(ValidateStm s) {
          if (s.getSchema().getGapTypes() != null) {
            for (Map.Entry<String,String> entry : s.getSchema().getGapTypes().entrySet()) {
              ChoiceNode gap = new ChoiceNode(entry.getKey(), false, false, new LinkedHashSet<Integer>(), s.getSchema().getOrigin());
              global_xg.addNode(gap);
              stm_nodes.setValidateGap(s, entry.getKey(), gap);
            }
          }
        }
View Full Code Here

   * @param node a choice node
   * @param g graph in which to replace the edges
   */
  private void restoreEdges(ChoiceNode node, XMLGraph g) {
    int index = node.getIndex();
    ChoiceNode gx = (ChoiceNode)global_xg.getNode(index);
    if (node.getContents() == gx.getContents())
      return;
    if (node.getContents().containsAll(gx.getContents()))
      return;
    if (node.getContents().isEmpty()) {
      node.setContent(gx.getContents(), g);
    } else {
      LinkedHashSet<Integer> cs = new LinkedHashSet<Integer>(node.getContents());
      cs.addAll(gx.getContents());
      node.setContent(cs, g);
    }
  }
View Full Code Here

  public XMLGraph transferConcat(ConcatStm s, XMLGraph xmlsource) {
    XMLGraph g = xmlsource.clone();
    if (g.isUnknown()) {
      return g;
    }
    ChoiceNode cn = stm_nodes.getConcatChoiceNode(s,g);
    Set<Integer> cs = new LinkedHashSet<Integer>();
    //cs.addAll(cn.getContents());
    stm_nodes.getConcatTextNode(s, g).replaceText(s.getStringSource(), g);
    if (!s.getStringSource().isEmpty()) {
      cs.add(stm_nodes.getConcatTextNode(s, g).getIndex());
    }
    cs.add(stm_nodes.getConcatSequenceNode(s, g).getIndex());
    cs.addAll(g.getRoots());
    cn.setContent(cs, g);
    g.getRoots().clear();
    g.getRoots().add(stm_nodes.getConcatOneOrMoreNode(s, g).getIndex());
    //stm_nodes.getConcatTextNode(s,g).replaceText(s.getStringSource(), g);
    g.sharpen();
    return g;
View Full Code Here

    case ATTRNODE:
    case ATTRIBUTEGAP:
    case TEMPLATEGAP:
    case TEMPNODE:
    case TEXT:
      ChoiceNode left = stm_nodes.getCopyLeftChoice(s, g);
      final LinkedHashSet<Integer> leftContent = new LinkedHashSet<Integer>();
      if (nextnode != null) {
        g.merge(nextnode);
        g.getRoots().clear();
        g.getRoots().add(stm_nodes.getCopyTopNode(s, g).getIndex());
        stm_nodes.getCopyNextNode(s, g).setContent(nextnode.getRoots(), g);
      }
      apply(base, new CachedNodeProcessor<EPresence>() {
        @Override
        public EPresence cycle() {
          return EPresence.UNKNOWN;
        }
        @Override
        public EPresence process(AttributeNode n) {
          leftContent.add(n.getIndex());
          //addChild(left, n.getIndex(), g);
          //left.getContents().add(n.getIndex());
          return EPresence.NONEMPTY;
        }
        @Override
        public EPresence process(ElementNode n) {
          return EPresence.BOTTOM;
        }
        @Override
        public EPresence process(OneOrMoreNode n) {
          return base.getNode(n.getContent()).process(this);
        }
        @Override
        public EPresence process(TextNode n) {
          if (s.getKind() == CopyStm.Kind.TEXT) {
            if (n.getText().isEmpty())
              return EPresence.BOTTOM;
            leftContent.add(n.getIndex());
            //addChild(left, child, g)
            //left.getContents().add(n.getIndex());
            if (n.getText().isEmptyString())
              return EPresence.EMPTY;
            else if (n.getText().run(""))
              return EPresence.UNKNOWN;
            else
              return EPresence.NONEMPTY;
          }
          return EPresence.BOTTOM;
        }
        @Override
        public EPresence process(ChoiceNode n) {
          EPresence p = EPresence.BOTTOM;
          if (n.isGap() && n.isOpen()) {
            if (base.getOpenAttributeGaps().contains(n.getName()) || base.getOpenTemplateGaps().contains(n.getName())) {
              //left.getContents().add(n.getIndex());
              leftContent.add(n.getIndex());
              p = EPresence.UNKNOWN;
            }
          }
          for (int child : n.getContents()) {
            p = p.leastUpperBound(base.getNode(child).process(this));
          }
          return p;
        }
        @Override
        public EPresence process(SequenceNode n) {
          EPresence p = EPresence.EMPTY;
          for (int child : n.getContents()) {
            p = p.concat(base.getNode(child).process(this));
            if (p.definitelyNonEmpty())
              break;
          }
          return p;
        }
        @Override
        public EPresence process(InterleaveNode n) {
          EPresence p = EPresence.BOTTOM;
          for (int child : n.getContents()) {
            p = p.leastUpperBound(base.getNode(child).process(this));
          }
          return p;
        }
      });
      left.setContent(leftContent, g);
      //left.getContents().addAll(base.getRoots());
      break;
    default:
      throw new RuntimeException("unexpected copy type " + s.getKind());
    }
View Full Code Here

TOP

Related Classes of dk.brics.xmlgraph.ChoiceNode

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.