Package nu.xom

Examples of nu.xom.Node$EmptyNamespaceContext


    if (node == null)
      throw new TransformerException("node must not be null");
    if (node instanceof DocType)
      throw new TransformerException("DocType can't be queried by XQuery/XPath");
   
    Node root = node;
    while (root.getParent() != null) {
      root = root.getParent();
    }

    DocumentWrapper docWrapper = null;
    if (docWrappers != null) docWrapper = (DocumentWrapper) docWrappers.get(root);
   
    if (docWrapper == null) { // root has not been seen before
      docWrapper = new DocumentWrapper(root, root.getBaseURI(), getStaticContext().getConfiguration());
     
      // remember the DocWrapper for the given root so we can reuse it later
      if (docWrappers != null) docWrappers.put(root, docWrapper);
    }
   
View Full Code Here


   

    public void testSelfAxisWithTextChild() {
       
        Element parent = new Element("parent");
        Node child = new Text("child");
        parent.appendChild(child);
        Nodes result = child.query("self::text()");
        assertEquals(1, result.size());
        assertEquals(child, result.get(0));
       
    }
View Full Code Here

   

    public void testSelfAxisWithTextChildren() {
       
        Element parent = new Element("parent");
        Node child1 = new Text("1");
        Node child2 = new Text("2");
        Node child3 = new Text("3");
        Node child4 = new Text("4");
        parent.appendChild(child1);
        parent.appendChild(child2);
        parent.appendChild(child3);
        parent.appendChild(child4);
        Nodes result = child1.query("self::text()");
View Full Code Here

   

    public void testSelfAxisWithTextChildren2() {
       
        Element parent = new Element("parent");
        Node child1 = new Text("1");
        Node child2 = new Text("2");
        Node child3 = new Text("3");
        Node child4 = new Text("4");
        parent.appendChild(child1);
        parent.appendChild(child2);
        parent.appendChild(child3);
        parent.appendChild(child4);
        Nodes result = child3.query("self::text()");
View Full Code Here

    }
   

    public void testSelfAxisWithTextChildAndNoParent() {
       
        Node child = new Text("child");
        Nodes result = child.query("self::text()");
        assertEquals(1, result.size());
        assertEquals(child, result.get(0));
       
    }
View Full Code Here

                // XPath expressions
                if (queryUsesVars(contextElement)) continue;
               
                String xpath = contextElement.getAttributeValue("select");
                XPathContext namespaces = getXPathContext(contextElement);
                Node context = source.query(xpath).get(0);
               
                // process counts
                Elements tests = contextElement.getChildElements("test");
                for (int k = 0; k < tests.size(); k++) {
                    Element test = tests.get(k);
                   
                    String select = test.getAttributeValue("select");
                    Attribute countAttribute = test.getAttribute("count");
                    int count = -1;
                    if (countAttribute != null) {
                        count = Integer.parseInt(countAttribute.getValue());
                    }
                   
                    boolean exceptional = false;
                    String exception = test.getAttributeValue("exception");
                    if ("true".equals(exception)) {
                        exceptional = true;
                    }
                   
                    if (exceptional) {
                        try {
                            context.query(select, namespaces);
                            fail("Evaluated " + select);
                        }
                        catch (XPathException success) {
                            assertNotNull(success.getMessage());
                        }
                    }
                    else {
                        try {
                            Nodes results = context.query(select, namespaces);
                            if (count != -1) {
                                assertEquals(select, count, results.size());
                            }
                            Elements valueOfs = test.getChildElements("valueOf");
                            for (int v = 0; v < valueOfs.size(); v++) {
View Full Code Here

    public String getValue() {
        // currentElement.getValue() not used as this includes text of child elements, which we don't want.
        final StringBuffer result = new StringBuffer();
        final int childCount = currentElement.getChildCount();
        for (int i = 0; i < childCount; i++) {
            final Node child = currentElement.getChild(i);
            if (child instanceof Text) {
                final Text text = (Text)child;
                result.append(text.getValue());
            }
        }
View Full Code Here

        doc.newPage();
    }

    private static void addNode(Node rootNode, HyphenationAuto hyphenation, Paragraph paragraph, String marker) throws FB2toPDFException {
        for (int j=0; j<rootNode.getChildCount(); j++) {
            Node node = rootNode.getChild(j);
            if (node instanceof Text) {
                Chunk chunk = noteStyle.createChunk();
                chunk.setHyphenation(hyphenation);
                if (superscript) {
                    chunk.setTextRise(noteStyle.getFontSize() / 3);
                }
                if (subscript) {
                    chunk.setTextRise(-noteStyle.getFontSize() / 12);
                }
                String value = (marker == null) ? node.getValue() : marker + " " + node.getValue();
                chunk.append(value);
                paragraph.add(chunk);
                marker = null;
                continue;
            }
View Full Code Here

              value,
              Attribute.Type.UNDECLARED
            );
            int size = nodes.size();
            for (int j=0; j < size; j++) {
                Node node = nodes.get(j);
                if (node instanceof Attribute) {
                    Attribute attribute = (Attribute) node;
                    while (true) {
                        try {
                            element.addAttribute(attribute);
View Full Code Here

        else {
            Nodes nodes = factory.finishMakingElement(element);
            ParentNode parent = element.getParent();
            element.detach();
            for (int i = 0; i < nodes.size(); i++) {
                Node node = nodes.get(i);
                if (node instanceof Attribute) {
                    ((Element) parent).addAttribute((Attribute) node);
                }
                else {
                    parent.appendChild(node);
View Full Code Here

TOP

Related Classes of nu.xom.Node$EmptyNamespaceContext

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.