• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

DOM

 
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can nayone please help me to get out of this confusion.
I have been reading XML / CSS /XSL for some time now. And am clear that when we apply stylesheets to XML document we can get the o/p on any of the media we want ay browser or printout applying appropriate stylesheets.
Noe I read DOM examples which are reading the xml data and displaying it as HTML document. So suddenly I felt hey then why use DOM/SAX api's with scripting languages!!
Now I am feeling confused again.
I understand these examples are just doing this displaying thing
which can very well be done with stylesheets.
But may be for writing to and from database I have to use these APIs.
May be I need to have look at some other examples by which I will clearly understand the use of DOM.
Please help me clarify my confusion.
I know my doubt is stupid :-(
but then where else but such free forum to ask this!!
Thanks
 
Gemini Moses
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I mean where we can express our stupidity....
Else I feel concious to ask some of the doubts..to someone
Here everyone seems to be free and understanding.
 
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
Gemini, your doubt is not stupid at all.
All too often can we do the same things with both DOM/SAX and XSLT. It's not so obvious which technology is preferable: as usual, there are pro and contra for both. Decision depends on 1) what kind of processing we need to apply 3) what are performance requirements 3) which language we are more comfortable with
I think if the task is to present XML document by converting it to HTML or some other format, then it's better to use XSLT. To hardcode presentation information in a program, working with DOM, is also possible, but it's not the best solution. In this case it's much easier to use XSL(T) and we also have advantage of separating data and presentation layers.
If the task is to to transform our XML document, say, to select only specific nodes or re-arrange/sort them, then we again have both options: DOM/SAX or XSLT.
XSLT language was specially designed for XML transformation, and it's often easier to use than Java+DOM+SAX. But in my feeling there are three moments to consider:
1) XSLT doesn't give us as much control on the document as we may want
2) XSLT programs do not scale well. If we can solve our problems with one-page-XSLT, then it's fine. But if we have complicated data and complex processing logic, then our XSLT quickly became unreadable. There are tools for modularity/reuse in XSLT, but in my opinion (which may be wrong!) object-oriented languages fight complexity better.
3) XSLT as a language is different from procedural languages, we used to. It is a functional language and people often find it difficult to understand. For example, we cannot update variables and simple construction I=I+1 doesn't work with XSLT. This article wil give more information.
Regarding performance requirements, XSLT again doesn't give us too much control, we have to rely on XSLT processor optimization mechanism. (Of course, in typical cases XSLT processor may do a better job than an average programmer ) Most of XSLT processors use DOM to represent an XML tree, so they are not very good for really large documents. There is an exception, however, Saxon, which accepts SAX events as an input.
Bottom line: if you have small XML files without complex processing, XSLT is the best choice. If your files are large, or can become large then you may consider �real pogramming� with DOM/SAX or at least, choose your XSLT processor more carefully.
I know that Ajith favours DOM/SAX, so I would wait for his reply
 
Gemini Moses
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Maparaputta,
Thank u very much for giving me clear understanding.
The article u provided also gave me good understanding and helped me to come out of confusion...
Hey does that mean I need to learn javascript to be able to work on xml applications.
I have java certification but everytime I see some code in scipting language I feel lost.
But I think I need to learn scripting language now....
Thanks once again.
 
Mapraputa Is
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
Hey does that mean I need to learn javascript to be able to work on xml applications.
Ha, Gemini, good news is that you do not have to learn JavaScript to be able to work on xml applications JavaScript is used on client side only, it is scripting language interpreted by browser. There are a lot of XML applications which have nothing to do with browsers; databases, for example. You can perfectly work on these application without any JavaScript knowledge. And even if an application does deal with browsers, most of processing still happens on server-side, where Java rules JavaScript plays subsidiary role for small tasks which can be performed on client side to reduce server workload, like checking input data validity before sending them to server or something like this.
JavaScript isn�t very different from Java really, they use very similar syntax. JavaScript, unlike Java, is object-based language, not object-oriented. It employs prototype-based inheritance vs. Java�s class-based inheritance. Unlike Java, it is a weakly typed language. But on algorithmic level there is not a big difference. Gemini, with your Java certification, I do not think you will meet any serious difficulty learning JavaScript. If you need to learn it, there is a good book: �Professional JavaScript� By Nigel McFarlane Wrox Press Ltd. On-line chapters are on: http://webreference.com/programming/javascript/professional/
From theoretical point of view , JavaScript is not a right language to learn either It will not radically change your way of thinking, which is the only valuable thing in a new language XSLT is more promising in this respect. It is a functional language, as opposed to imperative languages such as Java (strickly speaking, OO languages form separate category, but in my feeleng difference between imperative and OO languages is not as big as between functional and imperative or OOP languages). Learning any functional language is useful to obtain another point of view or anothr programming paradigm. I only doubt that XSLT is a good language to start with, since its hierarchical data model is quite complicated. SQL could be a better choice, its data model is clear, well-defined and there is a very nice theory behind it. I would say that for a beginner it�s easier to understand what is good and what is bad with SQL than with XSLT. But all this is only theoretical discourse , practically we should learn what is needed for concrete project or what is in demand on job market.
 
Gemini Moses
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey very nice to learn that I dont need to learn javascript.
Somehow I never liked to read code in it.....

Thanks about taking time to guide me in my skills.
Presently I am planning to take up XML certification.
and as this site helped me for my java certification hangging around a lot out here...
Thanks a lot.
 
Sometimes you feel like a nut. Sometimes you feel like a tiny ad.
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic