Package org.xml.sax

Examples of org.xml.sax.ContentHandler.endDocument()


        handler.startElement("", "tset", "tset", new AttributesImpl());
        handler.endElement("", "tset", "tset");
        handler.endElement("", "test", "test");
        handler.endPrefixMapping("bar");
        handler.endPrefixMapping("foo");
        handler.endDocument();
        assertEquals(
                "<?xml version=\"1.0\"?>"
                + "<test xmlns:foo=\"http://x.y.z/\" xmlns:bar=\"http://a.b.c/\">"
                + "<tset xmlns:foo=\"http://a.b.c/\"/><tset/>"
                + "</test>",
View Full Code Here


                  NodeValue content = ModuleUtils.streamToXML(context, new ByteArrayInputStream(baos.toByteArray()));
                  resource = target.createResource(name, "XMLResource");
                  ContentHandler handler = ((XMLResource)resource).setContentAsSAX();
                  handler.startDocument();
                  content.toSAX(context.getBroker(), handler, null);
                  handler.endDocument();
                } catch(SAXException e){
                  resource = target.createResource(name, "BinaryResource");
                  resource.setContent(baos.toByteArray());
                    }
               
View Full Code Here

    public void testMinimalDocument() throws SAXException {
        ContentHandler handler = new ToXmlContentHandler();
        handler.startDocument();
        handler.startElement("", "test", "test", new AttributesImpl());
        handler.endElement("", "test", "test");
        handler.endDocument();
        assertEquals("<?xml version=\"1.0\"?><test/>", handler.toString());
    }

    public void testAttribute() throws SAXException {
        ContentHandler handler = new ToXmlContentHandler();
View Full Code Here

        handler.startDocument();
        AttributesImpl attributes = new AttributesImpl();
        attributes.addAttribute("", "foo", "foo", "CDATA", "bar");
        handler.startElement("", "test", "test", attributes);
        handler.endElement("", "test", "test");
        handler.endDocument();
        assertEquals(
                "<?xml version=\"1.0\"?><test foo=\"bar\"/>",
                handler.toString());
    }
View Full Code Here

        attributes = new AttributesImpl();
        attributes.addAttribute("", "foo", "foo", "CDATA", "A");
        attributes.addAttribute("", "bar", "bar", "CDATA", "B");
        handler.startElement("", "test", "test", attributes);
        handler.endElement("", "test", "test");
        handler.endDocument();
        assertEquals(
                "<?xml version=\"1.0\"?><test foo=\"A\" bar=\"B\"/>",
                handler.toString());

        handler = new ToXmlContentHandler();
View Full Code Here

        attributes = new AttributesImpl();
        attributes.addAttribute("", "bar", "bar", "CDATA", "B");
        attributes.addAttribute("", "foo", "foo", "CDATA", "A");
        handler.startElement("", "test", "test", attributes);
        handler.endElement("", "test", "test");
        handler.endDocument();
        assertEquals(
                "<?xml version=\"1.0\"?><test bar=\"B\" foo=\"A\"/>",
                handler.toString());
    }
View Full Code Here

        handler.startElement("", "foo", "foo", new AttributesImpl());
        handler.endElement("", "foo", "foo");
        handler.startElement("", "bar", "bar", new AttributesImpl());
        handler.endElement("", "bar", "bar");
        handler.endElement("", "test", "test");
        handler.endDocument();
        assertEquals(
                "<?xml version=\"1.0\"?><test><foo/><bar/></test>",
                handler.toString());
    }
View Full Code Here

        ContentHandler handler = new ToXmlContentHandler();
        handler.startDocument();
        handler.startElement("", "test", "test", new AttributesImpl());
        handler.characters("foo".toCharArray(), 0, 3);
        handler.endElement("", "test", "test");
        handler.endDocument();
        assertEquals(
                "<?xml version=\"1.0\"?><test>foo</test>",
                handler.toString());
    }
View Full Code Here

        handler.ignorableWhitespace("\n".toCharArray(), 0, 1);
        handler.startElement("", "test", "test", new AttributesImpl());
        handler.ignorableWhitespace("\n".toCharArray(), 0, 1);
        handler.endElement("", "test", "test");
        handler.ignorableWhitespace("\n".toCharArray(), 0, 1);
        handler.endDocument();
        assertEquals(
                "<?xml version=\"1.0\"?>\n<test>\n</test>\n",
                handler.toString());
    }
View Full Code Here

        handler.startDocument();
        handler.processingInstruction("foo", "abc=\"xyz\"");
        handler.startElement("", "test", "test", new AttributesImpl());
        handler.processingInstruction("bar", null);
        handler.endElement("", "test", "test");
        handler.endDocument();
        assertEquals(
                "<?xml version=\"1.0\"?>"
                + "<?foo abc=\"xyz\"?><test><?bar?></test>",
                handler.toString());
    }
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.