OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]
Re: [xml-dev] RE: XML Mantra


I'll not try to contradict the notion of potential energy, I kind of agree, just to state that essentially we attempted to explain this same 'phenomenon' in regard to XForms at Balisage 2013.

Apart from thinking of XForms as being of the data-driven approach, the declarative "logic" of an XForms form (via actions, refs, binds) is made possible through XPath, using both its navigational and its predicate definitional power. So, we can go a step further and think of XForms as being 'data-structure-driven'."

[Cameron, Stephen, and William David Velásquez. “A Data-Driven Approach using XForms for Building a Web Forms Generation Framework.” Presented at Balisage: The Markup Conference 2013, Montréal, Canada, August 6 - 9, 2013. In Proceedings of Balisage: The Markup Conference 2013. Balisage Series on Markup Technologies, vol. 10 (2013). doi:10.4242/BalisageVol10.Velasquez01.
The potential energy is structure.]

There is still something missing though, which is the ability to refactor the structure and associated XPaths fearlessly, something that is so refined in OO development tools.

Steve Cameron

On Sun, Jan 5, 2014 at 11:44 PM, Hans-Juergen Rennau <hrennau@yahoo.de> wrote:
The "mantra" matches also my experience - recurring in almost every project and for many years. The challenge is to approach a genuine understanding of what difference it makes whether or not we bring XML into play.
The phenomenon: (1) reduced cost while achieving a desired result; (2) increased value of the artifacts created on the way. But what properties of XML are responsible for the phenomenon? I believe we have hardly begun to understand the principles behind it, we only observe the effects.
Not an explanation, but an image: XML encoded information is charged with potential energy (reduced entropy) which we can tap & turn into work. To turn non-XML into XML is like pumping energy into the input material which is henceforth at our disposal. (Rephrasing the mantra: "Maximize the phase in which to profit from XML potential energy.") Rule of thumb: to get from A to B, the effort critically depends on whether A is XML or not, and little depends on the format of B. (A *should* be XML; B may be anything).
~ ~ ~
I want to demonstrate the phenomenon with a small, but complete example.
Input: CSV data
Output: a text report rendering search results on the input data.
Pattern: XML is not involved in the problem; XML is the solution
Consider these CSV data about drivers (name, age, city):
Consider this desired result:
age > 30         : michael andy paul
city = Reading : michael tom chris
lacking: city     : bill paul
only: name      : bill
An XML-based solution:
(a) Use XQuery to turn CSV into XML (8 lines of code)
(b) Use XQuery to produce the report (6 lines of code)
The following XQuery code creates the complete report (including four queries):
age &gt; 30     : { //driver[age/number(.) gt 30]/name/string() }
city = Reading : { //driver[city eq 'Reading']/name/string() }
lacking: city     : { //driver[not(city/string())]/name/string() }
only: name      : { //driver[empty((* except name)[string()])]/name/string() }
(1) The cost:
      8 + 6 lines of XQuery code
(2) The benefits:
      (a) the desired report
      (b) a generic query to turn CSV into XML (supporting customized element names)
      (c) a report generator which is extremely concise, maintainable and extensible
(3) The principle: use XML
PS: A generic query (XQuery 3.0) for turning CSV into XML, supporting customized element names:
declare variable $uri external;
declare variable $names external;
declare variable $enames := tokenize(normalize-space($names), ' ');
element {$enames[1]} {
    for $line in unparsed-text-lines($uri)[string()] return
        element {$enames[2]} {
            for $cell at $nr in tokenize($line, ';') return
                element {$enames[2 + $nr]} {$cell}}}
PPS: Using BaseX (download from: http://basex.org/products/download/all-downloads/ ), the following command:
      basex -b uri=drivers.csv "-b names=drivers driver name age city" csv2xml.xq
created this XML:

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 1993-2007 XML.org. This site is hosted by OASIS