---- On Tue, 06 Jul 2010 03:19:48 -0700 Torsten Bergmann  wrote ---- 

>Just check "XMLWriter-tbn.5" which can be found in 
>"http://squeaksource.com/PharoGoodies/"; 
> 
>------------------------------------------------------ 
>|writer| 
>writer := XMLTagWriter xml. 
>writer comment: 'A new xml file'. 
>writer tag: 'package' with: [ 
>    writer cData: 'name' with: 'XMLWriter'. 
>]. 
>writer contents 
> 
>returns 
> 
> 
> 
> 
>  
> 
>------------------------------------------------------ 
> 
>You can also access the stream (writer stream). 
>Indenting is not yet working fully but at least 
>it should give you idea. Check out the test cases for 
>more. 
> 
>I once saw such an XMLWriter written by Ernest Micklei 
>in VAST (credits for the idea) and rebuilt it in Pharo. 
> 
>Bye 
>T. 
>-- 
>GMX DSL: Internet-, Telefon- und Handy-Flat ab 19,99 EUR/mtl. 
>Bis zu 150 EUR Startguthaben inklusive! http://portal.gmx.net/de/go/dsl 
> 
>_______________________________________________ 
>Pharo-project mailing list 
>Pharo-project@lists.gforge.inria.fr 
>http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project 
> 

The next version of XMLSupport will feature an XMLWriter with an API similar to 
XMLTagWriter. I had decided a few weeks that any API using explicit start/end 
methods was unsmalltalk-like and should be replaced with one based on 
execute-around methods, though I was unaware of XMLTagWriter and instead 
modeled the API loosely on Seaside's HTML generation. You now send XMLWriter 
messages that create markup-writing objects for the parts of a document. These 
objects can then be configured using messages like #attributeAt:put: and 
written to the document explicitly with a serialization message (which 
typically accepts content) or implicitly by creating another markup writer 
after it. The new API looks like this:

        | writer |
        ((writer := XMLWriter new)
                enablePrettyPrinting;
                xmlDeclaration;
                tag: 'foo')
                        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']]
which produces:
 <?xml version="1.0" encoding="UTF-8"?>
<foo xmlns:foo="http://foo"; a="one" b="two">
    <bar>test<baz />
        <foobar>test</foobar>
    </bar>
</foo>


_______________________________________________
Pharo-project mailing list
Pharo-project@lists.gforge.inria.fr
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project

Reply via email to