Package org.apache.xml.serialize

Examples of org.apache.xml.serialize.OutputFormat


        mapping.loadMapping(webXmlMapping);
        InputStream webXml = getClass().getResourceAsStream("web.xml");
        Unmarshaller unmarshaller = new Unmarshaller(mapping);
        WebAppDD config = (WebAppDD)unmarshaller.unmarshal(new InputStreamReader(webXml));

           OutputFormat of = new OutputFormat();
            of.setIndenting(true);
            of.setIndent(4); // 2-space indention
            of.setLineWidth(16384);
            // As large as needed to prevent linebreaks in text nodes
            of.setDoctype(
                 "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN",
                 "http://java.sun.com/dtd/web-app_2_3.dtd");

            FileWriter writer = new FileWriter("newWeb.xml");
            XMLSerializer serializer = new XMLSerializer(writer, of);
View Full Code Here


     * Write the object graph to it's descriptor.
     * @param object
     * @throws IOException
     */
    protected void writeInternal(Object object) throws IOException {
        OutputFormat of = new OutputFormat();
        of.setIndenting(true);
        of.setIndent(2);
        of.setLineWidth(600);
        of.setDoctype(getPublicId(), getDTDUri());

        OutputStreamWriter writer =
            new OutputStreamWriter(getOutputStream());
        XMLSerializer serializer = new XMLSerializer(writer, of);

View Full Code Here

            if (debug) {
                System.out.println(webApp);
            }

            OutputFormat of = new OutputFormat();
            of.setIndenting(true);
            of.setIndent(4); // 2-space indention
            of.setLineWidth(16384);
            // As large as needed to prevent linebreaks in text nodes
            of.setDoctype(
                Constants.WEB_PORTLET_PUBLIC_ID,
                Constants.WEB_PORTLET_DTD);

            FileWriter writer =
                new FileWriter(webAppsDir + webModule +
View Full Code Here

            XMLStreamWriter writer = outputFactory.createXMLStreamWriter(bos);
            staxProcessor.write(workspace, writer);
           
            // Parse again to pretty format the document
            Document document = documentBuilder.parse(new ByteArrayInputStream(bos.toByteArray()));
            OutputFormat format = new OutputFormat();
            format.setIndenting(true);
            format.setIndent(2);
           
            // Write to workspace.xml
            FileOutputStream os = new FileOutputStream(new File(workspaceFile));
            XMLSerializer serializer = new XMLSerializer(os, format);
            serializer.serialize(document);
View Full Code Here

            XMLStreamWriter writer = outputFactory.createXMLStreamWriter(bos);
            compositeProcessor.write(compositeCollection, writer);
           
            // Parse again to pretty format the document
            Document document = documentBuilder.parse(new ByteArrayInputStream(bos.toByteArray()));
            OutputFormat format = new OutputFormat();
            format.setIndenting(true);
            format.setIndent(2);
           
            // Write to domain.composite
            FileOutputStream os = new FileOutputStream(new File(compositeFile));
            XMLSerializer serializer = new XMLSerializer(os, format);
            serializer.serialize(document);
View Full Code Here

            generateXML();
            log(xmlSchema);
            xmlSerializer = new XMLSerializer(
                    new PrintWriter(
                    new FileOutputStream(xmlSchema)),
                    new OutputFormat(Method.XML, null, true));
            xmlSerializer.serialize(doc);
        }
        catch (Exception e)
        {
            throw new BuildException(e);
View Full Code Here

        {
            generateXML();
            xmlSerializer = new XMLSerializer(
                new PrintWriter(
                new FileOutputStream(xmlSchema)),
                new OutputFormat(Method.XML,null,true));
            xmlSerializer.serialize(doc);
        }
        catch (Exception e)
        {
            System.err.println(e);
View Full Code Here

            OutputStream out = outputContext.getOutputStream();
            if (out != null && exists()) {
                if (isMultiple()) {
                    Document doc = DomUtil.BUILDER_FACTORY.newDocumentBuilder().newDocument();
                    doc.appendChild(getProperty(JCR_VALUES).toXml(doc));
                    OutputFormat format = new OutputFormat("xml", "UTF-8", false);
                    XMLSerializer serializer = new XMLSerializer(out, format);
                    serializer.setNamespaces(true);
                    serializer.asDOMSerializer().serialize(doc);
                } else {
                    in = ((Property)item).getStream();
View Full Code Here

            ByteArrayOutputStream out = new ByteArrayOutputStream();
            try {
                Document doc = DomUtil.BUILDER_FACTORY.newDocumentBuilder().newDocument();
                doc.appendChild(serializable.toXml(doc));
               
                OutputFormat format = new OutputFormat("xml", "UTF-8", false);
                XMLSerializer serializer = new XMLSerializer(out, format);
                serializer.setNamespaces(true);
                serializer.asDOMSerializer().serialize(doc);

                byte[] bytes = out.toByteArray();
View Full Code Here

        }
    }

    private void writeDocument(Document document, OutputStream out) throws IOException
    {
        XMLSerializer serializer = new XMLSerializer(out, new OutputFormat(document, null, true));
        serializer.serialize(document);
    }
View Full Code Here

TOP

Related Classes of org.apache.xml.serialize.OutputFormat

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.