public void testDom4JCData() throws SAXException { StringWriter writer = new StringWriter(); OutputFormat format = new OutputFormat(); final XMLWriter xmlWriter = new XMLWriter(writer, format); xmlWriter.setEscapeText(false); XMLOutput output = new XMLOutput(xmlWriter, xmlWriter); String decl = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; String golden = "<!DOCTYPE foo [\n"; golden += " <!ELEMENT foo (#PCDATA)>\n"; golden += "]><foo></foo>"; output.startDocument(); output.write(golden); output.endDocument(); System.err.println("output was: '" + writer.toString() +"'"); System.err.println("golden is : '" + golden +"'"); assertEquals("output should contain the CDATA section", decl + golden, writer.toString()); }
/** * Writes the body fo this tag to the given Writer */ protected void writeBody(Writer writer) throws SAXException, JellyTagException { XMLOutput newOutput = createXMLOutput(writer); try { // we need to avoid multiple start/end document events newOutput.setContentHandler( new SafeContentHandler(newOutput.getContentHandler()) ); newOutput.startDocument(); invokeBody(newOutput); newOutput.endDocument(); } finally { try { newOutput.close(); } catch (IOException e) {} } }
/** * Writes the body fo this tag to the given Writer */ protected void writeBody(Writer writer) throws SAXException, JellyTagException { XMLOutput newOutput = createXMLOutput(writer); try { // we need to avoid multiple start/end document events newOutput.setContentHandler( new SafeContentHandler(newOutput.getContentHandler()) ); newOutput.startDocument(); invokeBody(newOutput); newOutput.endDocument(); } finally { try { newOutput.close(); } catch (IOException e) {} } }
/** * Writes the body fo this tag to the given Writer */ protected void writeBody(Writer writer) throws SAXException, JellyTagException { XMLOutput newOutput = createXMLOutput(writer); try { // we need to avoid multiple start/end document events newOutput.setContentHandler( new SafeContentHandler(newOutput.getContentHandler()) ); newOutput.startDocument(); invokeBody(newOutput); newOutput.endDocument(); } finally { try { newOutput.close(); } catch (IOException e) {} } }
/** * Writes the body fo this tag to the given Writer */ protected void writeBody(Writer writer) throws SAXException, JellyTagException { XMLOutput newOutput = createXMLOutput(writer); try { // we need to avoid multiple start/end document events newOutput.setContentHandler( new SafeContentHandler(newOutput.getContentHandler()) ); newOutput.startDocument(); invokeBody(newOutput); newOutput.endDocument(); } finally { try { newOutput.close(); } catch (IOException e) {} } }
public void testDom4Xmlns() throws SAXException { StringWriter writer = new StringWriter(); OutputFormat format = new OutputFormat(); final XMLWriter xmlWriter = new HTMLWriter(writer, format); xmlWriter.setEscapeText(false); XMLOutput output = new XMLOutput(xmlWriter, xmlWriter); String golden = "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">\n"; golden += "<html>"; output.startDocument(); output.write(golden); output.endDocument(); assertEquals("output should contain the namespaces", golden, writer.toString()); }