All 3 entries tagged XML
View all 7 entries tagged XML on Warwick Blogs | View entries tagged XML at Technorati | There are no images tagged XML on this blog
July 17, 2006
BooML Source Online
Follow-up to BooML SourceForge Project Pending from codeMonkey.Weblog();
The source for BooML is now online. The project is hosted by SourceForge. link
So far I've just got the source into SubVersion. I'm so busy at the moment (too many pies, not enough fingers!) – but I really must get some docs online too.
July 01, 2006
BooML SourceForge Project Pending
Follow-up to BooML – Language Integrated XML in Boo from codeMonkey.Weblog();
I have submitted a project request to SourceForge for BooML. I hope it is processed faster than Specter was!BooML – Language Integrated XML in Boo
Creating XML using the .NET XmlWriter object model tends to make your code look awful. I realised that using some mackery I could make Boo support creating XML right in the language. Thus was born "BooML"
Here is a little example.
import System
import System.IO
import System.Xml
import BooML
class Book:
[property(Title)]
private _title as string
[property(Author)]
private _author as string
def GetBooks():
return [
Book(Title: "Foo Bar", Author: "Bob Smith"),
Book(Title: "Test Title", Author: "Andrew Davey")
]
[XmlLiteral()]
def GetBooksXml(books):
books:
for book as Book in books:
book:
@id = book.GetHashCode()
title book.Title
author book.Author
xml = GetBooksXml(GetBooks())
print xml.ToString() The resulting XML is:<?xml version="1.0" encoding="utf-8"?>
<books>
<book id="54267293">
<title>Foo Bar</title>
<author>Bob Smith</author>
</book>
<book id="18643596">
<title>Test Title</title>
<author>Andrew Davey</author>
</book>
</books> The magic is in the XmlLiteral AST Attribute. It transforms macros (in the example: books, book, @id, title and author) into XML macros. The XML macros then in turn create the XmlTextWriter calls.
I think this could be a really powerful language enhancement for people doing web development who want to return abitrary XML from methods.
I may start a SourceForge project to open source the development.
Please wait - comments are loading

Loading…

