xsl-list
[Top] [All Lists]

Re: [xsl] LINQ to XML versus XSLT

2008-06-27 07:31:06


--------------------------------------------------
From: "Alexander Johannesen" <alexander(_dot_)johannesen(_at_)gmail(_dot_)com>
Sent: Friday, June 27, 2008 3:20 PM
To: <xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com>
Subject: Re: [xsl] LINQ to XML versus XSLT

On Fri, Jun 27, 2008 at 15:53, Joe Fawcett <joefawcett(_at_)hotmail(_dot_)com> 
wrote:
True but in LINQ's defence it is declarative, in the same mould as SQL.

Really? By that token, all queries are declarative. In my world,
declarative approaches deal more with expected outcome rather than
querying known structures (i.e. XSLT matching does not require
knowledge of the data model, whereas a query like SQL requires it).

Anyway, I find both LINQ and the XML API non-elegant, like a hack on
C# with an API of sorts instead of extending the language with native
XML support. Why no language hasn't got XML as a native datatype yet
is the truly absurd thing. Everybody use XML, yet no language has got
it in its fabric. In other words, why ;

XElement contacts =
  new XElement("contacts",
     new XElement("contact",
        new XElement("name", "Patrick Hines"),
        new XElement("phone", "206-555-0144"),
        new XElement("address",
           new XElement("street1", "123 Main St"),
           new XElement("city", "Mercer Island"),
           new XElement("state", "WA"),
           new XElement("postal", "68042")
        )
     )
  );

when you could do ;

result =
  <contacts>
     <contact>
        <name>Patrick Hines</name>
        <phone>...</phone>
        ...
     </contact>
  </contacts> ;

or ;

result = <root><name>{$some.variable}</name></root> ;

or ;

result =
  <root>
    <xsl:for-each select="{$some.list}">
       <name>{name}</name>
    </xsl:for-each>
  </root> ;

Fiddling around with the various APIs we're currently doing is *so*
1999. Time to move on, no? Put the beauty of XSLT in your languages
already.


Alex
--
Well you can do either of those first two syntaxes in VB.NET and a variant on the third.

When I said declarative I meant from/where/select syntax as shown in this posting: http://chaddalton.com/blog/post/2848/


Joe
http://joe.fawcett.name

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--