www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - [challenge] To implement XPath 2.0 in D

reply Justin Johansson <no spam.com> writes:
Is D2 suitable to implementing the W3C specifications
for XPath 2.0, and particularly the XPath & XQuery Data
Model (XDM), with both coding succinctness and runtime
time and space efficiency?

The reference links to the W3C specs are as follows:

XML Path Language (XPath) 2.0 (Second Edition)
http://www.w3.org/TR/2009/PER-xpath20-20090421/

XQuery 1.0 and XPath 2.0 Data Model (XDM) (Second Edition)
http://www.w3.org/TR/2009/PER-xpath-datamodel-20090421/

XQuery 1.0 and XPath 2.0 Formal Semantics (Second Edition)
http://www.w3.org/TR/2009/PER-xquery-semantics-20090421/

XQuery 1.0 and XPath 2.0 Functions and Operators (Second Edition)
http://www.w3.org/TR/2009/PER-xpath-functions-20090421/


Now, by suitability, I don't mean if it can be done.  Of course
it can be done in COBOL, assembler or any Turing machine
if one tries hard enough.

The challenge for D2 is to show that these W3C specs
can be implemented in D2 with ease (as say compared to
implementation in C++ or Java).

The biggest challenge that I see in any intelligent
implementation of these W3C specifications is to
produce an implementation that
(1) makes good balance of space and time complexity
from an algorithmic point of view
(2) demonstrates a well-read codification in the target
language which mirrors well, that is traceability,
with the W3C XPath/XDM specifications.
(3) implicit in (1) and (2) the target language lives
up to its expectations as advertised to be capable of
producing a concise and succinct implementation of
something as complex as XPath 2.0.

Is D2 up to a challenge a steep as this?

-- Justin Johansson
Sep 13 2010
next sibling parent reply "Yao G." <yao.gomez spam.gmail.com> writes:
On Mon, 13 Sep 2010 09:46:31 -0500, Justin Johansson <no spam.com> wrote:

 Is D2 suitable to implementing the W3C specifications
 for XPath 2.0, and particularly the XPath & XQuery Data
 Model (XDM), with both coding succinctness and runtime
 time and space efficiency?
 [snip]
For this. First we would need a better module to manipulate XML files than the one in std.xml. -- Yao G.
Sep 13 2010
parent reply Russel Winder <russel russel.org.uk> writes:
On Mon, 2010-09-13 at 11:19 -0500, Yao G. wrote:
[ . . . ]
 For this. First we would need a better module to manipulate XML files tha=
n =20
 the one in std.xml.
The Python community seem to be gravitating towards using lxml which wraps libxml2 and libxslt. If D can make calls to C libraries why reimplement the algorithms? cf. http://xmlsoft.org/ --=20 Russel. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D Dr Russel Winder t: +44 20 7585 2200 voip: sip:russel.winder ekiga.n= et 41 Buckmaster Road m: +44 7770 465 077 xmpp: russel russel.org.uk London SW11 1EN, UK w: www.russel.org.uk skype: russel_winder
Sep 13 2010
parent Olivier Pisano <olivier.pisano laposte.net> writes:
Le 14/09/2010 06:58, Russel Winder a écrit :
 On Mon, 2010-09-13 at 11:19 -0500, Yao G. wrote:
 [ . . . ]
 For this. First we would need a better module to manipulate XML files than
 the one in std.xml.
The Python community seem to be gravitating towards using lxml which wraps libxml2 and libxslt. If D can make calls to C libraries why reimplement the algorithms? cf. http://xmlsoft.org/
D has some features that can make a difference in terms of performances. The Tango D library is significantly faster than libxml2 for XML processing. Check out this link explaining why: http://dotnot.org/blog/archives/2008/03/12/why-is-dtango-so-fast-at-parsing-xml/
Sep 14 2010
prev sibling next sibling parent Kagamin <spam here.lot> writes:
Justin Johansson Wrote:

 Is D2 suitable to implementing the W3C specifications
 for XPath 2.0, and particularly the XPath & XQuery Data
 Model (XDM), with both coding succinctness and runtime
 time and space efficiency?
First you should implement DOM. The hardest part will be standard compliance. And making it time and space efficient will require a rewrite (custom string class for sure).
Sep 14 2010
prev sibling parent Justin Johansson <no spam.com> writes:
On 14/09/2010 12:16 AM, Justin Johansson wrote:
 Is D2 suitable to implementing the W3C specifications
 for XPath 2.0, and particularly the XPath & XQuery Data
 Model (XDM), with both coding succinctness and runtime
 time and space efficiency?

 Now, by suitability, I don't mean if it can be done. Of course
 it can be done in COBOL, assembler or any Turing machine
 if one tries hard enough.

 The challenge for D2 is to show that these W3C specs
 can be implemented in D2 with ease (as say compared to
 implementation in C++ or Java).

 The biggest challenge that I see in any intelligent
 implementation of these W3C specifications is to
 produce an implementation that
 (1) makes good balance of space and time complexity
 from an algorithmic point of view
 (2) demonstrates a well-read codification in the target
 language which mirrors well, that is traceability,
 with the W3C XPath/XDM specifications.
 (3) implicit in (1) and (2) the target language lives
 up to its expectations as advertised to be capable of
 producing a concise and succinct implementation of
 something as complex as XPath 2.0.

 Is D2 up to a challenge a steep as this?
To make this challenge a bit more realistic in what is humanly possible for a $64K question, let's reduce this challenge to an XPath 2.0 implementation which ignores XML node types as possible XDM item types. I resubmit this challenge to address only the atomic item types (i.e. such as xs:anyAtomicType, xs:decimal, xs:integer, xs:string and xs:boolean) ignoring anything else that is related to XML. Me thinks this diluted challenge remains difficult to implement in D (or C++ or Java for that matter). -- Justin Johansson
Sep 15 2010