Examples of AxisNodes


Examples of com.xmlcalabash.util.AxisNodes

                if (!cx_options.equals(root.getNodeName())) {
                    throw new XProcException(step.getNode(), "Options port must be a cx:options document.");
                }

               
                for (XdmNode opt : new AxisNodes(runtime, root, Axis.CHILD, AxisNodes.SIGNIFICANT)) {
                    if (opt.getNodeKind() != XdmNodeKind.ELEMENT || !cx_option.equals(opt.getNodeName())) {
                        throw new XProcException(step.getNode(), "A cx:options document must only contain cx:option elements");
                    }

                    String name = opt.getAttributeValue(_name);
View Full Code Here

Examples of com.xmlcalabash.util.AxisNodes

        root = S9apiUtils.getDocumentElement(builder.build(new SAXSource(new InputSource(new StringReader(xml)))));
    }

    @Test
    public void testALL() {
        AxisNodes an = new AxisNodes(root, Axis.CHILD, AxisNodes.ALL);

        XdmNode n = an.iterator().next();
        assertEquals(n.getNodeKind(), XdmNodeKind.PROCESSING_INSTRUCTION);

        n = an.iterator().next();
        assertEquals(n.getNodeKind(), XdmNodeKind.ELEMENT);
        assertEquals(n.getNodeName(), new QName("", "p"));

        n = an.iterator().next();
        assertEquals(n.getNodeKind(), XdmNodeKind.TEXT);
        assertEquals(n.toString(), " ");

        n = an.iterator().next();
        assertEquals(n.getNodeKind(), XdmNodeKind.ELEMENT);
        assertEquals(n.getNodeName(), new QName("", "p"));

        n = an.iterator().next();
        assertEquals(n.getNodeKind(), XdmNodeKind.TEXT);
        assertEquals(n.toString(), " some text ");

        n = an.iterator().next();
        assertEquals(n.getNodeKind(), XdmNodeKind.ELEMENT);
        assertEquals(n.getNodeName(), new QName("", "p"));

        n = an.iterator().next();
        assertEquals(n.getNodeKind(), XdmNodeKind.COMMENT);

        n = an.iterator().next();
        assertEquals(n.getNodeKind(), XdmNodeKind.ELEMENT);
        assertEquals(n.getNodeName(), new QName("http://www.w3.org/ns/xproc", "documentation"));

        assertEquals(an.iterator().hasNext(), false);
    }
View Full Code Here

Examples of com.xmlcalabash.util.AxisNodes

        assertEquals(an.iterator().hasNext(), false);
    }

    @Test
    public void testSIGNIFICANT() {
        AxisNodes an = new AxisNodes(root, Axis.CHILD, AxisNodes.SIGNIFICANT);

        XdmNode n = an.iterator().next();
        assertEquals(n.getNodeKind(), XdmNodeKind.ELEMENT);
        assertEquals(n.getNodeName(), new QName("", "p"));

        n = an.iterator().next();
        assertEquals(n.getNodeKind(), XdmNodeKind.ELEMENT);
        assertEquals(n.getNodeName(), new QName("", "p"));

        n = an.iterator().next();
        assertEquals(n.getNodeKind(), XdmNodeKind.TEXT);
        assertEquals(n.toString(), " some text ");

        n = an.iterator().next();
        assertEquals(n.getNodeKind(), XdmNodeKind.ELEMENT);
        assertEquals(n.getNodeName(), new QName("", "p"));

        n = an.iterator().next();
        assertEquals(n.getNodeKind(), XdmNodeKind.ELEMENT);
        assertEquals(n.getNodeName(), new QName("http://www.w3.org/ns/xproc", "documentation"));

        assertEquals(an.iterator().hasNext(), false);
    }
View Full Code Here

Examples of com.xmlcalabash.util.AxisNodes

        assertEquals(an.iterator().hasNext(), false);
    }

    @Test
    public void testPIPELINE() {
        AxisNodes an = new AxisNodes(null, root, Axis.CHILD, AxisNodes.PIPELINE);

        XdmNode n = an.iterator().next();
        assertEquals(n.getNodeKind(), XdmNodeKind.ELEMENT);
        assertEquals(n.getNodeName(), new QName("", "p"));

        n = an.iterator().next();
        assertEquals(n.getNodeKind(), XdmNodeKind.ELEMENT);
        assertEquals(n.getNodeName(), new QName("", "p"));

        n = an.iterator().next();
        assertEquals(n.getNodeKind(), XdmNodeKind.TEXT);
        assertEquals(n.toString(), " some text ");

        n = an.iterator().next();
        assertEquals(n.getNodeKind(), XdmNodeKind.ELEMENT);
        assertEquals(n.getNodeName(), new QName("", "p"));

        assertEquals(an.iterator().hasNext(), false);
    }
View Full Code Here

Examples of com.xmlcalabash.util.AxisNodes

        XdmNode doc = source.read();
        tree = new TreeWriter(runtime);
        tree.startDocument(baseURI);

        for (XdmNode node : new AxisNodes(doc, Axis.CHILD)) {
            write(node,false);
        }

        tree.endDocument();
View Full Code Here

Examples of com.xmlcalabash.util.AxisNodes

                if (underXmlBase) {
                    tree.addStartElement(node);
                } else {
                    tree.addStartElement(node, baseURI);
                }
                for (XdmNode child : new AxisNodes(node, Axis.ATTRIBUTE)) {
                    tree.addAttribute(child);
                }
                for (XdmNode child : new AxisNodes(node, Axis.CHILD)) {
                    write(child,underXmlBase);
                }
                tree.addEndElement();
                break;
            case TEXT:
View Full Code Here

Examples of com.xmlcalabash.util.AxisNodes

            tree.addAttribute(_status, ""+status);
            tree.addAttribute(_readable, status >= 200 && status < 400 ? "true" : "false");
            tree.addAttribute(_exists, status >= 400 && status < 500 ? "false" : "true");
            tree.addAttribute(_uri, uri.toASCIIString());

            for (XdmNode node : new AxisNodes(result, Axis.CHILD, AxisNodes.SIGNIFICANT)) {
                if ("Last-Modified".equals(node.getAttributeValue(_name))) {
                    String months[] = {"JAN", "FEB", "MAR", "APR", "MAY", "JUN",
                                       "JUL", "AUG", "SEP", "OCT", "NOV", "DEC" };
                    String dateStr = node.getAttributeValue(_value);
                    // dateStr = Fri, 13 Mar 2009 12:12:07 GMT
                    //           00000000001111111111222222222
                    //           01234567890123456789012345678

                    //System.err.println("dateStr: " + dateStr);
                   
                    String dayStr = dateStr.substring(5,7);
                    String monthStr = dateStr.substring(8,11).toUpperCase();
                    String yearStr = dateStr.substring(12,16);
                    String timeStr = dateStr.substring(17,25);
                    String tzStr = dateStr.substring(26,29);

                    int month = 0;
                    for (month = 0; month < 12; month++) {
                        if (months[month].equals(monthStr)) {
                            break;
                        }
                    }

                    tree.addAttribute(_last_modified, String.format("%1$04d-%2$02d-%3$02dT%4$s%5$s",
                            Integer.parseInt(yearStr), month+1, Integer.parseInt(dayStr), timeStr,
                            "GMT".equals(tzStr) ? "Z" : ""));
                }

                if ("Content-Length".equals(node.getAttributeValue(_name))) {
                    tree.addAttribute(_size, node.getAttributeValue(_value));
                }
            }


            tree.startContent();

            for (XdmNode node : new AxisNodes(result, Axis.CHILD, AxisNodes.SIGNIFICANT)) {
                tree.addSubtree(node);
            }

            tree.addEndElement();
        }
View Full Code Here

Examples of com.xmlcalabash.util.AxisNodes

        XdmNode doc = source.read();

        TreeWriter tree = new TreeWriter(runtime);
        tree.startDocument(doc.getBaseURI());
        for (XdmNode child : new AxisNodes(doc, Axis.CHILD)) {
            if (child.getNodeKind() == XdmNodeKind.COMMENT) {
                tree.addComment(child.getStringValue());
            } else if (child.getNodeKind() == XdmNodeKind.PROCESSING_INSTRUCTION) {
                tree.addPI(child.getNodeName().getLocalName(), child.getStringValue());
            } else if (child.getNodeKind() == XdmNodeKind.TEXT) {
View Full Code Here

Examples of com.xmlcalabash.util.AxisNodes

            tree.addAttribute(_status, ""+status);
            tree.addAttribute(_readable, status >= 200 && status < 400 ? "true" : "false");
            tree.addAttribute(_exists, status >= 400 && status < 500 ? "false" : "true");
            tree.addAttribute(_uri, uri.toASCIIString());

            for (XdmNode node : new AxisNodes(result, Axis.CHILD, AxisNodes.SIGNIFICANT)) {
                if ("Last-Modified".equals(node.getAttributeValue(_name))) {
                    String months[] = {"JAN", "FEB", "MAR", "APR", "MAY", "JUN",
                                       "JUL", "AUG", "SEP", "OCT", "NOV", "DEC" };
                    String dateStr = node.getAttributeValue(_value);
                    // dateStr = Fri, 13 Mar 2009 12:12:07 GMT
                    //           00000000001111111111222222222
                    //           01234567890123456789012345678

                    //System.err.println("dateStr: " + dateStr);

                    String dayStr = dateStr.substring(5,7);
                    String monthStr = dateStr.substring(8,11).toUpperCase();
                    String yearStr = dateStr.substring(12,16);
                    String timeStr = dateStr.substring(17,25);
                    String tzStr = dateStr.substring(26,29);

                    int month = 0;
                    for (month = 0; month < 12; month++) {
                        if (months[month].equals(monthStr)) {
                            break;
                        }
                    }

                    tree.addAttribute(_last_modified, String.format("%1$04d-%2$02d-%3$02dT%4$s%5$s",
                            Integer.parseInt(yearStr), month+1, Integer.parseInt(dayStr), timeStr,
                            "GMT".equals(tzStr) ? "Z" : ""));
                }

                if ("Content-Length".equals(node.getAttributeValue(_name))) {
                    tree.addAttribute(_size, node.getAttributeValue(_value));
                }
            }


            tree.startContent();

            for (XdmNode node : new AxisNodes(result, Axis.CHILD, AxisNodes.SIGNIFICANT)) {
                tree.addSubtree(node);
            }

            tree.addEndElement();
        }
View Full Code Here

Examples of com.xmlcalabash.util.AxisNodes

        XdmNode root = S9apiUtils.getDocumentElement(doc);
        if (!c_cookies.equals(root.getNodeName())) {
            throw new XProcException(step.getNode(), "The input to cx:set-cookies must be a c:cookies document.");
        }
       
        for (XdmNode node : new AxisNodes(root, Axis.CHILD, AxisNodes.SIGNIFICANT)) {
            if (node.getNodeKind() == XdmNodeKind.ELEMENT) {
                if (!c_cookie.equals(node.getNodeName())) {
                    throw new XProcException(step.getNode(), "A c:cookies document must contain only c:cookie elements.");
                }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.