Package com.skaringa.javaxml

Examples of com.skaringa.javaxml.ObjectTransformer.serialize()


      // Use western european encoding in the XML output.
      //trans.setProperty(javax.xml.transform.OutputKeys.ENCODING, "ISO-8859-1");

      // Serialize the Person object into a file.
      FileOutputStream out = new FileOutputStream("fred.xml");
      trans.serialize(fred, new StreamResult(out));
      out.close();

      // Create an XML schema file that describes the Person class.
      out = new FileOutputStream("Person.xsd");
      trans.writeXMLSchema(Person.class, new StreamResult(out));
View Full Code Here


      // Serialize the Person object into a file.
      // Omit all xsi:type, xsi:nil and id attributes.
      // This will shorten the output and make it more "human readable",
      // but this may not work correctly for all kinds of objects.
      out = new FileOutputStream("fred_short.xml");
      trans.serialize(fred, new StreamResult(out));
      out.close();
      // ... and deserialize it again
      // Note that the transformer used for deserialization also needs
      // the property OMIT_XSI_TYPE
      in = new FileInputStream("fred_short.xml");
View Full Code Here

          .newDocumentBuilder();
      org.w3c.dom.Document doc = docBuilder.newDocument();

      ObjectTransformer trans =
        ObjectTransformerFactory.getInstance().getImplementation();
      trans.serialize(people, new javax.xml.transform.dom.DOMResult(doc));

      // Use XPath to find the collection element
      // of the person whose last name is ...
      String xPathQuery = "//cel[lastName='Feuerstein']";
      org.w3c.dom.Node ffNode = null;
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.