Re: Writing XML

2011-02-08 Thread Ary Manzana
On 2/6/11 8:32 PM, spir wrote: When does one need to write by hand, in source, structured data needing to be serialised into XML (or any other format)? In my (admittedly very limited), such data always are outputs of some processing (if only reading from other file). denis If you have a

Re: Writing XML

2011-02-08 Thread spir
On 02/08/2011 07:44 PM, Ary Manzana wrote: On 2/6/11 8:32 PM, spir wrote: When does one need to write by hand, in source, structured data needing to be serialised into XML (or any other format)? In my (admittedly very limited), such data always are outputs of some processing (if only reading

Re: Writing XML

2011-02-08 Thread Russel Winder
On Wed, 2011-02-09 at 00:16 -0600, Christopher Nicholson-Sauls wrote: [ . . . ] xml.book(...) as sugar for xml.tag(book,...) make it xml.bookTag(...) using xml.bookTag would ruin it for me. I'd use something that allowed just book, xml.book is already not enough of a DSL. -- Russel.

Re: Writing XML

2011-02-07 Thread Russel Winder
I am coming in half way through a thread, apologies if I am saying something that has already been said or is not relevant. On Sun, 2011-02-06 at 22:59 +0100, Rainer Schuetze wrote: Tomek Sowiński wrote: auto xml = xmlWriter(outputRange); xml.comment(books.length, favorite books of

Re: Writing XML

2011-02-07 Thread Russel Winder
A couple of other random thoughts regarding XML: 1. Groovy has XMLSlurper which is an surprisingly fast way of reading XML and processing it as needed. It was developed for fast SAX-underneath, document-based but not-W3C-DOM processing of multi-Gigabyte XML documents.

Writing XML

2011-02-06 Thread Tomek Sowiński
While I'm circling the problem of parsing, I took a quick look at writing not to get stuck in analysis-paralysis. Writing XML is pretty independent from parsing and an order of magnitude easier to solve. It was perfect to get myself coding. These are the guidelines I followed: * Memory

Re: Writing XML

2011-02-06 Thread Jacob Carlborg
On 2011-02-06 15:43, Tomek Sowiński wrote: While I'm circling the problem of parsing, I took a quick look at writing not to get stuck in analysis-paralysis. Writing XML is pretty independent from parsing and an order of magnitude easier to solve. It was perfect to get myself coding

Re: Writing XML

2011-02-06 Thread Andrei Alexandrescu
On 2/6/11 9:43 AM, Tomek Sowiński wrote: While I'm circling the problem of parsing, I took a quick look at writing not to get stuck in analysis-paralysis. That's great. I won't be able to add much because I haven't worked with XML so I don't know what people need. The example looks nice and

Re: Writing XML

2011-02-06 Thread Rainer Schuetze
Tomek Sowiński wrote: auto xml = xmlWriter(outputRange); xml.comment(books.length, favorite books of mine.); foreach (book; books) { xml.book(year, book.year, { foreach (author; book.authors) { xml.tight.authorName({ xml.first(author.first);

Re: Writing XML

2011-02-06 Thread Jonathan M Davis
On Sunday 06 February 2011 13:59:19 Rainer Schuetze wrote: Tomek Sowiński wrote: auto xml = xmlWriter(outputRange); xml.comment(books.length, favorite books of mine.); foreach (book; books) { xml.book(year, book.year, { foreach (author; book.authors) {

Re: Writing XML

2011-02-06 Thread spir
On 02/06/2011 10:59 PM, Rainer Schuetze wrote: This looks nice and compact Using opDispatch to specify the tag (I guess that is what you are using to create a tag book by calling xml.book()) feels like misusing opDispatch, though. Does it add readability in contrast to passing the tag as a

Re: Writing XML

2011-02-06 Thread Adam D. Ruppe
On Mon, Feb 07, 2011 at 12:23:45AM +0100, spir wrote: How do you write a tag named tight? Or a tag calculated at runtime? Call opDispatch directly ;-) You can't call opDispatch with a runtime string; it needs to be a template parameter. The way I do it is: string createNode(string name) {

Re: Writing XML

2011-02-06 Thread spir
On 02/06/2011 03:43 PM, Tomek Sowiński wrote: While I'm circling the problem of parsing, I took a quick look at writing not to get stuck in analysis-paralysis. Writing XML is pretty independent from parsing and an order of magnitude easier to solve. It was perfect to get myself coding

Re: Writing XML

2011-02-06 Thread Tomek Sowiński
Rainer Schuetze napisał: This looks nice and compact Using opDispatch to specify the tag (I guess that is what you are using to create a tag book by calling xml.book()) feels like misusing opDispatch, though. Does it add readability in contrast to passing the tag as a string to some