Material moved from IwannaLearnXml
Doug Merritt speaks XML
In response to "Are You Sure??" asked on the parent page at one stage:
<sentence> <subject> <noun type="pronoun" person="first"/> </subject> <verb> <to_be tense="present" agreement="first_person"/> </verb> <object> <state> <frame_of_mind> <certainty degree="100%"/> </frame_of_mind> </state> </object> </sentence>:-) -- DougMerritt
Uhm, Doug, what about <sentence type="interrogatory" sense="ironic"> ...
Oops! Well, I guess my l33t XML skills need more work!
Uhm, Doug, are you sure 'you' is person="first" and agreement="first_person"?...
Well, I was aiming to say "I am sure." in XML, to answer the question at the top of the page. You can judge from that whether I translated correctly.
'''Why learn Xml (and related technologies) when many tools create/utilize xml files? Is there really a need to hand tailor XML files anymore?'''
???
Need to learn XPATH and /or XSLT?
If you really want to learn XML, well it can be defined in 10 or so pages. See The Essence of XML (http://homepages.inf.ed.ac.uk/wadler/papers/xml-essence/xml-essence.pdf), or even with a more practical flavour SXML specification (http://okmij.org/ftp/papers/SXML-paper.pdf). The rest is mostly unnecessary hype, and in the words of EwDijkstra artificial complexity.
True. But XPATH seems to be considered an important part of XML these days, is that covered too?
I hear there were comments that XPATH itself is not like XML at all (more like LispLanguage?). If that is the case, maybe a proper programming language that has good XML interface is preferred over XPATH?
You're thinking of XSLT.
In any case, both can be easily embedded in Scheme: http://www.okmij.org/ftp/papers/SXs.pdf.
What about the majority of IT shops where they use CobolLanguage on BigIron and VbClassic in clientserver, and are loath to bring in another programming language like Scheme? Do they really need XPATH or XSLT? Can they not go with the CobolLanguage and/or VbClassic. These shops can always wait for a tool that has XPATH / XSLT hidden behind the scenes, if one comes out that is mature (read widely adopted) and fit with the Corporate goals.
[This seems a little confused. XPATH and XSLT are extensions to the XML standard. Despite the power they threw into XSLT, it is not intended to be a general purpose programming language, and thus there should never, never, never be a question of switching from Cobol or VB to XSLT, anymore than you would switch from Cobol to XML, despite the fact that Cobol could be encoded in XML if someone had some reason to.]
[When you said "wait for a tool that has XPATH / XSLT hidden behind the scenes", that is closer (modulo minor details) to what is basically the only possible way to go, not a pronouncement of a wiser way to go.]
[The purpose of XPATH is to address data encoded in XML. The purpose of XSLT is to transform XML input to some fairly arbitrary output format. That's all.]
[The SXML that Costin is referring to is an XML-like syntax based on EssExpressions (see XmlIsaPoorCopyOfEssExpressions,XmlIsaGoodCopyOfEssExpressions) which many feel is better in several regards than the XML standard itself. Although only people already using SchemeLanguage are extremely likely to follow up on that, nonetheless it is conceivable that SXML could even be used with Cobol, should someone care to.]
For Enterprise applications is there really a need to have programmers to develop skills in XPATH and XSLT? Based on the above information I reckon it is not necessary as either CobolLanguage or VbClassic would suffice. The extra bit of development productivity gained may not yet warrant the loss of productivity during maintenance phase. Agree? --DavidLiu
[No, strongly disagree. Perhaps you should make explicit why you say that.]
[The reason to use XML is to exchange hierarchical data with remote systems. Perfect example: I used it at infoseek/go.com to get movie listings from movies.com. It looked a little like this:]
<movie_listings> <movie> <title> Gone With The Wind </title> <showtimes> 1:00 2:00 6:00 7:30 10:00 </showtimes> </movie> </movie_listings>
[XPATH, if we had used it, would have been handy for addressing some subnode of that XML. It's just like pathnames in a directory. So, should VB and Cobol programmers regard it as a big deal to learn directory pathname syntax? Not at all! How about XPATH? Same thing, of course they should learn it, if it's handy for the job at hand. It doesn't matter which coding language you use...this is about a data language.]
[XSLT is a bit controversial, but still, it's just a way of talking about XML such as the above, pattern matching on parts of it, and emitting it in a new format, such as RTF or HTML or something. It's a special-purpose way of specifying data-transformations. Should people learn it if they're doing a lot of XML processing, in any language whatsoever? Arguably, yes. Doing the same processing in Cobol or VB would be far, far more difficult.]
I do agree Xml is useful for Enterprise development. But I do not understand what is the need to learn XPATH for directory stuff, can it not be handled in the host language for xml processing? Maybe better use of programmers time to become better with the application of Xml usage (e.g. attributes vs ?fields) than to pick up the nuances of XPATH. I take a conservative approach become XML is evolving and it is huge. So I tend to think the same way about XPATH.
[First off, these things don't take any particular time to learn. Look at XML...DTDs are something of a nuisance, but XML itself you can learn in a single evening. How complex do you think XPATH is? You're thinking it's something huge, and it's not, and that leads you to a false conclusion.]
[Secondly, XPATH is used from/in conjunction with a host language, just as is XML. You don't switch from Cobol/VB/Jave/C++ to XML; you stay with the host language, and you use some library like DOM/SAX to handle the XML and to do XPATH stuff.]
[Thirdly, XML and everything associated with it is not huge, it's the hype about it that's huge.]
[XPATH is simple.]
Ok. Do you have a link to recommend for a description of this simple adjunct XmlTechnology?, and have examples to help developer understand that they do need it?? Thanks
[Not right now, sorry, maybe someone else can provide such pointers. But googling is very likely to yield what you want. I'd try "xpath tutorial", including the double quotes, and then try variants if that doesn't do it. DeleteWhenCooked]
Xpath is a very concise and fairly readable way to reference elements in a hierarchy (not necessarily XML). I developed the xpath rule definition feature for http://pmd.sf.net/ because it much simpler than trying to define the rules in java code (though I admit that if pmd was in ruby/python/perl I probably may not have felt such a pressing need). With a couple of hours work, I converted nearly all of the pmd rules into xpath expressions, and this was maybe two days after I first learnt about the workings of Xpath. In the right situations, Xpath is a godsend.
Using the above example, suppose I wanted the title nodes of all the movies. In ruby-like code (I don't know the ruby xml library):
movie_listing.select { |node| node.name == "movie" }.collect { |node| node.select { |innernode| innernode.name == "title" } }.flattenWhereas, with xpath, I'd do
movie_listing.xpath_select( "movie/title" )Expand this into more complicated expressions, say movie titles of French films that are longer than 120 minutes
movie_listing.xpath_select( "movie[@language='french'][@length gt 120]/title" ) movie_listing.select { |node| node.name == "movie" and node.attrs.any? {|innernode| innernode.name == 'language' && innernode.value == 'french' } and node.attrs.any? {|innernode| innernode.name == 'length' && innernode.value.to_i > 120 } }.collect { |node| node.select { |innernode| innernode.name == 'title' } }(excuse any errors, I haven't been near xml/xpath in a while now)
Since this page title has the same format as those other IwannaLearn< languagename > pages, let me pipe in with a caveat: There are efforts by overzealous committees to create a TuringComplete language, most notably XSLT, using XML angle brackets in the syntax. XML is most useful when it is more modest than that. I personally think of XSLT in the same vein as RegularExpressions and manage to get a lot of use out of it that way. -- francis