The SAX parser will invoke this method only once, before any other event callbacks (except for {@link #setDocumentLocator setDocumentLocator}).
299300301302303304305306307308309
String uri = "http://www.jcp.org/jcr/sv/1.0"; String prefix = "sv:"; ContentHandler ch = parent.getSession().getImportContentHandler(parent.getPath(), ImportUUIDBehavior.IMPORT_UUID_COLLISION_THROW); try { ch.startDocument(); String nN = "node"; AttributesImpl attrs = new AttributesImpl(); attrs.addAttribute(uri, "name", prefix + "name", "CDATA", nodeName); ch.startElement(uri, nN, prefix + nN, attrs);
300301302303304305306307308309310
&& foNode instanceof ObjectBuiltListener) { ((ObjectSource) subHandler).setObjectBuiltListener( (ObjectBuiltListener) foNode); } subHandler.startDocument(); subHandler.startElement(namespaceURI, localName, rawName, attlist); depth = 1; delegate = subHandler; }
5758596061626364656667
String svuri = Name.NS_SV_URI; String svprefix = Name.NS_SV_PREFIX + ":"; ContentHandler ch = superuser.getImportContentHandler(testRootNode.getPath(), ImportUUIDBehavior.IMPORT_UUID_CREATE_NEW); ch.startDocument(); ch.startPrefixMapping(prefix, uri); String nN = "node"; AttributesImpl attrs = new AttributesImpl(); attrs.addAttribute(svuri, "name", svprefix + "name", "CDATA", nodeName1);
2829303132333435363738
public void testSerializingContentHandler() throws Exception { StringWriter writer = new StringWriter(); ContentHandler handler = SerializingContentHandler.getSerializer(writer); handler.startDocument(); handler.startPrefixMapping("p", "uri"); handler.startElement("uri", "a", "p:a", new AttributesImpl()); AttributesImpl attributes = new AttributesImpl(); attributes.addAttribute("uri", "foo", "p:foo", "CDATA", "bar"); handler.startElement(null, "b", "b", attributes);
6970717273747576777879
public void testNoPrefixMappingCalls() throws Exception { StringWriter writer = new StringWriter(); ContentHandler handler = SerializingContentHandler.getSerializer(writer); handler.startDocument(); handler.startElement("uri", "a", "p:a", new AttributesImpl()); AttributesImpl attributes = new AttributesImpl(); attributes.addAttribute("uri", "foo", "p:foo", "CDATA", "bar"); handler.startElement(null, "b", "b", attributes); handler.characters("abc".toCharArray(), 0, 3);
2526272829303132333435
public class XmlnsContentHandlerTest extends TestCase { public void testXmlns() throws SAXException { ContentHandler handler = new XmlnsContentHandler(new ToXmlContentHandler()); handler.startDocument(); handler.startPrefixMapping("foo", "http://x.y.z/"); handler.startPrefixMapping("bar", "http://a.b.c/"); handler.startElement("", "test", "test", new AttributesImpl()); handler.startPrefixMapping("foo", "http://a.b.c/"); handler.startElement("", "tset", "tset", new AttributesImpl());
186187188189190191192193194195196
try{ 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());
2425262728293031323334
public class ToXmlContentHandlerTest extends TestCase { 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()); }
3334353637383940414243
assertEquals("<?xml version=\"1.0\"?><test/>", handler.toString()); } public void testAttribute() throws SAXException { ContentHandler handler = new ToXmlContentHandler(); handler.startDocument(); AttributesImpl attributes = new AttributesImpl(); attributes.addAttribute("", "foo", "foo", "CDATA", "bar"); handler.startElement("", "test", "test", attributes); handler.endElement("", "test", "test"); handler.endDocument();
4950515253545556575859
public void testAttributeOrder() throws SAXException { ContentHandler handler; AttributesImpl attributes; handler = new ToXmlContentHandler(); handler.startDocument(); attributes = new AttributesImpl(); attributes.addAttribute("", "foo", "foo", "CDATA", "A"); attributes.addAttribute("", "bar", "bar", "CDATA", "B"); handler.startElement("", "test", "test", attributes); handler.endElement("", "test", "test");