Package org.apache.tuscany.sca.databinding.xml

Examples of org.apache.tuscany.sca.databinding.xml.XMLStreamSerializer


     * @see org.apache.tuscany.sca.databinding.PushTransformer#transform(java.lang.Object, java.lang.Object, org.apache.tuscany.sca.databinding.TransformationContext)
     */
    public void transform(XMLStreamReader source, OutputStream target, TransformationContext context) {
        try {
            StAXDocumentSerializer serializer = new StAXDocumentSerializer(target);
            XMLStreamSerializer streamSerializer = new XMLStreamSerializer();
            streamSerializer.serialize(source, serializer);
            serializer.flush();
            source.close();
        } catch (Exception e) {
            throw new TransformationException(e);
        }
View Full Code Here


    public void testJSON2XML() throws Exception {
        JSON2XMLStreamReader t2 = new JSON2XMLStreamReader();
        XMLStreamReader reader2 = t2.transform(new JSONObject(JSON_STR), null);
        StringWriter sw = new StringWriter();
        XMLStreamWriter streamWriter = XMLOutputFactory.newInstance().createXMLStreamWriter(sw);
        new XMLStreamSerializer().serialize(reader2, streamWriter);
        streamWriter.flush();
        Assert.assertTrue(sw.toString()
            .contains("<xsl:root xmlns:xsl=\"http://foo.com\"><data>my json string</data></xsl:root>"));
    }
View Full Code Here

    public Object transform(XMLStreamReader source, TransformationContext context) {
        try {
            StringWriter writer = new StringWriter();
            XMLStreamWriter jsonWriter = new BadgerFishXMLStreamWriter(writer);
            XMLStreamSerializer serializer = new XMLStreamSerializer();
            serializer.serialize(source, jsonWriter);
            source.close();
            Class type = null;
            if (context != null && context.getTargetDataType() != null) {
                type = context.getTargetDataType().getPhysical();
            }
View Full Code Here

    public Object transform(XMLStreamReader source, TransformationContext context) {
        try {
            StringWriter writer = new StringWriter();
            XMLStreamWriter jsonWriter = new BadgerFishXMLStreamWriter(writer);
            XMLStreamSerializer serializer = new XMLStreamSerializer();
            serializer.serialize(source, jsonWriter);
            source.close();
            Class type = null;
            if (context != null && context.getTargetDataType() != null) {
                type = context.getTargetDataType().getPhysical();
            }
View Full Code Here

     * @see org.apache.tuscany.sca.databinding.PushTransformer#transform(java.lang.Object, java.lang.Object, org.apache.tuscany.sca.databinding.TransformationContext)
     */
    public void transform(XMLStreamReader source, OutputStream target, TransformationContext context) {
        try {
            StAXDocumentSerializer serializer = new StAXDocumentSerializer(target);
            XMLStreamSerializer streamSerializer = new XMLStreamSerializer();
            streamSerializer.serialize(source, serializer);
            serializer.flush();
            source.close();
        } catch (Exception e) {
            throw new TransformationException(e);
        }
View Full Code Here

    public Object transform(XMLStreamReader source, TransformationContext context) {
        try {
            StringWriter writer = new StringWriter();
            XMLStreamWriter jsonWriter = new BadgerFishXMLStreamWriter(writer);
            XMLStreamSerializer serializer = new XMLStreamSerializer();
            serializer.serialize(source, jsonWriter);
            source.close();
            Class type = null;
            if (context != null && context.getTargetDataType() != null) {
                type = context.getTargetDataType().getPhysical();
            }
View Full Code Here

     * @see org.apache.tuscany.sca.databinding.PushTransformer#transform(java.lang.Object, java.lang.Object, org.apache.tuscany.sca.databinding.TransformationContext)
     */
    public void transform(XMLStreamReader source, OutputStream target, TransformationContext context) {
        try {
            StAXDocumentSerializer serializer = new StAXDocumentSerializer(target);
            XMLStreamSerializer streamSerializer = new XMLStreamSerializer();
            streamSerializer.serialize(source, serializer);
            serializer.flush();
            source.close();
        } catch (Exception e) {
            throw new TransformationException(e);
        }
View Full Code Here

    public void testJSON2XML() throws Exception {
        JSON2XMLStreamReader t2 = new JSON2XMLStreamReader();
        XMLStreamReader reader2 = t2.transform(new JSONObject(JSON_STR), null);
        StringWriter sw = new StringWriter();
        XMLStreamWriter streamWriter = XMLOutputFactory.newInstance().createXMLStreamWriter(sw);
        new XMLStreamSerializer().serialize(reader2, streamWriter);
        streamWriter.flush();
        Assert.assertTrue(sw.toString()
            .contains("<xsl:root xmlns:xsl=\"http://foo.com\"><data>my json string</data></xsl:root>"));
    }
View Full Code Here

     * @see org.apache.tuscany.sca.databinding.PushTransformer#transform(java.lang.Object, java.lang.Object, org.apache.tuscany.sca.databinding.TransformationContext)
     */
    public void transform(XMLStreamReader source, OutputStream target, TransformationContext context) {
        try {
            StAXDocumentSerializer serializer = new StAXDocumentSerializer(target);
            XMLStreamSerializer streamSerializer = new XMLStreamSerializer();
            streamSerializer.serialize(source, serializer);
            serializer.flush();
            source.close();
        } catch (Exception e) {
            throw new TransformationException(e);
        }
View Full Code Here

    public Object transform(XMLStreamReader source, TransformationContext context) {
        try {
            StringWriter writer = new StringWriter();
            XMLStreamWriter jsonWriter = new BadgerFishXMLStreamWriter(writer);
            XMLStreamSerializer serializer = new XMLStreamSerializer();
            serializer.serialize(source, jsonWriter);
            source.close();
            Class type = null;
            if (context != null && context.getTargetDataType() != null) {
                type = context.getTargetDataType().getPhysical();
            }
View Full Code Here

TOP

Related Classes of org.apache.tuscany.sca.databinding.xml.XMLStreamSerializer

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.