Package dk.brics.xmlgraph

Examples of dk.brics.xmlgraph.AttributeNode


        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());
            addGapType(n.getGap(), n.getType(), n.getOrigin());
          }
          push(n.getNextAttr(), m.parent);
        }
View Full Code Here


                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);
            }
        }
View Full Code Here

        boolean addempty=false;
        for (int child : n.getContents()) {
          Node node = g.getNode(child);
          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;
          }
        }
View Full Code Here

        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);
View Full Code Here

TOP

Related Classes of dk.brics.xmlgraph.AttributeNode

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.