Writing API for XML (WAX) - Bibliography example

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

Writing API for XML (WAX) - Bibliography example

Hannes Hirzel
Hello

I read the post by Stephane Ducasse about writing XML (see below) with
a bibliography example.

Recently I (re)-discovered the port to Squeak/Pharo of the Writing API
for XML (WAX) (http://java.ociweb.com/mark/programming/WAX.html) and
could put it to good use for writing an XML file a bit more complex
than the bibliography example.

From the web site
 WAX has the following characteristics:

    * focuses on writing XML, not reading it
    * requires less code than other approaches
    * uses less memory than other approaches
      (because it outputs XML as each method is called rather than
      storing it in a DOM-like structure and outputting it later)
    * writes all XML node types
    * always outputs well-formed XML or throws an exception unless
running in "trust me" mode
    * knows how to associate DTDs, XML Schemas and XSLT stylesheets
with the XML it outputs
    * is well-suited for writing XML request and response messages for
REST-based and SOAP-based services

However I do not know how far these points apply to the Squeak/Pharo port.
http://www.squeaksource.com/WAX
It needs the VB Regex package (http://www.squeaksource.com/Regex)

As an exercise I did the code to produce the example Stephane gave. It
worked fine; see below.

Regards
Hannes





==========================================================

        WAX  new
                stream: (FileStream newFileNamed: 'myBibliography.xml');
              writeXMLDeclaration: #1.0;
              start: 'BDBase';
                        attr: 'date' value: '25 May 2010';
                        attr: 'note' value: 'nil';
                       
                        start: 'bd';
                                attr: 'authors' value: 'Larcenet';
                                attr: 'editor' value: 'Dargaud';
                                attr: 'entryCreationDate' value: '25 March 2006';
                                attr: 'entryNumber' value: '1';
                                attr: 'number' value: '1';
                                attr: 'original' value: 'true';
                                attr: 'serie' value: 'Nic oumouk';
                                attr: 'serieComplete' value: 'false';
                                attr: 'title' value: 'Total souk pour nic oumouk';
                                attr: 'year' value: '2005';
                        end;
                       
                        start: 'bd';
                                attr: 'authors' value: 'Greg';
                                attr: 'editor' value: 'Dargaud';
                                attr: 'entryCreationDate' value: '5 May 2006';
                                attr: 'entryNumber' value: '2';
                                attr: 'notes' value: 'sur le 4eme de couv aventure a manhattan';
                                attr: 'number' value: '9';
                                attr: 'original' value: 'true';
                                attr: 'serie' value: 'Achille Talon';
                                attr: 'title' value: 'Les petits desseins d''Achille Talon';
                                attr: 'year' value: '1974';
                        end;
                       
                        start: 'bd';
                                attr: 'authors' value: 'Greg';
                                attr: 'editor' value: 'Dargaud';
                                attr: 'entryCreationDate' value: '5 May 2006';
                                attr: 'entryNumber' value: '3';
                                attr: 'notes' value: 'sur la couverture une histoire du journal tintin';
                                attr: 'number' value: '13';
                                attr: 'original' value: 'true';
                                attr: 'serie' value: 'Achille Talon';
                                attr: 'title' value: 'Pas de pitié pour Achille Talon';
                                attr: 'year' value: '1976';
                        end;
                end;
       close.

==========================================================
Output
<?xml version="1.0" encoding="UTF-8"?>
<BDBase date="25 May 2010" note="nil">
  <bd authors="Larcenet" editor="Dargaud" entryCreationDate="25 March
2006" entryNumber="1" number="1" original="true" serie="Nic oumouk"
serieComplete="false" title="Total souk pour nic oumouk" year="2005"/>
  <bd authors="Greg" editor="Dargaud" entryCreationDate="5 May 2006"
entryNumber="2" notes="sur le 4eme de couv aventure a manhattan"
number="9" original="true" serie="Achille Talon" title="Les petits
desseins d&apos;Achille Talon" year="1974"/>
  <bd authors="Greg" editor="Dargaud" entryCreationDate="5 May 2006"
entryNumber="3" notes="sur la couverture une histoire du journal
tintin" number="13" original="true" serie="Achille Talon" title="Pas
de pitié pour Achille Talon" year="1976"/>
</BDBase>



==========================================================

On 10/31/10, stephane ducasse <[hidden email]> wrote:

> How can I control that each of the node of my document get printed a cr at
> its end?
>
> In the past I got that
>
> <?xml  version="1.0" encoding="UTF-8" ?>
> <BDBase date="25 May 2010" entriesNumber="2440" note="nil">
> <bd authors="Larcenet" editor="Dargaud" entryCreationDate="25 March 2006"
> entryNumber="1" number="1" original="true" serie="Nic oumouk"
> serieComplete="false" title="Total souk pour nic oumouk" year="2005"/>
> <bd authors="Greg" editor="Dargaud" entryCreationDate="5 May 2006"
> entryNumber="2" notes="sur le 4eme de couv aventure a manhattan" number="9"
> original="true" serie="Achille Talon" title="Les petits desseins d'Achille
> Talon" year="1974"/>
> <bd authors="Greg" editor="Dargaud" entryCreationDate="5 May 2006"
> entryNumber="3" notes="sur la couverture une histoire du journal tintin"
> number="13" original="true" serie="Achille Talon" title="Pas de pitié pour
> Achille Talon" year="1976"/>
> <bd aut
>
> Now I get
>
> <?xml version="1.0" encoding="UTF-8"?><Base date="31 October 2010"
> entriesNumber="2448" note="nil"><bd serieComplete="false" editor="Dargaud"
> entryCreationDate="25 March 2006" entryNumber="1" authors="Larcenet"
> title="Total souk pour nic oumouk" serie="Nic oumouk" original="true"
> number="1" year="2005" /><bd serieComplete="false" editor="Dargaud"
> entryCreationDate="5 May 2006" entryNumber="2" authors="Greg" title="Les
> petits desseins d'Achille Talon" serie="Achille Talon" original="true"
> notes="sur le 4eme de couv aventure a manhattan" number="9" year="1974"
> /><bd serieComplete="false" editor="Dargaud" entryCreationDate="5 May 2006"
> entryNumber="3" authors="Greg" title="Pas de pitié pour Achille Talon"
> serie="Achille Talon" original="true" notes="sur la couverture une histoire
> du journal tintin" number="13" year="1976" /><bd serieComplete="false"
> editor="Dargaud" entryCreationDate="5 May 2006" entryNumber="4"
> authors="Greg" title
>
> Thanks
>
> Stef
>

Reply | Threaded
Open this post in threaded view
|

Re: Writing API for XML (WAX) - Bibliography example

Stéphane Ducasse
Thanks hannes
I think that the XMLWriter offers a bit something similar influenced by seaside DSL.

Stef

On Nov 1, 2010, at 10:58 PM, Hannes Hirzel wrote:

> Hello
>
> I read the post by Stephane Ducasse about writing XML (see below) with
> a bibliography example.
>
> Recently I (re)-discovered the port to Squeak/Pharo of the Writing API
> for XML (WAX) (http://java.ociweb.com/mark/programming/WAX.html) and
> could put it to good use for writing an XML file a bit more complex
> than the bibliography example.
>
> From the web site
> WAX has the following characteristics:
>
>    * focuses on writing XML, not reading it
>    * requires less code than other approaches
>    * uses less memory than other approaches
>      (because it outputs XML as each method is called rather than
>      storing it in a DOM-like structure and outputting it later)
>    * writes all XML node types
>    * always outputs well-formed XML or throws an exception unless
> running in "trust me" mode
>    * knows how to associate DTDs, XML Schemas and XSLT stylesheets
> with the XML it outputs
>    * is well-suited for writing XML request and response messages for
> REST-based and SOAP-based services
>
> However I do not know how far these points apply to the Squeak/Pharo port.
> http://www.squeaksource.com/WAX
> It needs the VB Regex package (http://www.squeaksource.com/Regex)
>
> As an exercise I did the code to produce the example Stephane gave. It
> worked fine; see below.
>
> Regards
> Hannes
>
>
>
>
>
> ==========================================================
>
> WAX  new
> stream: (FileStream newFileNamed: 'myBibliography.xml');
>      writeXMLDeclaration: #1.0;
>      start: 'BDBase';
> attr: 'date' value: '25 May 2010';
> attr: 'note' value: 'nil';
>
> start: 'bd';
> attr: 'authors' value: 'Larcenet';
> attr: 'editor' value: 'Dargaud';
> attr: 'entryCreationDate' value: '25 March 2006';
> attr: 'entryNumber' value: '1';
> attr: 'number' value: '1';
> attr: 'original' value: 'true';
> attr: 'serie' value: 'Nic oumouk';
> attr: 'serieComplete' value: 'false';
> attr: 'title' value: 'Total souk pour nic oumouk';
> attr: 'year' value: '2005';
> end;
>
> start: 'bd';
> attr: 'authors' value: 'Greg';
> attr: 'editor' value: 'Dargaud';
> attr: 'entryCreationDate' value: '5 May 2006';
> attr: 'entryNumber' value: '2';
> attr: 'notes' value: 'sur le 4eme de couv aventure a manhattan';
> attr: 'number' value: '9';
> attr: 'original' value: 'true';
> attr: 'serie' value: 'Achille Talon';
> attr: 'title' value: 'Les petits desseins d''Achille Talon';
> attr: 'year' value: '1974';
> end;
>
> start: 'bd';
> attr: 'authors' value: 'Greg';
> attr: 'editor' value: 'Dargaud';
> attr: 'entryCreationDate' value: '5 May 2006';
> attr: 'entryNumber' value: '3';
> attr: 'notes' value: 'sur la couverture une histoire du journal tintin';
> attr: 'number' value: '13';
> attr: 'original' value: 'true';
> attr: 'serie' value: 'Achille Talon';
> attr: 'title' value: 'Pas de pitié pour Achille Talon';
> attr: 'year' value: '1976';
> end;
> end;
>       close.
>
> ==========================================================
> Output
> <?xml version="1.0" encoding="UTF-8"?>
> <BDBase date="25 May 2010" note="nil">
>  <bd authors="Larcenet" editor="Dargaud" entryCreationDate="25 March
> 2006" entryNumber="1" number="1" original="true" serie="Nic oumouk"
> serieComplete="false" title="Total souk pour nic oumouk" year="2005"/>
>  <bd authors="Greg" editor="Dargaud" entryCreationDate="5 May 2006"
> entryNumber="2" notes="sur le 4eme de couv aventure a manhattan"
> number="9" original="true" serie="Achille Talon" title="Les petits
> desseins d&apos;Achille Talon" year="1974"/>
>  <bd authors="Greg" editor="Dargaud" entryCreationDate="5 May 2006"
> entryNumber="3" notes="sur la couverture une histoire du journal
> tintin" number="13" original="true" serie="Achille Talon" title="Pas
> de pitié pour Achille Talon" year="1976"/>
> </BDBase>
>
>
>
> ==========================================================
>
> On 10/31/10, stephane ducasse <[hidden email]> wrote:
>> How can I control that each of the node of my document get printed a cr at
>> its end?
>>
>> In the past I got that
>>
>> <?xml  version="1.0" encoding="UTF-8" ?>
>> <BDBase date="25 May 2010" entriesNumber="2440" note="nil">
>> <bd authors="Larcenet" editor="Dargaud" entryCreationDate="25 March 2006"
>> entryNumber="1" number="1" original="true" serie="Nic oumouk"
>> serieComplete="false" title="Total souk pour nic oumouk" year="2005"/>
>> <bd authors="Greg" editor="Dargaud" entryCreationDate="5 May 2006"
>> entryNumber="2" notes="sur le 4eme de couv aventure a manhattan" number="9"
>> original="true" serie="Achille Talon" title="Les petits desseins d'Achille
>> Talon" year="1974"/>
>> <bd authors="Greg" editor="Dargaud" entryCreationDate="5 May 2006"
>> entryNumber="3" notes="sur la couverture une histoire du journal tintin"
>> number="13" original="true" serie="Achille Talon" title="Pas de pitié pour
>> Achille Talon" year="1976"/>
>> <bd aut
>>
>> Now I get
>>
>> <?xml version="1.0" encoding="UTF-8"?><Base date="31 October 2010"
>> entriesNumber="2448" note="nil"><bd serieComplete="false" editor="Dargaud"
>> entryCreationDate="25 March 2006" entryNumber="1" authors="Larcenet"
>> title="Total souk pour nic oumouk" serie="Nic oumouk" original="true"
>> number="1" year="2005" /><bd serieComplete="false" editor="Dargaud"
>> entryCreationDate="5 May 2006" entryNumber="2" authors="Greg" title="Les
>> petits desseins d'Achille Talon" serie="Achille Talon" original="true"
>> notes="sur le 4eme de couv aventure a manhattan" number="9" year="1974"
>> /><bd serieComplete="false" editor="Dargaud" entryCreationDate="5 May 2006"
>> entryNumber="3" authors="Greg" title="Pas de pitié pour Achille Talon"
>> serie="Achille Talon" original="true" notes="sur la couverture une histoire
>> du journal tintin" number="13" year="1976" /><bd serieComplete="false"
>> editor="Dargaud" entryCreationDate="5 May 2006" entryNumber="4"
>> authors="Greg" title
>>
>> Thanks
>>
>> Stef
>>
>


Reply | Threaded
Open this post in threaded view
|

Re: Writing API for XML (WAX) - Bibliography example

Hannes Hirzel
Thank you Stef, for pointing this out.

I had a look at Torsten's email of July 6th about XMLWriter and the
subsequent discussion.

Yes, an alternative approach would be to model an XML  generation API
along the lines of Seaside html rendering -- with blocks instead of
start/end messages.

Has there some work going on elsewhere besides what Torsten did?
http://squeaksource.com/PharoGoodies/XMLWriter-tbn.5.mcz

--Hannes

N.B. This is only about 'XML writing' NOT about XML parsing. The idea
is to have an API which allows to have readable XML generation code
with an implementation which does not consume much memory. And with
enough examples and tests.


On 11/2/10, Stéphane Ducasse <[hidden email]> wrote:

> Thanks hannes
> I think that the XMLWriter offers a bit something similar influenced by
> seaside DSL.
>
> Stef
>
> On Nov 1, 2010, at 10:58 PM, Hannes Hirzel wrote:
>
>> Hello
>>
>> I read the post by Stephane Ducasse about writing XML (see below) with
>> a bibliography example.
>>
>> Recently I (re)-discovered the port to Squeak/Pharo of the Writing API
>> for XML (WAX) (http://java.ociweb.com/mark/programming/WAX.html) and
>> could put it to good use for writing an XML file a bit more complex
>> than the bibliography example.
>>
>> From the web site
>> WAX has the following characteristics:
>>
>>    * focuses on writing XML, not reading it
>>    * requires less code than other approaches
>>    * uses less memory than other approaches
>>      (because it outputs XML as each method is called rather than
>>      storing it in a DOM-like structure and outputting it later)
>>    * writes all XML node types
>>    * always outputs well-formed XML or throws an exception unless
>> running in "trust me" mode
>>    * knows how to associate DTDs, XML Schemas and XSLT stylesheets
>> with the XML it outputs
>>    * is well-suited for writing XML request and response messages for
>> REST-based and SOAP-based services
>>
>> However I do not know how far these points apply to the Squeak/Pharo port.
>> http://www.squeaksource.com/WAX
>> It needs the VB Regex package (http://www.squeaksource.com/Regex)
>>
>> As an exercise I did the code to produce the example Stephane gave. It
>> worked fine; see below.
>>
>> Regards
>> Hannes
>>
>>
>>
>>
>>
>> ==========================================================
>>
>> WAX  new
>> stream: (FileStream newFileNamed: 'myBibliography.xml');
>>      writeXMLDeclaration: #1.0;
>>      start: 'BDBase';
>> attr: 'date' value: '25 May 2010';
>> attr: 'note' value: 'nil';
>>
>> start: 'bd';
>> attr: 'authors' value: 'Larcenet';
>> attr: 'editor' value: 'Dargaud';
>> attr: 'entryCreationDate' value: '25 March 2006';
>> attr: 'entryNumber' value: '1';
>> attr: 'number' value: '1';
>> attr: 'original' value: 'true';
>> attr: 'serie' value: 'Nic oumouk';
>> attr: 'serieComplete' value: 'false';
>> attr: 'title' value: 'Total souk pour nic oumouk';
>> attr: 'year' value: '2005';
>> end;
>>
>> start: 'bd';
>> attr: 'authors' value: 'Greg';
>> attr: 'editor' value: 'Dargaud';
>> attr: 'entryCreationDate' value: '5 May 2006';
>> attr: 'entryNumber' value: '2';
>> attr: 'notes' value: 'sur le 4eme de couv aventure a manhattan';
>> attr: 'number' value: '9';
>> attr: 'original' value: 'true';
>> attr: 'serie' value: 'Achille Talon';
>> attr: 'title' value: 'Les petits desseins d''Achille Talon';
>> attr: 'year' value: '1974';
>> end;
>>
>> start: 'bd';
>> attr: 'authors' value: 'Greg';
>> attr: 'editor' value: 'Dargaud';
>> attr: 'entryCreationDate' value: '5 May 2006';
>> attr: 'entryNumber' value: '3';
>> attr: 'notes' value: 'sur la couverture une histoire du journal
>> tintin';
>> attr: 'number' value: '13';
>> attr: 'original' value: 'true';
>> attr: 'serie' value: 'Achille Talon';
>> attr: 'title' value: 'Pas de pitié pour Achille Talon';
>> attr: 'year' value: '1976';
>> end;
>> end;
>>       close.
>>
>> ==========================================================
>> Output
>> <?xml version="1.0" encoding="UTF-8"?>
>> <BDBase date="25 May 2010" note="nil">
>>  <bd authors="Larcenet" editor="Dargaud" entryCreationDate="25 March
>> 2006" entryNumber="1" number="1" original="true" serie="Nic oumouk"
>> serieComplete="false" title="Total souk pour nic oumouk" year="2005"/>
>>  <bd authors="Greg" editor="Dargaud" entryCreationDate="5 May 2006"
>> entryNumber="2" notes="sur le 4eme de couv aventure a manhattan"
>> number="9" original="true" serie="Achille Talon" title="Les petits
>> desseins d&apos;Achille Talon" year="1974"/>
>>  <bd authors="Greg" editor="Dargaud" entryCreationDate="5 May 2006"
>> entryNumber="3" notes="sur la couverture une histoire du journal
>> tintin" number="13" original="true" serie="Achille Talon" title="Pas
>> de pitié pour Achille Talon" year="1976"/>
>> </BDBase>
>>
>>
>>
>> ==========================================================
>>
>> On 10/31/10, stephane ducasse <[hidden email]> wrote:
>>> How can I control that each of the node of my document get printed a cr
>>> at
>>> its end?
>>>
>>> In the past I got that
>>>
>>> <?xml  version="1.0" encoding="UTF-8" ?>
>>> <BDBase date="25 May 2010" entriesNumber="2440" note="nil">
>>> <bd authors="Larcenet" editor="Dargaud" entryCreationDate="25 March 2006"
>>> entryNumber="1" number="1" original="true" serie="Nic oumouk"
>>> serieComplete="false" title="Total souk pour nic oumouk" year="2005"/>
>>> <bd authors="Greg" editor="Dargaud" entryCreationDate="5 May 2006"
>>> entryNumber="2" notes="sur le 4eme de couv aventure a manhattan"
>>> number="9"
>>> original="true" serie="Achille Talon" title="Les petits desseins
>>> d'Achille
>>> Talon" year="1974"/>
>>> <bd authors="Greg" editor="Dargaud" entryCreationDate="5 May 2006"
>>> entryNumber="3" notes="sur la couverture une histoire du journal tintin"
>>> number="13" original="true" serie="Achille Talon" title="Pas de pitié
>>> pour
>>> Achille Talon" year="1976"/>
>>> <bd aut
>>>
>>> Now I get
>>>
>>> <?xml version="1.0" encoding="UTF-8"?><Base date="31 October 2010"
>>> entriesNumber="2448" note="nil"><bd serieComplete="false"
>>> editor="Dargaud"
>>> entryCreationDate="25 March 2006" entryNumber="1" authors="Larcenet"
>>> title="Total souk pour nic oumouk" serie="Nic oumouk" original="true"
>>> number="1" year="2005" /><bd serieComplete="false" editor="Dargaud"
>>> entryCreationDate="5 May 2006" entryNumber="2" authors="Greg" title="Les
>>> petits desseins d'Achille Talon" serie="Achille Talon" original="true"
>>> notes="sur le 4eme de couv aventure a manhattan" number="9" year="1974"
>>> /><bd serieComplete="false" editor="Dargaud" entryCreationDate="5 May
>>> 2006"
>>> entryNumber="3" authors="Greg" title="Pas de pitié pour Achille Talon"
>>> serie="Achille Talon" original="true" notes="sur la couverture une
>>> histoire
>>> du journal tintin" number="13" year="1976" /><bd serieComplete="false"
>>> editor="Dargaud" entryCreationDate="5 May 2006" entryNumber="4"
>>> authors="Greg" title
>>>
>>> Thanks
>>>
>>> Stef
>>>
>>
>
>
>

Reply | Threaded
Open this post in threaded view
|

Re: Writing API for XML (WAX) - Bibliography example

Hannes Hirzel
Is XMLWriter in the upcoming 1.2 image? It is not in the 1.1 image.

--Hannes

On 11/3/10, Hannes Hirzel <[hidden email]> wrote:

> Thank you Stef, for pointing this out.
>
> I had a look at Torsten's email of July 6th about XMLWriter and the
> subsequent discussion.
>
> Yes, an alternative approach would be to model an XML  generation API
> along the lines of Seaside html rendering -- with blocks instead of
> start/end messages.
>
> Has there some work going on elsewhere besides what Torsten did?
> http://squeaksource.com/PharoGoodies/XMLWriter-tbn.5.mcz
>
> --Hannes
>
> N.B. This is only about 'XML writing' NOT about XML parsing. The idea
> is to have an API which allows to have readable XML generation code
> with an implementation which does not consume much memory. And with
> enough examples and tests.
>
>
> On 11/2/10, Stéphane Ducasse <[hidden email]> wrote:
>> Thanks hannes
>> I think that the XMLWriter offers a bit something similar influenced by
>> seaside DSL.
>>
>> Stef
>>
>> On Nov 1, 2010, at 10:58 PM, Hannes Hirzel wrote:
>>
>>> Hello
>>>
>>> I read the post by Stephane Ducasse about writing XML (see below) with
>>> a bibliography example.
>>>
>>> Recently I (re)-discovered the port to Squeak/Pharo of the Writing API
>>> for XML (WAX) (http://java.ociweb.com/mark/programming/WAX.html) and
>>> could put it to good use for writing an XML file a bit more complex
>>> than the bibliography example.
>>>
>>> From the web site
>>> WAX has the following characteristics:
>>>
>>>    * focuses on writing XML, not reading it
>>>    * requires less code than other approaches
>>>    * uses less memory than other approaches
>>>      (because it outputs XML as each method is called rather than
>>>      storing it in a DOM-like structure and outputting it later)
>>>    * writes all XML node types
>>>    * always outputs well-formed XML or throws an exception unless
>>> running in "trust me" mode
>>>    * knows how to associate DTDs, XML Schemas and XSLT stylesheets
>>> with the XML it outputs
>>>    * is well-suited for writing XML request and response messages for
>>> REST-based and SOAP-based services
>>>
>>> However I do not know how far these points apply to the Squeak/Pharo
>>> port.
>>> http://www.squeaksource.com/WAX
>>> It needs the VB Regex package (http://www.squeaksource.com/Regex)
>>>
>>> As an exercise I did the code to produce the example Stephane gave. It
>>> worked fine; see below.
>>>
>>> Regards
>>> Hannes
>>>
>>>
>>>
>>>
>>>
>>> ==========================================================
>>>
>>> WAX  new
>>> stream: (FileStream newFileNamed: 'myBibliography.xml');
>>>      writeXMLDeclaration: #1.0;
>>>      start: 'BDBase';
>>> attr: 'date' value: '25 May 2010';
>>> attr: 'note' value: 'nil';
>>>
>>> start: 'bd';
>>> attr: 'authors' value: 'Larcenet';
>>> attr: 'editor' value: 'Dargaud';
>>> attr: 'entryCreationDate' value: '25 March 2006';
>>> attr: 'entryNumber' value: '1';
>>> attr: 'number' value: '1';
>>> attr: 'original' value: 'true';
>>> attr: 'serie' value: 'Nic oumouk';
>>> attr: 'serieComplete' value: 'false';
>>> attr: 'title' value: 'Total souk pour nic oumouk';
>>> attr: 'year' value: '2005';
>>> end;
>>>
>>> start: 'bd';
>>> attr: 'authors' value: 'Greg';
>>> attr: 'editor' value: 'Dargaud';
>>> attr: 'entryCreationDate' value: '5 May 2006';
>>> attr: 'entryNumber' value: '2';
>>> attr: 'notes' value: 'sur le 4eme de couv aventure a manhattan';
>>> attr: 'number' value: '9';
>>> attr: 'original' value: 'true';
>>> attr: 'serie' value: 'Achille Talon';
>>> attr: 'title' value: 'Les petits desseins d''Achille Talon';
>>> attr: 'year' value: '1974';
>>> end;
>>>
>>> start: 'bd';
>>> attr: 'authors' value: 'Greg';
>>> attr: 'editor' value: 'Dargaud';
>>> attr: 'entryCreationDate' value: '5 May 2006';
>>> attr: 'entryNumber' value: '3';
>>> attr: 'notes' value: 'sur la couverture une histoire du journal
>>> tintin';
>>> attr: 'number' value: '13';
>>> attr: 'original' value: 'true';
>>> attr: 'serie' value: 'Achille Talon';
>>> attr: 'title' value: 'Pas de pitié pour Achille Talon';
>>> attr: 'year' value: '1976';
>>> end;
>>> end;
>>>       close.
>>>
>>> ==========================================================
>>> Output
>>> <?xml version="1.0" encoding="UTF-8"?>
>>> <BDBase date="25 May 2010" note="nil">
>>>  <bd authors="Larcenet" editor="Dargaud" entryCreationDate="25 March
>>> 2006" entryNumber="1" number="1" original="true" serie="Nic oumouk"
>>> serieComplete="false" title="Total souk pour nic oumouk" year="2005"/>
>>>  <bd authors="Greg" editor="Dargaud" entryCreationDate="5 May 2006"
>>> entryNumber="2" notes="sur le 4eme de couv aventure a manhattan"
>>> number="9" original="true" serie="Achille Talon" title="Les petits
>>> desseins d&apos;Achille Talon" year="1974"/>
>>>  <bd authors="Greg" editor="Dargaud" entryCreationDate="5 May 2006"
>>> entryNumber="3" notes="sur la couverture une histoire du journal
>>> tintin" number="13" original="true" serie="Achille Talon" title="Pas
>>> de pitié pour Achille Talon" year="1976"/>
>>> </BDBase>
>>>
>>>
>>>
>>> ==========================================================
>>>
>>> On 10/31/10, stephane ducasse <[hidden email]> wrote:
>>>> How can I control that each of the node of my document get printed a cr
>>>> at
>>>> its end?
>>>>
>>>> In the past I got that
>>>>
>>>> <?xml  version="1.0" encoding="UTF-8" ?>
>>>> <BDBase date="25 May 2010" entriesNumber="2440" note="nil">
>>>> <bd authors="Larcenet" editor="Dargaud" entryCreationDate="25 March
>>>> 2006"
>>>> entryNumber="1" number="1" original="true" serie="Nic oumouk"
>>>> serieComplete="false" title="Total souk pour nic oumouk" year="2005"/>
>>>> <bd authors="Greg" editor="Dargaud" entryCreationDate="5 May 2006"
>>>> entryNumber="2" notes="sur le 4eme de couv aventure a manhattan"
>>>> number="9"
>>>> original="true" serie="Achille Talon" title="Les petits desseins
>>>> d'Achille
>>>> Talon" year="1974"/>
>>>> <bd authors="Greg" editor="Dargaud" entryCreationDate="5 May 2006"
>>>> entryNumber="3" notes="sur la couverture une histoire du journal
>>>> tintin"
>>>> number="13" original="true" serie="Achille Talon" title="Pas de pitié
>>>> pour
>>>> Achille Talon" year="1976"/>
>>>> <bd aut
>>>>
>>>> Now I get
>>>>
>>>> <?xml version="1.0" encoding="UTF-8"?><Base date="31 October 2010"
>>>> entriesNumber="2448" note="nil"><bd serieComplete="false"
>>>> editor="Dargaud"
>>>> entryCreationDate="25 March 2006" entryNumber="1" authors="Larcenet"
>>>> title="Total souk pour nic oumouk" serie="Nic oumouk" original="true"
>>>> number="1" year="2005" /><bd serieComplete="false" editor="Dargaud"
>>>> entryCreationDate="5 May 2006" entryNumber="2" authors="Greg"
>>>> title="Les
>>>> petits desseins d'Achille Talon" serie="Achille Talon" original="true"
>>>> notes="sur le 4eme de couv aventure a manhattan" number="9" year="1974"
>>>> /><bd serieComplete="false" editor="Dargaud" entryCreationDate="5 May
>>>> 2006"
>>>> entryNumber="3" authors="Greg" title="Pas de pitié pour Achille Talon"
>>>> serie="Achille Talon" original="true" notes="sur la couverture une
>>>> histoire
>>>> du journal tintin" number="13" year="1976" /><bd serieComplete="false"
>>>> editor="Dargaud" entryCreationDate="5 May 2006" entryNumber="4"
>>>> authors="Greg" title
>>>>
>>>> Thanks
>>>>
>>>> Stef
>>>>
>>>
>>
>>
>>
>

Reply | Threaded
Open this post in threaded view
|

Re: Writing API for XML (WAX) - Bibliography example

Stéphane Ducasse
In reply to this post by Hannes Hirzel
No we consider it as an external package.
Now we will have specific dedicated repositories for each version where configuration and all their packages will be published
so that people can have distribution of working code.

Stef

On Nov 3, 2010, at 7:28 PM, Hannes Hirzel wrote:

> Is XMLWriter in the upcoming 1.2 image? It is not in the 1.1 image.
>
> --Hannes
>
> On 11/3/10, Hannes Hirzel <[hidden email]> wrote:
>> Thank you Stef, for pointing this out.
>>
>> I had a look at Torsten's email of July 6th about XMLWriter and the
>> subsequent discussion.
>>
>> Yes, an alternative approach would be to model an XML  generation API
>> along the lines of Seaside html rendering -- with blocks instead of
>> start/end messages.
>>
>> Has there some work going on elsewhere besides what Torsten did?
>> http://squeaksource.com/PharoGoodies/XMLWriter-tbn.5.mcz
>>
>> --Hannes
>>
>> N.B. This is only about 'XML writing' NOT about XML parsing. The idea
>> is to have an API which allows to have readable XML generation code
>> with an implementation which does not consume much memory. And with
>> enough examples and tests.
>>
>>
>> On 11/2/10, Stéphane Ducasse <[hidden email]> wrote:
>>> Thanks hannes
>>> I think that the XMLWriter offers a bit something similar influenced by
>>> seaside DSL.
>>>
>>> Stef
>>>
>>> On Nov 1, 2010, at 10:58 PM, Hannes Hirzel wrote:
>>>
>>>> Hello
>>>>
>>>> I read the post by Stephane Ducasse about writing XML (see below) with
>>>> a bibliography example.
>>>>
>>>> Recently I (re)-discovered the port to Squeak/Pharo of the Writing API
>>>> for XML (WAX) (http://java.ociweb.com/mark/programming/WAX.html) and
>>>> could put it to good use for writing an XML file a bit more complex
>>>> than the bibliography example.
>>>>
>>>> From the web site
>>>> WAX has the following characteristics:
>>>>
>>>>   * focuses on writing XML, not reading it
>>>>   * requires less code than other approaches
>>>>   * uses less memory than other approaches
>>>>     (because it outputs XML as each method is called rather than
>>>>     storing it in a DOM-like structure and outputting it later)
>>>>   * writes all XML node types
>>>>   * always outputs well-formed XML or throws an exception unless
>>>> running in "trust me" mode
>>>>   * knows how to associate DTDs, XML Schemas and XSLT stylesheets
>>>> with the XML it outputs
>>>>   * is well-suited for writing XML request and response messages for
>>>> REST-based and SOAP-based services
>>>>
>>>> However I do not know how far these points apply to the Squeak/Pharo
>>>> port.
>>>> http://www.squeaksource.com/WAX
>>>> It needs the VB Regex package (http://www.squeaksource.com/Regex)
>>>>
>>>> As an exercise I did the code to produce the example Stephane gave. It
>>>> worked fine; see below.
>>>>
>>>> Regards
>>>> Hannes
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> ==========================================================
>>>>
>>>> WAX  new
>>>> stream: (FileStream newFileNamed: 'myBibliography.xml');
>>>>      writeXMLDeclaration: #1.0;
>>>>      start: 'BDBase';
>>>> attr: 'date' value: '25 May 2010';
>>>> attr: 'note' value: 'nil';
>>>>
>>>> start: 'bd';
>>>> attr: 'authors' value: 'Larcenet';
>>>> attr: 'editor' value: 'Dargaud';
>>>> attr: 'entryCreationDate' value: '25 March 2006';
>>>> attr: 'entryNumber' value: '1';
>>>> attr: 'number' value: '1';
>>>> attr: 'original' value: 'true';
>>>> attr: 'serie' value: 'Nic oumouk';
>>>> attr: 'serieComplete' value: 'false';
>>>> attr: 'title' value: 'Total souk pour nic oumouk';
>>>> attr: 'year' value: '2005';
>>>> end;
>>>>
>>>> start: 'bd';
>>>> attr: 'authors' value: 'Greg';
>>>> attr: 'editor' value: 'Dargaud';
>>>> attr: 'entryCreationDate' value: '5 May 2006';
>>>> attr: 'entryNumber' value: '2';
>>>> attr: 'notes' value: 'sur le 4eme de couv aventure a manhattan';
>>>> attr: 'number' value: '9';
>>>> attr: 'original' value: 'true';
>>>> attr: 'serie' value: 'Achille Talon';
>>>> attr: 'title' value: 'Les petits desseins d''Achille Talon';
>>>> attr: 'year' value: '1974';
>>>> end;
>>>>
>>>> start: 'bd';
>>>> attr: 'authors' value: 'Greg';
>>>> attr: 'editor' value: 'Dargaud';
>>>> attr: 'entryCreationDate' value: '5 May 2006';
>>>> attr: 'entryNumber' value: '3';
>>>> attr: 'notes' value: 'sur la couverture une histoire du journal
>>>> tintin';
>>>> attr: 'number' value: '13';
>>>> attr: 'original' value: 'true';
>>>> attr: 'serie' value: 'Achille Talon';
>>>> attr: 'title' value: 'Pas de pitié pour Achille Talon';
>>>> attr: 'year' value: '1976';
>>>> end;
>>>> end;
>>>>      close.
>>>>
>>>> ==========================================================
>>>> Output
>>>> <?xml version="1.0" encoding="UTF-8"?>
>>>> <BDBase date="25 May 2010" note="nil">
>>>> <bd authors="Larcenet" editor="Dargaud" entryCreationDate="25 March
>>>> 2006" entryNumber="1" number="1" original="true" serie="Nic oumouk"
>>>> serieComplete="false" title="Total souk pour nic oumouk" year="2005"/>
>>>> <bd authors="Greg" editor="Dargaud" entryCreationDate="5 May 2006"
>>>> entryNumber="2" notes="sur le 4eme de couv aventure a manhattan"
>>>> number="9" original="true" serie="Achille Talon" title="Les petits
>>>> desseins d&apos;Achille Talon" year="1974"/>
>>>> <bd authors="Greg" editor="Dargaud" entryCreationDate="5 May 2006"
>>>> entryNumber="3" notes="sur la couverture une histoire du journal
>>>> tintin" number="13" original="true" serie="Achille Talon" title="Pas
>>>> de pitié pour Achille Talon" year="1976"/>
>>>> </BDBase>
>>>>
>>>>
>>>>
>>>> ==========================================================
>>>>
>>>> On 10/31/10, stephane ducasse <[hidden email]> wrote:
>>>>> How can I control that each of the node of my document get printed a cr
>>>>> at
>>>>> its end?
>>>>>
>>>>> In the past I got that
>>>>>
>>>>> <?xml  version="1.0" encoding="UTF-8" ?>
>>>>> <BDBase date="25 May 2010" entriesNumber="2440" note="nil">
>>>>> <bd authors="Larcenet" editor="Dargaud" entryCreationDate="25 March
>>>>> 2006"
>>>>> entryNumber="1" number="1" original="true" serie="Nic oumouk"
>>>>> serieComplete="false" title="Total souk pour nic oumouk" year="2005"/>
>>>>> <bd authors="Greg" editor="Dargaud" entryCreationDate="5 May 2006"
>>>>> entryNumber="2" notes="sur le 4eme de couv aventure a manhattan"
>>>>> number="9"
>>>>> original="true" serie="Achille Talon" title="Les petits desseins
>>>>> d'Achille
>>>>> Talon" year="1974"/>
>>>>> <bd authors="Greg" editor="Dargaud" entryCreationDate="5 May 2006"
>>>>> entryNumber="3" notes="sur la couverture une histoire du journal
>>>>> tintin"
>>>>> number="13" original="true" serie="Achille Talon" title="Pas de pitié
>>>>> pour
>>>>> Achille Talon" year="1976"/>
>>>>> <bd aut
>>>>>
>>>>> Now I get
>>>>>
>>>>> <?xml version="1.0" encoding="UTF-8"?><Base date="31 October 2010"
>>>>> entriesNumber="2448" note="nil"><bd serieComplete="false"
>>>>> editor="Dargaud"
>>>>> entryCreationDate="25 March 2006" entryNumber="1" authors="Larcenet"
>>>>> title="Total souk pour nic oumouk" serie="Nic oumouk" original="true"
>>>>> number="1" year="2005" /><bd serieComplete="false" editor="Dargaud"
>>>>> entryCreationDate="5 May 2006" entryNumber="2" authors="Greg"
>>>>> title="Les
>>>>> petits desseins d'Achille Talon" serie="Achille Talon" original="true"
>>>>> notes="sur le 4eme de couv aventure a manhattan" number="9" year="1974"
>>>>> /><bd serieComplete="false" editor="Dargaud" entryCreationDate="5 May
>>>>> 2006"
>>>>> entryNumber="3" authors="Greg" title="Pas de pitié pour Achille Talon"
>>>>> serie="Achille Talon" original="true" notes="sur la couverture une
>>>>> histoire
>>>>> du journal tintin" number="13" year="1976" /><bd serieComplete="false"
>>>>> editor="Dargaud" entryCreationDate="5 May 2006" entryNumber="4"
>>>>> authors="Greg" title
>>>>>
>>>>> Thanks
>>>>>
>>>>> Stef
>>>>>
>>>>
>>>
>>>
>>>
>>
>


Reply | Threaded
Open this post in threaded view
|

Re: Writing API for XML (WAX) - Bibliography example

Hannes Hirzel
On 11/3/10, Stéphane Ducasse <[hidden email]> wrote:
> No we consider it as an external package.

Where do I find the most recent version?
--HJH

Reply | Threaded
Open this post in threaded view
|

Re: Writing API for XML (WAX) - Bibliography example

Stéphane Ducasse
In reply to this post by Stéphane Ducasse
in XMLSupport package

On Nov 4, 2010, at 6:13 PM, Hannes Hirzel wrote:

> On 11/3/10, Stéphane Ducasse <[hidden email]> wrote:
>> No we consider it as an external package.
>
> Where do I find the most recent version?
> --HJH
>


Reply | Threaded
Open this post in threaded view
|

Re: Writing API for XML (WAX) - Bibliography example

Alexandre Bergel
http://www.squeaksource.com/XMLSupport.html

To load the thing:

Gofer new
                squeaksource: 'XMLSupport';
                package: 'ConfigurationOfXMLSupport';
                load.
(Smalltalk at: #ConfigurationOfXMLSupport) perform: #loadDefault

Alexandre


On 4 Nov 2010, at 17:54, Stéphane Ducasse wrote:

> in XMLSupport package
>
> On Nov 4, 2010, at 6:13 PM, Hannes Hirzel wrote:
>
>> On 11/3/10, Stéphane Ducasse <[hidden email]> wrote:
>>> No we consider it as an external package.
>>
>> Where do I find the most recent version?
>> --HJH
>>
>
>

--
_,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:
Alexandre Bergel  http://www.bergel.eu
^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.






Reply | Threaded
Open this post in threaded view
|

Re: Writing API for XML (WAX) - Bibliography example

jaayer
In reply to this post by Hannes Hirzel




---- On Wed, 03 Nov 2010 11:28:13 -0700 Hannes Hirzel  wrote ----

>Is XMLWriter in the upcoming 1.2 image? It is not in the 1.1 image.
>
>--Hannes

The new XML writer is in the more recent versions, from version 96 on, but at the moment you have to download it manually through Monticello or from the XMLSupport page on squeaksource.com, as the most recent Metacello configuration still points to v. 93. I'll try to update it shortly.


Reply | Threaded
Open this post in threaded view
|

Re: Writing API for XML (WAX) - Bibliography example

Hannes Hirzel
Jaayer,

Thanks, I checked out

MCHttpRepository
    location: 'http://www.squeaksource.com/XMLSupport'
    user: ''
    password: ''

and looked at
XML-Parser-tg.101


Right version?


the class comment of XMLWriter



This class allows you to generate well-formed XML documents using an
API similar to Seaside's canvas and tag brush API.

Markup can be created by sending an instance any of the messages under
"writing markup." The messages that take no arguments return an
instance of an XMLMarkupWriter subclass. These objects can be
configured with messages like #name: and #attributeAt:put:. Sending
them #write or a specific writing message that accepts markup to embed
within (#content: or #internalSubset: for example) causes the markup
writer's configuration to be committed and its markup written to the
output stream. For markup writers that can have embedded markup, the
argument to the writing message can be a string, collection (of
strings and blocks), a block, or nil. The block passed in can
optionally take an argument, which will be the XMLWriter object that
created the markup writer object. Within the block you can generate
additional, child markup that will be contained by the parent.
Creating additional non-embedded markup will cause any unwritten
markup from a previous markup writer to be written, as will sending an
XMLWriter or XMLMarkupWriter #contents, #asString, #printOn:, or
#write.

Here is an example, which you can highlight and evaluate with cmd-p to
see the result:

        | writer |
        (writer := XMLWriter new) enablePrettyPrinting.
        writer xml.
        writer tag
                        name: 'foo:bar';
                        xmlnsAt: 'foo' put: 'http://foo';
                        attributeAt: 'a' put: 'one';
                        attributeAt: 'b' put: 'two';
                        content: [
                                writer tag: 'bar' content: [
                                        writer
                                                string: 'test';
                                                tag: 'baz';
                                                tag: 'foobar' content: 'test']]


Nice, as I know the Seaside html builder pattern. It is the same.


Remark: I think it should be in its own package

Instead of

    XML-Parser-Writers

I'd like to have

    XML-Writer

because writing has nothing to do with parsing.

However at this point it is minor cosmetics.

Another remark: An example using tags like name, author, title would
be helpful as well in the class comment because one sees more easily
what is going on.

For the current problem at hand I have started using WAX and I think I
will continue to do so. One reason it that I might want to port my App
to Java when finished prototyping in Smalltalk.


MCHttpRepository
    location: 'http://www.squeaksource.com/WAX'
    user: ''
    password: ''

I have not found XMLWriter tests whereas WAX has a considerable number of them.

As for XMLWriter, I surely will look at it again in a few months time.


Regards
Hannes

On 11/5/10, jaayer <[hidden email]> wrote:

>
>
>
>
> ---- On Wed, 03 Nov 2010 11:28:13 -0700 Hannes Hirzel  wrote ----
>
>>Is XMLWriter in the upcoming 1.2 image? It is not in the 1.1 image.
>>
>>--Hannes
>
> The new XML writer is in the more recent versions, from version 96 on, but
> at the moment you have to download it manually through Monticello or from
> the XMLSupport page on squeaksource.com, as the most recent Metacello
> configuration still points to v. 93. I'll try to update it shortly.
>
>
>

Reply | Threaded
Open this post in threaded view
|

Re: Writing API for XML (WAX) - Bibliography example

jaayer




---- On Sat, 06 Nov 2010 03:36:11 -0700 Hannes Hirzel  wrote ----

>Jaayer,
>
>Thanks, I checked out
>
>MCHttpRepository
> location: 'http://www.squeaksource.com/XMLSupport' 
> user: ''
> password: ''
>
>and looked at
>XML-Parser-tg.101
>
>
>Right version?

Yes.