473,509 Members | 2,890 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

XSLT on 2 XML files, after passing one thru a SAX filter

Hello everyone

I have sucessfully implemented a SAX filter to take a large
XML data file, and strip it down to its essential elements,
and then pass that on to an XSL transformer. (A bare bones example
of the java code is listed at the end) I also need another XML file, a
list of all possible records, which I use for getting additional
information by cross referencing with xsl:key.

The list file only has one type of element, and I need to write
some output for each of them. So if I don't filter the data file
and start running the XSLT on the List file, and iterating through
every element, I can get the data from the Data file easily, by
accessing it via document().

But to use the filter, I seem to have to START processing with the Data
file
and then *it* is what gets passed to the transformer. I don't know how
to immediately switch to the list file, iterate through each of its
elements and refer back to the data file as needed...

I guess I could template-match on the root element of the filtered
data file and jump from that over to the list file...?

Anyway, here is the rudiments of how I am doing the SAX filtering,
and passing to the XSLT:
- - - - - - - - - - - - - - - - - - - -- - - - - - -
FileReader r = new FileReader( xmlDataFile );
XMLReader xr =
XMLReaderFactory.createXMLReader("org.apache.xerce s.parsers.SAXParser");
KeepSpecificEltsFilter kFilter = new KeepSpecificEltsFilter( xr,
elementsToKeep );
TransformerFactory tFactory = TransformerFactory.newInstance();
SAXTransformerFactory saxTFactory = ((SAXTransformerFactory) tFactory);
XMLFilter xmlFilter2 = saxTFactory.newXMLFilter( new StreamSource(
xsltFile ) );
xmlFilter2.setParent( kFilter );
java.util.Properties xmlProps =
OutputPropertiesFactory.getDefaultMethodProperties ("xml");
Serializer serializer = SerializerFactory.getSerializer( xmlProps );

xmlFilter2.setContentHandler( serializer.asContentHandler() );
xmlFilter2.parse( new InputSource(xmlDataFile) );
- - - - - - - - - - - - - - - - - - - - - - - - - - - -

I am open to any ideas...
--Jeff

Mar 29 '06 #1
2 1252
I'd suggest: Filter the first, use it as your input document, and have
the stylesheet explicit access the second via paths based on the
document() function. (Or, if you already have the second in memory as a
DOM tree, your XSLT processor *may* let you pass it in as a stylesheet
parameter and treat it as a nodeset -- but that's getting into
non-standardized stuff.)

--
Joe Kesselman / Beware the fury of a patient man. -- John Dryden
Mar 29 '06 #2

Joseph Kesselman wrote:
I'd suggest: Filter the first, use it as your input document, and have
the stylesheet explicit access the second via paths based on the
document() function. (Or, if you already have the second in memory as a
DOM tree, your XSLT processor *may* let you pass it in as a stylesheet
parameter and treat it as a nodeset -- but that's getting into
non-standardized stuff.)

--
Joe Kesselman / Beware the fury of a patient man. -- John Dryden


Thanks, that sounds like a good strategy.
--Jeff

Mar 31 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
2829
by: Harolds | last post by:
The code below worked in VS 2003 & dotnet framework 1.1 but now in VS 2005 the pmID is evaluated to "" instead of what the value is set to: .... xmlItems.Document = pmXML // Add the pmID...
2
1926
by: Peter Gloor | last post by:
What's the difference between the file type extensions .xsl and .xslt? When to use what? So far I always created XSLT files thru the appropriate menues in VS.NET. They automatically become .xslt...
3
302
by: Peter Row | last post by:
Hi, I have 2 XML files and 1 XSLT file. The second XML file has the following declarative 1st line: <?xml version="1.0" encoding="UTF-8" standalone="yes"?> ....the 1st one (the one to be...
4
1504
by: Adrian von Bidder | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Yo! Mostly as a finger-exercise (and because I'm annoyed again and again how bad the existing solutions are), I'm hacking up a web-based forum...
18
2046
by: yinglcs | last post by:
Hi, I have a newbie XSLT question. I have the following xml, and I would like to find out the children of feature element in each 'features' element. i.e. for each <featuresI would like to...
0
1705
by: Umagowder | last post by:
All I have my class serialised correctly. I have to apply style sheet to that data and display it in some other format. Everything works fine,I can not read the following xml tag, ...
3
9538
by: super.raddish | last post by:
Greetings, I am relatively new to, what I would call, advanced XSLT/XPath and I am after some advice from those in the know. I am attempting to figure out a mechanism within XSLT to compare the...
21
34327
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Uploading files from a local computer to a remote web server has many useful purposes, the most...
0
2396
by: SpaceMarine | last post by:
hello, im having a discussion w/ one of my associates, and we're are trying to get a consensus on a possible performance scenario. we're working a/ 3-rd party component that produces PDFs using...
0
7234
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7136
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7412
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
5652
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5060
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4730
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3216
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1570
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
775
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.