• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Xalan and line by line parsing

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I am getting heavily involved in servlet/xalan parsing.
I have the process of sending the data to a file, and also
re-directing back to the browser in HTML. But...
What I din't understand is how to conveniently point to an
xml and xsl file and then read it line by line. Is this possible
with the Xalan API ? Is it DOM I have to look at it?
Any help is appreciated.
Regards Al
 
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am not sure if I understand you correctly. It sounds like you probably want to look at the SAX API, which is generally supported along with DOM by XML parsers like Xerces, etc. Reading an XML file line by line does not make much sense, since whitespace between elements is not technically necessary, even if it makes it easier for a human to read the XML file. The same file could be written in a single line.
DOM parses the complete document into a tree that is stored in memory and which you can subsequently traverse, modify, and even write back. SAX on the other hand uses an event-based parser which allows you to define callbacks (by implementing a certain interface), that get called when a certain element is found in the XML file, e.g. a start tag, an end tag, etc.
I am not sure what you are trying to do with XSL in this context. Using XSL is quite different from parsing an XML file. You need an XSL engine like Xalan that you pass both an XML and an XSL file, and it converts this into the appropriate output resulting from applying the XSL stylesheet to the XML file.
-Mirko

Originally posted by al881:

I am getting heavily involved in servlet/xalan parsing.
I have the process of sending the data to a file, and also
re-directing back to the browser in HTML. But...
What I din't understand is how to conveniently point to an
xml and xsl file and then read it line by line. Is this possible
with the Xalan API ? Is it DOM I have to look at it?
Any help is appreciated.
Regards Al


 
Leverager of our synergies
Posts: 10065
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
how to conveniently point to an xml and xsl file
If what you want to do is to transform your XML document into HTML,
you can use Xalan's command line utility and specify your XML and XSl as:
-IN myXML.xml -XSL myXSL.xsl -OUT myHTML.html
Also, please, take a look at our policy on Proper Names and re-register with a new name which meets the requirements. Thanks for cooperation!
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Well thanks for the replies but I've already done all of the
suggestions.
My point was to use the Xalan API to point to a XML file and
read it's contents line by line and NOT have a SAX call back
or store it in a DOM memory. I thought that the API would
allow this.
I guess what I'm really looking at is this.
My XSL files send data back in HTML form based on a XML. These
2 files are set up in the Xalan parser API and it works just fine.
By I wanted to somehow simulate that my client is a WAP device
and take the parsed data set up by the XSL and then have my
SERVLET modify the contents of the PARSED data and return it as
WAP material and NOT HTML. I suppose I could just copy the XSL
file and change the HTML tags to WAP tags and make the XSL do
this.
Am I on the right path? Do people "just" copy the XSL file and
modify the HTML to other type output devices and then have
thr servlet switch files on the fly?
Any thoughts?
Regards Al
 
reply
    Bookmark Topic Watch Topic
  • New Topic