Package dk.brics.xact

Examples of dk.brics.xact.Node


    }

    @Override
    public void startElement(String uri, String localname, String name, Attributes attrs) {
        Origin origin = getOrigin();
        Node n;
        if (uri.equals(XMLParser.XACT_NAMESPACE)) {
            if (localname.equals("tgap")) {
                n = new TemplateGap(attrs.getValue("", "gap"), attrs.getValue("", "type"), origin);
            } else { // agap
                String ns = null;
View Full Code Here


    @Override
    public void endElement(String uri, String localname, String name) {
        Stack<Node> children = siblings.pop();
        TempNode c = null;
        Node n = siblings.peek().pop();
        if (n instanceof Element) {
            Element e = (Element) n;
            AttrNode a = e.getFirstAttr();
            while (!children.isEmpty()) {
                Node m = children.pop();
                if (m instanceof AttributeGap) { // element with agap child
                    a = ((AttributeGap) m).copy(a);
                } else {
                    c = ((TempNode) m).copy(c);
                }
            }
            n = e.copy(a, c, e.getNextSibling());
        } else if (n instanceof AttributeGap) {
            if (!siblings.peek().isEmpty()) {
                Node m = siblings.peek().pop();
                if (m instanceof Element) { // element with agap successor
                    Element f = (Element) m;
                    m = f.copy(((AttributeGap) n).copy(f.getFirstAttr()), f.getFirstChild(), f.getNextSibling());
                    n = null;
                }
View Full Code Here

          @Override public void visit(ProcessingInstructionWrapper w) {
            w.setReal(w.getReal().copy(w.getRealNextSibling()));
          }
        });
        if (selectedset.contains(e.node) && e.node != root) {
          Node en = e.node.getReal();
          if (remove_successors) {
            if (en instanceof TempNode) {
              en = ((TempNode) en).copy(null);
            } else if (en instanceof AttrNode) {
              en = ((AttrNode) en).copy(null);
View Full Code Here

    final StringBuilder b = new StringBuilder();
    final Stack<Node> stack = new Stack<Node>(); // using heap stack, avoids deep recursive calls
    if (e.getFirstChild() != null)
      stack.push(e.getFirstChild());
    while (!stack.isEmpty()) {
      Node n = stack.pop();
      n.visitBy(new NodeVisitor() {
        @Override
        public void visit(Text n) {
          printEscaped(b, n.getString(), false);
          if (n.getNextSibling() != null)
            stack.push(n.getNextSibling());
        }

        @Override
        public void visit(Element n) {
          if (n.getNextSibling() != null)
            stack.push(n.getNextSibling());
          if (n.getFirstChild() != null)
            stack.push(n.getFirstChild());
        }
      });
    }
    return b.toString();
  }
View Full Code Here

TOP

Related Classes of dk.brics.xact.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.