RE: [xsl] Filtering XML to improve performance

Subject: RE: [xsl] Filtering XML to improve performance
From: <Jarno.Elovirta@xxxxxxxxx>
Date: Mon, 22 Mar 2004 08:30:25 +0200
Hi,

> Let's say my xml is this:
> 
> <root>
> 	<items>
> 		<onlyImportantItem>THIS</onlyImportantItem>
> 		<junkItem>foo</junkItem>
> 		<moreJunk>foo</moreJunk>
> 		<stillMoreJunk>foo</stillMoreJunk>
> 	</items>
> 	<items>
> 		<onlyImportantItem>THAT</onlyImportantItem>
> 		<junkItem>foo</junkItem>
> 		<moreJunk>foo</moreJunk>
> 		<stillMoreJunk>foo</stillMoreJunk>
> 	</items>
> 	...
> 	...
> 	...
> </root>
> 
> 
> If I only mainly want to work with <onlyImportantItems>, is 
> there a way that
> I can filter out all the other data I don't need when I do 
> the transform?
>
> So for instance, I don't want the XML parser searching through all the
> garbage, I want it cut down to just the data I need.  Can I 
> do something
> like this at the beginning of all my xsl sheets?

XSLT itself will not help you. If you're working with e.g SAX, you can write a class that implements XMLFilter and there filter out all descendant events you don't want in the next processing step. That is, you need to control how the Source Tree is build, or filter the data before it is used to build the Source Tree.

Cheers,

Jarno - T.O.Y.: Beyond Sleep

Current Thread