Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

difference between JavaScript and XML

 
Simon Xu
Ranch Hand
Posts: 235
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
I am new to XML. The format is similar to JavaScript embodded in HTML. What is the difference? Please clarify.
Simon
 
Roseanne Zhang
Ranch Hand
Posts: 1953
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm new to XML too, but probably know a little better than you.
A suggestion: go to W3Schools for XML and JavaScript both will answer your question here. I just went through the XML, XSL schools during the new year break.
Happy learning!
Roseanne
 
Ajith Kallambella
Sheriff
Posts: 5782
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here are some differences

  • XML is often used to represent "raw" data. JavaScript on the otherhand, is a part of content-rendering language more specifically designed for presentation of the data.
  • JavaScript is "heavy" because of inline Javacode. Content rendering involves compilation cycles. XML on the otherhand is "light" because it defines just the data, is language independent and doesnt require compilation( validation, XSP in XSL are exceptions )
  • JavaScript can only use "allowed" keywords on the otherhand in XML you can define your own tags which makes it more flexible than JavaScript.

  • Bottomline, these two are orthogonal technologies. They are meant for different purposes and are not mutually exclusive. Though JavaScript can be used to make XML presentation more efficient( XSL, HTML and javaScript can be used together, ) there are alternate and more efficient ways to achieve the same flexibility. Take a look at XSP and you'll know what I am talking about.
    Ajith

    [This message has been edited by Ajith Kallambella (edited January 03, 2001).]
 
Roseanne Zhang
Ranch Hand
Posts: 1953
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ajith
XSL, HTML and javaScript can be used together

Can you give a very simple example on it. I am looking for it actually. When I transfer my table data to an XML island, I lost some features of the original presentation, and do not how to get it back.
Another point: to my understanding, Java is portable code, and XML is portable data, not metadata. Meta data is data decribe the (real) data, such as attribute of XML tags. Correct me if I'm wrong.
Thanks!
Roseanne
[This message has been edited by Roseanne Zhang (edited January 03, 2001).]
 
Ajith Kallambella
Sheriff
Posts: 5782
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, you are right about the metadata part. I stand corrected. Infact I think it is right to refer to both DTD or the XML Schema as the metadata for the data in XML.
XSL can act as a container for embeded HTML tags( but they should confirm to the well-formed XML rules ) and inline JavaScript. For examples, you may want to consult some good XML/XSL book. I read a little bit about it in the "Java and XML" book by O'Reilly. If you have the book, you may get some examples of it but it focuses mainly on usage of XML in Java appliations.
Thanks!
Ajith
 
Simon Xu
Ranch Hand
Posts: 235
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, Ajith & Roseanne,
Thanks for your useful link and clear expl.
I will go deeper from here,
Simon
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic