Package dk.brics.xact

Examples of dk.brics.xact.Element


        } else {
            NamespaceDecl lns = null;
            for (NamespaceDecl ns : nsDecls) {
                lns = new NamespaceDecl(ns.getPrefix(), ns.getNamespace(),lns, null);
            }
            n = new Element(uri, localname, makeAttributes(attrs, origin), null, lns, null, origin);
            nsDecls = new LinkedList<NamespaceDecl>();
        }
        siblings.peek().push(n);
        siblings.push(new Stack<Node>());
    }
View Full Code Here


    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;
                }
                siblings.peek().push(m);
            }
        }
View Full Code Here

      throw new XMLXPathException(e.getCause());
    }
  }
 
  private static ElementWrapper makeRoot(XML context) {
    return new ElementWrapper((Element)new Element("root").appendContent(context), null); // used as document root node
  }
View Full Code Here

          }

        });
        break;
      case END_ELEMENT:
        Element n = (Element) (en.node);
        boolean whitespaceSense = en.whitespaceSensitive || indentation.isWhitespaceSensitive(n);
        boolean indentElem = !whitespaceSense && indentation.getIndentType(n) == XMLIndentation.IndentType.BLOCK;
        boolean isBlock = !whitespaceSense && indentation.getIndentType(n) != XMLIndentation.IndentType.NONE;
        if (indentElem) {
          p.append(linebreak).append(en.indent);
        }
        p.append("</");
        String namespace = n.getNamespace();
        String prefix = ns.getPrefix(namespace).peek();
        if (prefix.length() > 0)
          p.append(prefix).append(':');
        p.append(n.getLocalName()).append('>');
        ns.popNamespaceDeclarations(en.nsdecls);
        if (n.getNextSibling() != null)
          stack.push(new Entry(Entry.Kind.START_NODE, n.getNextSibling(), null, en.whitespaceSensitive, en.indent, isBlock));
        break;
      }
    }
    p.flush();
  }
View Full Code Here

            throw e.e;
          }
          break;

        case END_ELEMENT:
          Element n = (Element) (en.node);
          String qName = getQName(ns, n.getNamespace(), n.getLocalName());
          contentHandler.endElement(n.getNamespace(), n.getLocalName(), qName);
          for (String p : en.nsdecls.keySet())
            contentHandler.endPrefixMapping(p);
          ns.popNamespaceDeclarations(en.nsdecls);
          if (n.getNextSibling() != null)
            stack.push(new Entry(Entry.Kind.START_NODE, n.getNextSibling(),null));
          break;
        }
      }
      contentHandler.endDocument();
    }
View Full Code Here

TOP

Related Classes of dk.brics.xact.Element

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.