Examples of XmlPrettyPrinter


Examples of no.priv.garshol.duke.utils.XMLPrettyPrinter

   * Writes the given configuration to the given file.
   */
  public static void write(Configuration config, String file)
    throws IOException {
    FileOutputStream fos = new FileOutputStream(file);
    XMLPrettyPrinter pp = new XMLPrettyPrinter(fos);

    pp.startDocument();
    pp.startElement("duke", null);

    // FIXME: here we should write the objects, but that's not
    // possible with the current API. we don't need that for the
    // genetic algorithm at the moment, but it would be useful.

    pp.startElement("schema", null);

    writeElement(pp, "threshold", "" + config.getThreshold());
    if (config.getMaybeThreshold() != 0.0)
      writeElement(pp, "maybe-threshold", "" + config.getMaybeThreshold());

    for (Property p : config.getProperties())
      writeProperty(pp, p);

    pp.endElement("schema");

    String dbclass = config.getDatabase(false).getClass().getName();
    AttributeListImpl atts = new AttributeListImpl();
    atts.addAttribute("class", "CDATA", dbclass);
    pp.startElement("database", atts);
    pp.endElement("database");

    if (config.isDeduplicationMode())
      for (DataSource src : config.getDataSources())
        writeDataSource(pp, src);
    else {
      pp.startElement("group", null);
      for (DataSource src : config.getDataSources(1))
        writeDataSource(pp, src);
      pp.endElement("group");

      pp.startElement("group", null);
      for (DataSource src : config.getDataSources(2))
        writeDataSource(pp, src);
      pp.endElement("group");
    }

    pp.endElement("duke");
    pp.endDocument();

    fos.close();
  }
View Full Code Here

Examples of org.mule.module.xml.transformer.XmlPrettyPrinter

        }
       
        // Extract the XML payload and format it
        String payload = lines[payloadLine];
        String xml = StringUtils.substringAfter(payload, "Payload: ");
        XmlPrettyPrinter pp = new XmlPrettyPrinter();
        try
        {
            xml = (String) pp.transform(xml);
        }
        catch (MuleException e)
        {
            System.err.println(e.getMessage());
        }
View Full Code Here

Examples of org.mule.module.xml.transformer.XmlPrettyPrinter

        return "org/mule/module/xml/xml-prettyprinter-config.xml";
    }

    public void testPrettyPrinter()
    {
        XmlPrettyPrinter pp = (XmlPrettyPrinter) muleContext.getRegistry().lookupTransformer("MyXMLPrettyPrinter");

        assertNotNull(pp);
        assertEquals("ISO-8859-15", pp.getEncoding());
        assertEquals(true, pp.isExpandEmptyElements());
        assertEquals(true, pp.getIndentEnabled());
        assertEquals("   ", pp.getIndentString());
        assertEquals("\\n\\n", pp.getLineSeparator());
        assertEquals(1, pp.getNewLineAfterNTags());
        assertFalse(pp.isNewlines());
        assertFalse(pp.isNewLineAfterDeclaration());
        assertFalse(pp.isOmitEncoding());
        assertFalse(pp.isPadText());
        assertFalse(pp.isTrimText());
        assertFalse(pp.isSuppressDeclaration());
        assertTrue(pp.isXHTML());
    }
View Full Code Here

Examples of org.mule.module.xml.transformer.XmlPrettyPrinter

        return createObject(XmlPrettyPrinter.class);
    }

    public void testOutputOptions()
    {
        XmlPrettyPrinter t = new XmlPrettyPrinter();
        OutputFormat f = t.getOutputFormat();
        assertEquals(2, f.getIndent().length());
        assertTrue(f.isPadText());

        t.setIndentSize(4);
        t.setPadText(true);
        assertEquals(4, f.getIndent().length());
        assertTrue(f.isPadText());
    }
View Full Code Here

Examples of org.mule.module.xml.transformer.XmlPrettyPrinter

        }
       
        // Extract the XML payload and format it
        String payload = lines[payloadLine];
        String xml = StringUtils.substringAfter(payload, "Payload: ");
        XmlPrettyPrinter pp = new XmlPrettyPrinter();
        try
        {
            xml = (String) pp.transform(xml);
        }
        catch (MuleException e)
        {
            System.err.println(e.getMessage());
        }
View Full Code Here

Examples of org.mule.module.xml.transformer.XmlPrettyPrinter

    }

    @Test
    public void testOutputOptions()
    {
        XmlPrettyPrinter t = new XmlPrettyPrinter();
        OutputFormat f = t.getOutputFormat();
        assertEquals(2, f.getIndent().length());
        assertTrue(f.isPadText());

        t.setIndentSize(4);
        t.setPadText(true);
        assertEquals(4, f.getIndent().length());
        assertTrue(f.isPadText());
    }
View Full Code Here

Examples of org.mule.module.xml.transformer.XmlPrettyPrinter

    }

    @Test
    public void testPrettyPrinter()
    {
        XmlPrettyPrinter pp = (XmlPrettyPrinter) muleContext.getRegistry().lookupTransformer("MyXMLPrettyPrinter");

        assertNotNull(pp);
        assertEquals("ISO-8859-15", pp.getEncoding());
        assertEquals(true, pp.isExpandEmptyElements());
        assertEquals(true, pp.getIndentEnabled());
        assertEquals("   ", pp.getIndentString());
        assertEquals("\\n\\n", pp.getLineSeparator());
        assertEquals(1, pp.getNewLineAfterNTags());
        assertFalse(pp.isNewlines());
        assertFalse(pp.isNewLineAfterDeclaration());
        assertFalse(pp.isOmitEncoding());
        assertFalse(pp.isPadText());
        assertFalse(pp.isTrimText());
        assertFalse(pp.isSuppressDeclaration());
        assertTrue(pp.isXHTML());
    }
View Full Code Here

Examples of org.wso2.carbon.utils.xml.XMLPrettyPrinter

            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            env.serialize(baos);
            InputStream xmlIn = new ByteArrayInputStream(baos.toByteArray());
            String encoding =
                    (String) msgContext.getProperty(Constants.Configuration.CHARACTER_SET_ENCODING);
            XMLPrettyPrinter xmlPrettyPrinter = new XMLPrettyPrinter(xmlIn, encoding);
            xml = xmlPrettyPrinter.xmlFormat();
        } catch (Throwable e) {
            String error = "Error occurred while pretty printing message. " + e.getMessage();
            log.error(error, e);
            xml = error;
        }
View Full Code Here

Examples of org.wso2.carbon.utils.xml.XMLPrettyPrinter

    }

    public static String parseSequenceToPrettyfiedString(SequenceMediator sequence) {
        ByteArrayInputStream byteArrayInputStream
                = new ByteArrayInputStream(parseSequenceToString(sequence).getBytes());
        XMLPrettyPrinter printer = new XMLPrettyPrinter(byteArrayInputStream);
        return printer.xmlFormat();
    }
View Full Code Here

Examples of org.wso2.carbon.utils.xml.XMLPrettyPrinter

    public static String parseAnonSequenceToPrettyfiedString(SequenceMediator seqMediator,
                                                             String targetSeqName) {
        OMElement elem = parseAnonSequenceToOM(seqMediator);
        elem.setLocalName(targetSeqName + "Sequence");
        ByteArrayInputStream stream = new ByteArrayInputStream(elem.toString().getBytes());
        XMLPrettyPrinter printer = new XMLPrettyPrinter(stream);
        return printer.xmlFormat();
    }
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.