Keith Visco wrote:
>Using the Mapping file you can simply leave out fields that you don't
>want to show up in the generated XML. Therefore you can toggle between
>different mapping files depending on your needs.
good idea... putting the "level of detail" attributes in the mapping file
and generating new mapping xml from that using xsl. Going to try that out.
Didn't realise that unspecified elements would be left out... I thought the
default mapping would then kick in.
Keith Visco wrote:
>I am not really sure how you would automatically determine how much
>detail someone would want. For example what does "LOW_DETAIL" really
>mean? What "detail" does it leave out?
I don't automatically decide that. When a client calls the "listPeople"
service on my server, the listPeople service knows that the client only
needs the name and ssn. In the mapper, LOW_DETAIL is defined per class so
when you call the Person mapper he will only write out fields that have been
defined as a part of the LOW_DETAIL package.
Here is the method from the PersonXmlMapper:
public void mapObjectToXml(XmlMappableObject obj, Document document, Element
element, int levelOfDetail) throws Exception
{
Person person = (Person) obj;
if (levelOfDetail >= AbstractXmlMapper.LOW_DETAILS)
{
mapObjectFieldToXml(person, "ssn", element);
mapObjectFieldToXml(person, "name", element);
// more fields here
}
if (levelOfDetail >= AbstractXmlMapper.FULL_DETAILS)
{
mapObjectFieldToXml(person, "dateOfBirth", element);
mapObjectFieldToXml(person, "nationality", element);
// more fields here
addressMapper.mapCollectionToXml(person.getAddresses(),
element);
}
}
So, now you know why I want to go from this code, with xml elements all over
the code and the structure of the xml hardcoded in the class hierarchy ;-)
But the level of detail is quite necessary for us so that the xml doesn't
get too big. E.g. when we want to see the xml representation of a
reservation, we don't want all the addresses of every attendant to come with
it. We just want the name of the attendants and their id's, so that the
client can then request the full details of a person if he wants. In which
case he will make a call to the server again.
Keith Visco wrote:
>but this seems like something highly specific to your case.
I thought not. Does everyone always want all the xml of an object and all
the xml of the objects that are contained in that object??? Of course we
could always produce the whole xml and use xsl to make it smaller
afterwards, but that sounds like overhead. And I'm not even sure that this
is more complicated.
Thanks for you time!
regards,
Gauti
PS. If you guys have any other ideas on how I could solve this... feel free
;-)
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev