Package dk.brics.xmlgraph

Examples of dk.brics.xmlgraph.ReachableNodesProcessor


    //} catch (XPathException e) {
    //  throw new XMLXPathException(e);
    //}
    final StatusMap sm = smt;
    checkXPathEmpty(s, base, sm);
    g.processRoots(new ReachableNodesProcessor(g) { 
      @Override
      public Object process(ChoiceNode n) { // all concrete nodes have a choice node parent
        Collection<Integer> cs = new LinkedHashSet<Integer>();
        boolean modified = false;
        boolean add_gap = false;
View Full Code Here


    case PLUGWRAP:
      final String gapname = s.getGapName();
      // plug roots into the relevant gaps and merge the XML graphs
      final boolean skip_str = s.getStringSource().isEmpty();
      if (g.getOpenAttributeGaps().contains(gapname) || g.getOpenTemplateGaps().contains(gapname)) {
        g.processRoots(new ReachableNodesProcessor(g) { 
          @Override
          public Object process(ChoiceNode n) {
            if (n.isGap() && n.isOpen() && n.getName().equals(gapname)) {
              Collection<Integer> c = new LinkedHashSet<Integer>();
              c.addAll(n.getContents());
              c.addAll(xmlsrc.getRoots());
              if (!skip_str)
                c.add(stm_nodes.getPlugTextNode(s,g).getIndex());
              n.setContentAndStatus(false, n.isRemoved(), c, g);
            }
            return null;
          }
        });
      }
      if (!skip_str) {
        TextNode tn = stm_nodes.getPlugTextNode(s,g);
        ArrayList<Automaton> ss = new ArrayList<Automaton>();
        ss.add(s.getStringSource());
        ss.add(tn.getText());
        tn.replaceText(Automaton.union(ss), g);
      }
      g.merge(xmlsrc);
      if (s.getKind() == PlugStm.Kind.PLUGWRAP) {
        g.getRoots().clear();
        g.getRoots().add(stm_nodes.getPlugWrapTopNode(s, g).getIndex());
        restoreEdges(stm_nodes.getPlugWrapTopNode(s, g), g);
        stm_nodes.getPlugWrapContentNode(s, g).setContent(base.getRoots(), g);
      } else {
        g.getRoots().retainAll(base.getRoots());
      }
      // mark the gap as closed
      if (g.getOpenTemplateGaps().contains(gapname))
        g.addClosedTemplateGap(gapname);
      g.removeOpenTemplateGap(gapname);
      if (g.getOpenAttributeGaps().contains(gapname))
        g.addClosedAttributeGap(gapname);
      g.removeOpenAttributeGap(gapname);
      g.getGapTypeMap().remove(gapname);
      // open again if the inserted value contains the gap
      if (xmlsrc.getOpenTemplateGaps().contains(gapname)) {
        g.addOpenTemplateGap(gapname);
        if (!xmlsrc.getClosedTemplateGaps().contains(gapname))
          g.removeClosedTemplateGap(gapname);
        String gaptype = xmlsrc.getGapTypeMap().get(gapname);
        if (gaptype != null)
          g.getGapTypeMap().put(gapname, gaptype);
     
      if (xmlsrc.getOpenAttributeGaps().contains(gapname)) {
        g.addOpenAttributeGap(gapname);
        if (!xmlsrc.getClosedAttributeGaps().contains(gapname))
          g.removeClosedAttributeGap(gapname);
        String gaptype = xmlsrc.getGapTypeMap().get(gapname);
        if (gaptype != null)
          g.getGapTypeMap().put(gapname, gaptype);
     
//      XMLGraphDebug.dumpXMLGraph(g, s);
      break;
    case CLOSE:
      g.processRoots(new ReachableNodesProcessor(g) { 
        @Override
        public Object process(ChoiceNode n) {
          if (n.isGap() && n.isOpen()) {
            Collection<Integer> c = new LinkedHashSet<Integer>();
            c.addAll(n.getContents());
View Full Code Here

    }
    StatusMap smt;
    smt = evaluateXPathOrRoot(s.getXPath(), base); //evaluator.evaluate(base, s.getXPath(), dummy_root, dummy_root_content);
    final StatusMap sm = smt;
    checkXPathEmpty(s, base, sm);
    g.processRoots(new ReachableNodesProcessor(g) { 
      @Override
      public Object process(ChoiceNode n) { // all concrete nodes have a choice node parent
        Collection<Integer> cs = new LinkedHashSet<Integer>();
        boolean modified = false;
        boolean add_emptyseq = false;
View Full Code Here

TOP

Related Classes of dk.brics.xmlgraph.ReachableNodesProcessor

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.