You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by Charlie Wu <da...@pacbell.net> on 2001/03/10 02:16:23 UTC

is there a way to exclude xml headers of the transform result?

hi there:

i can now have a complete xml files to anotehr xml file using xslt (with
xalan)

i'm wondering if i can supress the output xml file's headers?

i.e. from: <a>val</a> (or <?xml version="1.0"?><a>val</a>)

	to: <b>val</b> (not <?xml version="1.0"?><b>val</b>)

Thanks!

Charlie


RE: is there a way to exclude xml headers of the transform result?

Posted by Charlie Wu <da...@pacbell.net>.
btw.. the code i'm using is basically taken from SimpleTransform.java

thanks!

Charlie

    public static String transform(String xmlString, String xslFile)
    {

        TransformerFactory transformerFactory =
TransformerFactory.newInstance();
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        try {
            // System.out.println("Current dir is
"+System.getProperty("user.dir"));
            Templates stylesheet = transformerFactory.newTemplates(
                new StreamSource( new FileInputStream( xslFile ) ) );
            Transformer processor = stylesheet.newTransformer();
            StreamSource source = new StreamSource( new
StringBufferInputStream( xmlString ) );
            StreamResult result = new StreamResult( baos );
            processor.transform( source, result );
        } catch (FileNotFoundException e) {
            e.printStackTrace();
            System.exit(-1);
        } catch (TransformerConfigurationException e) {
            e.printStackTrace();
            System.exit(-1);
        } catch (TransformerException e) {
            e.printStackTrace();
            System.exit(-1);
        }
	return baos.toString();
    }

> -----Original Message-----
> From: Charlie Wu [mailto:daydayup@pacbell.net]
> Sent: Friday, March 09, 2001 5:16 PM
> To: Xalan-Dev@Xml. Apache. Org
> Subject: is there a way to exclude xml headers of the transform result?
>
>
> hi there:
>
> i can now have a complete xml files to anotehr xml file using xslt (with
> xalan)
>
> i'm wondering if i can supress the output xml file's headers?
>
> i.e. from: <a>val</a> (or <?xml version="1.0"?><a>val</a>)
>
> 	to: <b>val</b> (not <?xml version="1.0"?><b>val</b>)
>
> Thanks!
>
> Charlie
>