View Single Post
  #3 (permalink)  
Old September 26th, 2012, 02:38 PM
WilliamYou WilliamYou is offline
Authorized User
Points: 141, Level: 2
Points: 141, Level: 2 Points: 141, Level: 2 Points: 141, Level: 2
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2012
Posts: 35
Thanks: 18
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by mhkay View Post
Well, it rather depends whether your XMLFilter is placed before or after the XSLT transformer in the processing pipeline. From the sound of it, your filter appears before the transformer in the pipeline but you are expecting it to appear after. (The JAXP API for setting up pipelines is very confusing, so this is probably an easier mistake to make than you might think.)
Good, that will make a change for me.
Quote:
Originally Posted by mhkay View Post
However, the usual rules apply: we can't find the bugs in your code if you don't show us your code.
Thanks for your reply, I've included the code so maybe this will shed some light on the matter at hand.
Code:
try
{
	StreamSource source = new StreamSource(input) ;
	File outputFile = new File(output) ;
	TransformerFactory factory = TransformerFactory.newInstance() ;
	Source styleSource = factory.getAssociatedStylesheet(source, null, format, null) ;
	BinaryTokeniser binaryTokeniser = new BinaryTokeniser() ;
	StreamSource style = binaryTokeniser.getResource("Transformers" + styleSource.getSystemId().substring(styleSource.getSystemId().lastIndexOf('/')))  ;
	binaryTokeniser.Close();
	SAXParserFactory parserFactory = SAXParserFactory.newInstance() ;
	parserFactory.setNamespaceAware(true) ;
	XMLReader reader = parserFactory.newSAXParser().getXMLReader() ;
	SAXTransformerFactory saxFactory = (SAXTransformerFactory) factory ;
	XMLFilterImpl pipeline = null ;
	XMLFilter filter = saxFactory.newXMLFilter(style) ;
	if (getType().equals("XYPlot"))
	{
		pipeline = new XYPipelineFilter(list, section, chart) ;
		((XYPipelineFilter)pipeline).setDateRange(fromDate, toDate) ;
		((XYPipelineFilter)pipeline).setTooltips(getTooltips()) ;
	}
	else
	{
		pipeline = new PNGPipelineFilter(list, section, chart) ;
		((PNGPipelineFilter)pipeline).setDateRange(fromDate, toDate) ;
	}
	pipeline.setParent(reader) ;
	filter.setParent(pipeline) ;
	TransformerHandler serialiser = saxFactory.newTransformerHandler() ;
	serialiser.setResult(new StreamResult(outputFile)) ;
	Transformer t = serialiser.getTransformer() ;
	t.setOutputProperty(OutputKeys.METHOD, "xml") ;
	t.setOutputProperty(OutputKeys.INDENT, "yes") ;
	t.setParameter("selector", list) ;
	pipeline.setContentHandler(serialiser) ;
	pipeline.parse(source.getSystemId()) ;
	outputFile.delete() ;
}
catch (SAXException | TransformerConfigurationException | ParserConfigurationException | IOException e)
{
	e.printStackTrace();
}
--
William
Reply With Quote