From: Clark C. E. <cc...@cl...> - 2003-09-24 14:26:04
|
On Wed, Sep 24, 2003 at 10:01:33AM +0100, Ged Byrne wrote: | I hope you don't mind me sharing some thoughts on | YPATH. YPATH should not be Xpath Well, my goal is two fold: (a) do not use anything from XPath unless there are lots and lots of reasons (b) do not deviate from XPath unless there are a few good reasons. YAML is very different from XML -- I am not blindly idolizing Xpath. ;) | The XML phile is used to Xpath. If YPATH is trying to | be XPath it will never succeed, Xpath is just too big. Agreed. However, given the YAML <-> XML transformation, it would be nice if _simple_ path structures happened to work both in a YPath and an XPath processor and return "equivalent" results. | The XML Sceptic has rejected XML has hype. They have | no need to learn the ever expanding mass of Xfamily | specs because they're scripting language already gives | them the abitlity to throw their data about any which | way. The XML sceptic likes YAML because it is quick, | convenient and lighweight. For example, it uses their | favourite scripting languages datastructures, so they | didn't have the displeasure of learning a new DOM. Yep. | puts "\n// *1" | p y | | puts "\n/product *24" | p y['product'] | | puts "\n/product/ *25,*34" | y['product'].each{|n| p n} | | puts "\nproduct/*/sku/ *27,*36" | ((y['product'].each{|n| n}).each{|n| p n['sku']}) | | puts "\n/address/!~{sta}/ *15,*17" | y.each{|k, v| v['address'].each{|k, v| p v unless | k=~/sta/} if v.class==Hash && v['address']} | | Without any work, the necessary features are almost | there. I'm sure Perl and Python are no different. | | The rather complex each statements used in the later | example to implement selection and recursion could be | cleaned up by extending [] to allow expresions like | | [*] ( all ) | [**] ( resursive all ) | [*{if 'sku'}] | [**{unless /sta/}]. I'd love to hear more. Best, Clark |