XML.registerObjectMarshaller and xml dsl help

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

XML.registerObjectMarshaller and xml dsl help

m!ke410
Hello all,

I saw a post a few weeks back that mentioned registering a marshaller i the bootstrap and I really liked the idea.  I setup one for a class but I ran into a small problem with I seem to figure out.  I'd like the xml to look like:
<facility id="1"><name>Something</name></facility> 
But I can't figure out how to get the id in the root node.

def init = { servletContext ->
XML.registerObjectMarshaller Facility, { facility, converter ->
converter.build {
id:facility.id 
name(facility.name)
}
}
}


This just ignores the id.  I've tried other variants but with no success.  What am I doing wrong?

Is there documentation somewhere on how to use the xml dsl?  I been looking and I can't find a good resource.

~mike





Reply | Threaded
Open this post in threaded view
|

Re: XML.registerObjectMarshaller and xml dsl help

Siegfried Puchbauer
Hi Michael,

it can be solved that way:

def init = { servletContext ->
XML.registerObjectMarshaller Facility, { facility, xml ->
xml.attribute 'id', facility.id
                xml.build {
}
}
}

or you could implement a real ObjectMarshaller<XML> like the default one for DomainClasses: see http://tinyurl.com/myzujq

The API docs for the XML Converter can be found here: http://grails.org/doc/1.1.1/api/grails/converters/XML.html

hth

Cheers, Sigi
_______________________
Siegfried Puchbauer
http://siegfried.puchbauer.com/


On Fri, May 29, 2009 at 04:13, Michael Fortin <[hidden email]> wrote:
Hello all,

I saw a post a few weeks back that mentioned registering a marshaller i the bootstrap and I really liked the idea.  I setup one for a class but I ran into a small problem with I seem to figure out.  I'd like the xml to look like:
<facility id="1"><name>Something</name></facility> 
But I can't figure out how to get the id in the root node.

def init = { servletContext ->
XML.registerObjectMarshaller Facility, { facility, converter ->
converter.build {
}
}
}


This just ignores the id.  I've tried other variants but with no success.  What am I doing wrong?

Is there documentation somewhere on how to use the xml dsl?  I been looking and I can't find a good resource.

~mike






Reply | Threaded
Open this post in threaded view
|

Re: XML.registerObjectMarshaller and xml dsl help

m!ke410
Thanks, Sigi

That's it.  Is there documentation for this somewhere?

~mike





On May 29, 2009, at 4:02 AM, Siegfried Puchbauer wrote:

Hi Michael,

it can be solved that way:

def init = { servletContext ->
XML.registerObjectMarshaller Facility, { facility, xml ->
xml.attribute 'id', facility.id
                xml.build {
}
}
}

or you could implement a real ObjectMarshaller<XML> like the default one for DomainClasses: see http://tinyurl.com/myzujq

The API docs for the XML Converter can be found here: http://grails.org/doc/1.1.1/api/grails/converters/XML.html

hth

Cheers, Sigi
_______________________
Siegfried Puchbauer
http://siegfried.puchbauer.com/


On Fri, May 29, 2009 at 04:13, Michael Fortin <[hidden email]> wrote:
Hello all,

I saw a post a few weeks back that mentioned registering a marshaller i the bootstrap and I really liked the idea.  I setup one for a class but I ran into a small problem with I seem to figure out.  I'd like the xml to look like:
<facility id="1"><name>Something</name></facility> 
But I can't figure out how to get the id in the root node.

def init = { servletContext ->
XML.registerObjectMarshaller Facility, { facility, converter ->
converter.build {
}
}
}


This just ignores the id.  I've tried other variants but with no success.  What am I doing wrong?

Is there documentation somewhere on how to use the xml dsl?  I been looking and I can't find a good resource.

~mike







Reply | Threaded
Open this post in threaded view
|

Re: XML.registerObjectMarshaller and xml dsl help

Siegfried Puchbauer
Not yet unfortunately :-/ I'll do my best to catch up for the next release.

Cheers, Sigi
_______________________
Siegfried Puchbauer
http://siegfried.puchbauer.com/


On Fri, May 29, 2009 at 13:55, Michael Fortin <[hidden email]> wrote:
Thanks, Sigi

That's it.  Is there documentation for this somewhere?

~mike





On May 29, 2009, at 4:02 AM, Siegfried Puchbauer wrote:

Hi Michael,

it can be solved that way:

def init = { servletContext ->
XML.registerObjectMarshaller Facility, { facility, xml ->
xml.attribute 'id', facility.id
                xml.build {
}
}
}

or you could implement a real ObjectMarshaller<XML> like the default one for DomainClasses: see http://tinyurl.com/myzujq

The API docs for the XML Converter can be found here: http://grails.org/doc/1.1.1/api/grails/converters/XML.html

hth

Cheers, Sigi
_______________________
Siegfried Puchbauer
http://siegfried.puchbauer.com/


On Fri, May 29, 2009 at 04:13, Michael Fortin <[hidden email]> wrote:
Hello all,

I saw a post a few weeks back that mentioned registering a marshaller i the bootstrap and I really liked the idea.  I setup one for a class but I ran into a small problem with I seem to figure out.  I'd like the xml to look like:
<facility id="1"><name>Something</name></facility> 
But I can't figure out how to get the id in the root node.

def init = { servletContext ->
XML.registerObjectMarshaller Facility, { facility, converter ->
converter.build {
}
}
}


This just ignores the id.  I've tried other variants but with no success.  What am I doing wrong?

Is there documentation somewhere on how to use the xml dsl?  I been looking and I can't find a good resource.

~mike