Package nu.xom

Examples of nu.xom.Document


    }

    private Source convertResponse(Element responseElement) throws IOException {
        ByteArrayOutputStream os = new ByteArrayOutputStream();
        Serializer serializer = createSerializer(os);
        Document document = responseElement.getDocument();
        if (document == null) {
            document = new Document(responseElement);
        }
        serializer.write(document);
        byte[] bytes = os.toByteArray();
        return new StreamSource(new ByteArrayInputStream(bytes));
    }
View Full Code Here


        public void domSource(Node node) {
            if (node.getNodeType() == Node.ELEMENT_NODE) {
                element = DOMConverter.convert((org.w3c.dom.Element) node);
            }
            else if (node.getNodeType() == Node.DOCUMENT_NODE) {
                Document document = DOMConverter.convert((org.w3c.dom.Document) node);
                element = document.getRootElement();
            }
            else {
                throw new IllegalArgumentException("DOMSource contains neither Document nor Element");
            }
        }
View Full Code Here

        @Override
        public void saxSource(XMLReader reader, InputSource inputSource) throws IOException, SAXException {
            try {
                Builder builder = new Builder(reader);
                Document document;
                if (inputSource.getByteStream() != null) {
                    document = builder.build(inputSource.getByteStream());
                }
                else if (inputSource.getCharacterStream() != null) {
                    document = builder.build(inputSource.getCharacterStream());
                }
                else {
                    throw new IllegalArgumentException(
                            "InputSource in SAXSource contains neither byte stream nor character stream");
                }
                element = document.getRootElement();
            }
            catch (ValidityException ex) {
                throw new XomParsingException(ex);
            }
            catch (ParsingException ex) {
View Full Code Here

            throw new IllegalArgumentException("XMLEventReader not supported");
        }

        @Override
        public void staxSource(XMLStreamReader streamReader) throws XMLStreamException {
            Document document = StaxStreamConverter.convert(streamReader);
            element = document.getRootElement();
        }
View Full Code Here

            DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
            factory.setNamespaceAware(true);
            DocumentBuilder builder = factory.newDocumentBuilder();
            DOMImplementation impl = builder.getDOMImplementation();

            return DOMConverter.convert(new Document(root), impl);
        } catch (ParserConfigurationException e) {
            throw new IllegalStateException(e);
        }
    }
View Full Code Here

@Test
public class JsonXmlConverterTest {
    public void shouldConvertToXml() {
        JsonObject object = sampleJson();
        Element element = JsonXmlConverter.getElement(object, "r");
        Document document = new Document(element);
        String xml = document.toXML();
        Assert.assertTrue(xml.contains("<r>"), "should contain the opening tag <r>");
    }
View Full Code Here

  static void load(InputStream inputStream) {

    Builder builder = new Builder();

    Document doc = null;

    try {
      doc = builder.build(inputStream);
      load(doc);
    } catch (ValidityException e) {
View Full Code Here

      LOGGER.debug("UITolls: FileNotFoundException");
      e1.printStackTrace();
    }
    LOGGER.debug("loading file pointer open.");

    Document doc = null;

    if (input == null)
      LOGGER.debug("UITools: File input is null.");

    try {
View Full Code Here

        root.addAttribute(new Attribute("version", String
            .valueOf(SETTINGS.version)));
       
        root.appendChild(GLOBAL.sketchChairs.getCurChair().toXML());

        Document doc = new Document(root);
        OutputStream outXML = new FileOutputStream(name);
        outXML = new BufferedOutputStream(outXML);
        Serializer serializer = new Serializer(outXML, "ISO-8859-1");
        serializer.write(doc);
View Full Code Here

        Element root = new Element("SketchChairDoc");
        root.addAttribute(new Attribute("version", String
            .valueOf(SETTINGS.version)));
        root.appendChild(GLOBAL.sketchChairs.getCurChair().toXML());

        Document doc = new Document(root);
        //   outXML = ;// new FileOutputStream(name+".xml");

        ByteArrayOutputStream outXML = new ByteArrayOutputStream();
        Serializer serializer = new Serializer(outXML, "ISO-8859-1");
        serializer.write(doc);
View Full Code Here

TOP

Related Classes of nu.xom.Document

Copyright © 2018 www.massapicom. 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.