private void toFile(XMLizable desc, File destination) throws SAXException, FileNotFoundException { destination.getParentFile().mkdirs(); OutputStream out = new FileOutputStream(destination); XMLSerializer sax = new XMLSerializer(out); ContentHandler ch = sax.getContentHandler(); ch.startDocument(); desc.toXML(ch); ch.endDocument(); }
private void callBuildFromXMLElement(Element aElement, XMLizable object, ParsingOptions aOptions) throws InvalidXMLException { if (aOptions.preserveComments && (object instanceof MetaDataObject_impl)) { ((MetaDataObject_impl)object).setInfoset(aElement); } object.buildFromXMLElement(aElement, this, aOptions); }
/** * Converts a given <code>XMLizable</code> object to String. This method is useful for * debugging. * * @param content * The given <code>XMLizable</code> object * @return A String that represents the given <code>XMLizable</code> object. */ static String toXmlString(XMLizable content) { StringWriter sWriter = new StringWriter(); PrintWriter oWriter = null; try { oWriter = new PrintWriter(sWriter); content.toXML(oWriter); oWriter.flush(); } catch (Exception exc) { } finally { if (oWriter != null) { try { oWriter.close(); } catch (Exception e) { } } } return sWriter.toString(); } }
/** * Serialize an element named name, with the indicated attributes and value. * * @param name * is the element name * @param attributes * are the attributes...serializer is free to add more. * @param value * is the value * @param context * is the SerializationContext */ public void serialize(QName name, Attributes attributes, Object value, SerializationContext context) throws IOException { if (value instanceof XMLizable) { try { // System.out.println("AxisResourceServiceSerializer::serialize(" + name + ")"); context.startElement(name, attributes); SerializerContentHandler contentHandler = new SerializerContentHandler(context); ((XMLizable) value).toXML(contentHandler); context.endElement(); } catch (SAXException e) { throw new IOException("SAXException: " + e.getMessage()); } } else { throw new IOException("Can't serialize a " + value.getClass().getName() + " with an XmlSerializer."); } }
/** * Serialize an element named name, with the indicated attributes and value. * * @param name * is the element name * @param attributes * are the attributes...serializer is free to add more. * @param value * is the value * @param context * is the SerializationContext */ public void serialize(QName name, Attributes attributes, Object value, SerializationContext context) throws IOException { if (value instanceof XMLizable) { try { // System.out.println("AxisResourceServiceSerializer::serialize(" + name + ")"); context.startElement(name, attributes); SerializerContentHandler contentHandler = new SerializerContentHandler(context); ((XMLizable) value).toXML(contentHandler); context.endElement(); } catch (SAXException e) { throw new IOException("SAXException: " + e.getMessage()); } } else { throw new IOException("Can't serialize a " + value.getClass().getName() + " with an XmlSerializer."); } }
jch.withoutNl(); object.toXML(jch);
aed.toXML(contentHandler, true, true); } else trueDescriptor.toXML(contentHandler, true); contentHandler.endDocument(); writer.close();
((XMLizable) val).toXML(sc.ch);