ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Al Le" <Al...@gmx.de>
Subject Aw: Re: XSL transformation with Ant: sorting a list
Date Mon, 07 Mar 2016 12:56:55 GMT
Hello Scot,

thanks for a quick response!

> first you are killing yourself in the way you XSLT is 
> written
> [. . .]
> You are trying to do the work of the templating engine in your XSLT :)

Yes, I know this is a "procedural" way of doing things and maybe not the best. But the example
is just an example. The real script is much bigger and more complicated. I just tried to give
a simple case to reproduce the problem.

Do you also think that it should work (despite the fact that it's may be not the best way
to do it)?

The java program I used to verify the transformation is:

package my.test;

import java.io.File;
import java.io.StringWriter;

import javax.xml.transform.Result;
import javax.xml.transform.Source;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;

public class Transform {

	public static void main(String[] args) throws Exception {
		String inputFileName = "Q:\\MiscThings\\t\\a.xml";
		String xslFileName = "Q:\\MiscThings\\t\\trans.xsl";

		Source xmlSource = new StreamSource(new File(inputFileName));
		Source xslSource = new StreamSource(new File(xslFileName));

		StringWriter stringWriter = new StringWriter();
		Result transformationResult = new StreamResult(stringWriter);

		TransformerFactory transformerFactory = TransformerFactory.newInstance();
		Transformer transformer = transformerFactory.newTransformer(xslSource);
		transformer.transform(xmlSource, transformationResult);

		stringWriter.flush();
		String xmlResult = stringWriter.toString();

		System.out.println(xmlResult);
	}

}

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message