• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

XML transformation  RSS feed

 
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I need to transform xml to html and display it in an html document. My problem is I can't use XSL, XSLT, or DTDs because of the custom browser I am using. I can use CSS, DOM, Java (the browser is written in Java), and Javascript.I am going to use Xerces to create a DOM tree (using Java) and pass the results to my html client via an applet I have already written and works fine. I will then use Javascript to fill the text fields in the html I need to fill using their ids. Any other suggestions anyone else may have tried along these lines? Is it very easy to use Java to extract element data? It's just getting to the data itself without having the ability to use XSL/XSLT.
Thanks as always,
Joe Crew
 
Leverager of our synergies
Posts: 10065
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Joe, using XSL(T) on client side via browser is not your the only option. Actually, using XSLT on server side is preferable for many reasons. You transform XML files into HTML on server and send them to the browser. In this case all the browser needs to understand is HTML To use XSLT on server you need XSLT processor. There are a lot of them for free. Or, even better, you can use Xalan, which provides much more than just XSLT processor.
I think in your case XSLT on server side would be a good choice, because you can fill in text fields via XSLT, you do not need to use JavaScript for it later.
For example, to fill in the text field with "myField" element content, you write something like:
<xsl:template match = "myField">
...
<input type="text" name="myField" size="80" value="{.}"/>
...
</xsl:template>
- and you have a ready HTML document as an output.
Is it very easy to use Java to extract element data?
If you have experience with Java and DOM, it is not very difficult, but if you do not, than XSLT may be an easier way. It is said that "Writing XSLT is at least an order of magnitude easier than writing DOM-based code." http://www.xmleverywhere.com/newsletters/20000329.htm
On the other hand, people often say that XSLT is too difficult for a typical programmer. I would summarize by saying that for easy task, like "give me this element value" or "give me this element's attribute value" XSLT is much easier than DOM/SAX. But if your processing employes complicated logic or a lot of calculations, then your XSLT program quickly becomes too complicated and ugly. Also, I read that most known XSLT processors use DOM parsers, so all arguments against DOM are valid for XSLT ��� if you have a large document and want to extract only small part of it, then you should check if your XSLT processor is optimized for such use.
 
Joe Crew
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you, I will give this option a try.
Joe Crew
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!