On Nov 29, 2007 1:15 PM, Luke Palmer <[EMAIL PROTECTED]> wrote:
> This has become quite the flame war.  There seem to be two sides of
> the argument, you arguing one, everybody else arguing the other.

good to see there is passion underlying perl 6 development ;)

> So to bring some perspective back into this discussion, I'd like to
> ask you, what would it mean to you for there to be an XML type in
> core?  That is,
> from a user's perspective, disregarding implementation of the
> language?  What would you be able to do with it that you couldn't do
> if it were a module
> (arguments such as "use it without putting 'use XML::Foo' at the top"
> considered valid)?

well, if my previous posts didn't attract flames.... this post certainly will ;)

but you did say 'from a users perspective' ... so I will play 'make
believe' with some syntax

first a few assumptions;

we will probably never want to 'address' xml in perl ... e.g. perl
format will never become declarative markup and there is no reason to
start wanting to somehow mix code/data lisp style in perl

another thing to admit is that an XML type would probably just be an
XML document .... well formed and adhering to the rules of XML v1.0
.... going beyond that and stating it must be an XML Infoset is going
too far.

-----------------------

Here are some examples of psuedo syntax I would find useful (which I
have borrowed from things like XQuery, e4X, etc);

---------------------------------
declaring some xml in one's perl program;
---------------------------------

my $sales = <sales vendor="John">
    <item type="peas" price="4" quantity="6"/>
    <item type="carrot" price="3" quantity="10"/>
    <item type="chips" price="5" quantity="3"/>
  </sales>;

no surrounding quotes seems about right.

however this leads to some 'other thoughts, like how does perl and xml
play nice together....

what about;

my $html  = <html><head/><body>
    <span>
      <h1>{ $sometitlevar }</h1>
      <ul>
      {

loop ($counter = 1; $counter < 20; $counter++) {
     <li>Try to count electric sheep . . . </li>;
}

      }
      </ul>
    </span>
</body></html>

I have eschewed with explicitly having a print statement, as a
syntactic shortcut.

when it comes to manipulating XML, there are a few axioms...

---------------------------------
How to Address parts of an XML document variable ?
---------------------------------

It is common to want to address a portion of an XML document

    my $select_li_elements  = $html.html.body.span.ul ;

this syntax is ok (actually I do not like this approach), but I like
my 'scanability' to be in xpath form ala:

    my $select_li_elements  = $html[/html/body/span/ul/li];

and then u have the expressive power of xpath inside of these brackets.

so when declaring a var as xml, it would be this

my $data is XML;

( as an aside, is there any concept of the native types, Scalar,
Array, Hash being in a different namespace then all the other symbols
e.g. could I override Scalar type ?)

next,

---------------------------------
How do I update an XML document variable ?
---------------------------------

Here are a few edit type examples reusing the XPATH syntax introduced earlier;

This would replace text context node of <div id="mydivid"/>

    $html[/html/body/[EMAIL PROTECTED]'mydivid'] ] = "new text value";

This would replace text context node of a div with an id of the value
of $myperlvar

    $html[/html/body/[EMAIL PROTECTED] ] = "new text value";

This would replace XML children of ul element

    $html[/html/body/span/ul] .= <li>some new bullet point</li>;

This would remove XML children of ul element

    $html[/html/body/span/ul] .= null;

I am unsure of what an append scenario  would look like.

---------------------------------
And what about validation?
---------------------------------

Perhaps one would like to be able to decide if this xml must be
checked for validaty against some schema technology (DTD and relaxNG
as basic) .... are there any 'adjectives when declaring a type ... I
guess I am suggesting a new sigil enforcing an XML context ;0


then there is the 'processing' XML bit .....

---------------------------------
Iterating through XML
---------------------------------

should print out the value of each div contained in html

for $myxmlvar[/html/body/div]]{
    print; # prints $_, the current loop variable
}


I will stop here ... so I can put on my flame proof suit.

cheers, Jim Fuller

Reply via email to