SsmlDocument extends XmlDocument { public Speak getSpeak() { NodeList speak = getElementsByTagName(Speak.TAG_NAME); if (speak.getLength() == 0) { speak = getElementsByTagNameNS("*", Speak.TAG_NAME); if (speak.getLength() == 0) { return null; } } return new Speak(speak.item(0)); } SsmlDocument();  SsmlDocument(final InputSource source); @Override XmlNodeFactory<?> getXmlNodefactory(); Speak getSpeak();  }
@Test public void testSerialize() throws Exception { System.setProperty("jvoicexml.xml.encoding", "UTF-8"); final SsmlDocument doc = new SsmlDocument(); final Speak speak = doc.getSpeak(); speak.addText("Hello World!"); final ByteArrayOutputStream out = new ByteArrayOutputStream(); final ObjectOutputStream oout = new ObjectOutputStream(out); oout.writeObject(doc); final ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray()); final ObjectInputStream oin = new ObjectInputStream(in); final Object o = oin.readObject(); Assert.assertEquals(doc.toString(), o.toString()); final String str = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<speak><audio " + "src=\"http: + "</speak>"; final StringReader reader = new StringReader(str); final InputSource source = new InputSource(reader); final SsmlDocument doc2 = new SsmlDocument(source); final ByteArrayOutputStream out2 = new ByteArrayOutputStream(); final ObjectOutputStream oout2 = new ObjectOutputStream(out2); oout2.writeObject(doc2); final ByteArrayInputStream in2 = new ByteArrayInputStream(out2.toByteArray()); final ObjectInputStream oin2 = new ObjectInputStream(in2); final Object o2 = oin2.readObject(); Assert.assertEquals(doc2.toString(), o2.toString()); }