Stevo,
Stevo Slavić wrote:
> Hello all,
>
> Is it possible to define castor mapping so that castor, when
> unmarshalling XML, takes into account element namespace? E.g. if there
> are two elements both with same element name but belonging to different
> namespace a different OXM mapping should be used; similarly for all
> nested elements. Example XML snippet follows:
>
> <database>
> <table xmlns:ns1="table1">
> <description/>
> <row />
> <row />
> </table>
> <table xmlns:ns1="table2">
> <description/>
> <row />
> <row />
> </table>
> </database>
I can see what you are trying to do, but Castor - by the means of a
mapping file - allows you to define one mapping per Java class only.
Having said that, this does not prevent you to define more than one Java
class that are mapped against the same XML artefacts.
> Database class has collection of Table<?> classes, while table element
> with table1 namespace (and all it's nested elements) should be mapped in
> one way, e.g to a Table1 class (extends Table<Row1>) while table element
> with table2 namespace should be mapped to Table2 class (extends
> Table<Row2>).
If you happen to have an extension hierarchy, you should be able to get
this working, though.
> I've thought that if I map tables property of Database class to Table
> class binding it to table XML element without mentioning namespace, and
> then define mapping for each Table specialization binding each of them
> to table XML element and their specific ns-prefix and ns-uri, it would
> work, but it doesn't.
Can you show me the relevant mapping fragments ?
Regards
Werner
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email