Package org.wso2.carbon.utils.xml

Examples of org.wso2.carbon.utils.xml.XMLPrettyPrinter.xmlFormat()


            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


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

    public static OMElement parseAnonSequenceToOM(SequenceMediator seqMediator) {
        OMElement elem = seqMediator.serialize(null);
        elem.removeAttribute(elem.getAttribute(new QName("name")));
View Full Code Here

                                                             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();
    }
    public static String parseAnonSequenceToPrettyfiedString(SequenceMediator seqMediator) {
        OMElement elem = parseAnonSequenceToOM(seqMediator);
        ByteArrayInputStream stream = new ByteArrayInputStream(elem.toString().getBytes());
        XMLPrettyPrinter printer = new XMLPrettyPrinter(stream);
View Full Code Here

    }
    public static String parseAnonSequenceToPrettyfiedString(SequenceMediator seqMediator) {
        OMElement elem = parseAnonSequenceToOM(seqMediator);
        ByteArrayInputStream stream = new ByteArrayInputStream(elem.toString().getBytes());
        XMLPrettyPrinter printer = new XMLPrettyPrinter(stream);
        return printer.xmlFormat();
    }

   public static Mediator getMediatorAt(AbstractListMediator sequence, String position) {
        int index;
        if (position != null && sequence != null) {
View Full Code Here

        OMElement ele = mediator.serialize(null);
        if (ele != null) {
            ByteArrayInputStream byteArrayInputStream
                = new ByteArrayInputStream(ele.toString().getBytes());
            XMLPrettyPrinter printer = new XMLPrettyPrinter(byteArrayInputStream);
            return printer.xmlFormat();
        }
        return null;
    }

    public static boolean isRedirected(HttpServletRequest request) {
View Full Code Here

                    OMElement paramEle = new StAXOMBuilder(xmlSR).getDocumentElement();
                    String paramName = paramEle.getAttribute(new QName("name")).getAttributeValue();
                    InputStream xmlIn = new ByteArrayInputStream(operationParameter.getBytes());
                    XMLPrettyPrinter xmlPrettyPrinter = new XMLPrettyPrinter(xmlIn, null);
                    Parameter parameter = new Parameter(paramName,
                                                        xmlPrettyPrinter.xmlFormat());
                    boolean isLocked = false;
                    OMAttribute lockedAttrib = paramEle.getAttribute(new QName("locked"));
                    if (lockedAttrib != null) {
                        isLocked = "true".equals(lockedAttrib.getAttributeValue());
                    }
View Full Code Here

    public static String prettyPrint(String rawXML) {
        rawXML = rawXML.replaceAll("\n|\\r|\\f|\\t", "");
        rawXML = rawXML.replaceAll("> +<", "><");
        InputStream xmlIn = new ByteArrayInputStream(rawXML.getBytes());
        XMLPrettyPrinter xmlPrettyPrinter = new XMLPrettyPrinter(xmlIn);
        rawXML = xmlPrettyPrinter.xmlFormat();
//        rawXML = rawXML.replaceAll("\n", "<br>");

        return rawXML;
    }
View Full Code Here

   * Prettify a given XML string
   */
  public static String prettifyXML(String xmlContent) {
    ByteArrayInputStream byteIn = new ByteArrayInputStream(xmlContent.getBytes());
    XMLPrettyPrinter prettyPrinter = new XMLPrettyPrinter(byteIn);
    return prettyPrinter.xmlFormat().trim();
  }
 
  /**
   * Prettify a given XML file
   */ 
 
View Full Code Here

  /**
   * Prettify a given XML file
   */ 
  public static void prettifyXMLFile(String filePath) throws IOException {
    XMLPrettyPrinter prettyPrinter = new XMLPrettyPrinter(new FileInputStream(filePath));
    String prettyXML = prettyPrinter.xmlFormat().trim();
    if (prettyXML != null && prettyXML.trim().length() > 0) {
        FileUtils.writeStringToFile(new File(filePath), prettyXML);
    }
  }
 
View Full Code Here

                    XMLOutputFactory.newInstance().createXMLStreamWriter(outBuffer);
            policy.serialize(writer);
            writer.flush();
            ByteArrayInputStream bais = new ByteArrayInputStream(outBuffer.toByteArray());
            XMLPrettyPrinter xmlPrettyPrinter = new XMLPrettyPrinter(bais);
            return xmlPrettyPrinter.xmlFormat();

        } catch (XMLStreamException e) {
            throw new RuntimeException("Serialization of Policy object failed " + e);
        }
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.