Thanks for the suggestion. Not only is the content of "Auto" variable, but "Auto" itself is variable. It could just as easily be "car" or "truck" with a completely arbitrary structure and content at runtime. I am able to load a Java class which tells what that structure is, what the content will be and so on.


What I am working on is part of the UI for a MetaSchema product which, among other things, helps synch MetaSchemas for various databases, ontologies, taxonomies and so on. This part of the response we get from our server lets our user define an arbitrary extension structure for any of our first order objects - from which I must create a UI which allows them to navigate the structure and edit the content. They can't change the structure in my UI, but they can add/delete predefined elements up to/down to a predefined number of elements (defined in the structure I am given).

So anyway, I managed to extend the GeneralizedFieldHandler and use the ANyNode to create a List which contains the elements and their content (which may be another list of elements). It is much easier to understand than a HashMap - at least for me.

I do need to parse the whole structure all the way - there is nothing in there that I am not interested in. Last night it occured to me that it might be worthwhile to put this whole thing into something like a lightweight DOM - like JDOM, where I could search it easier(?). There may be a need for searching through the structure using something like an XPath statement.

Now I need to populate the UI and then convert the UI back to the List.

Andrew Fawcett wrote:
Lauren,

Have you tried describing your XML in XML Schema?

It has a facility for this type of thing in the form of the <xsd:any>
element.


If you take an XML Schema and run it through the Castor Source Generator
it will produce the classes and the descriptiors (can be thought of as
compiled time mappings) for you.


Given your example, if for example the element content of <auto> is
variable then an XML Schema as follows will generate a class that uses
the Castor AnyNode class to describe your variable content.

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema";
elementFormDefault="qualified" attributeFormDefault="unqualified">
        <xs:element name="auto">
                <xs:complexType>
                        <xs:sequence>
                                <xs:any/>
                        </xs:sequence>
                        <xs:attribute name="color" type="xs:string"/>
                        <xs:attribute name="make" type="xs:string"/>
                </xs:complexType>
        </xs:element>
</xs:schema>

If you then determine after an initial unmarshalling to further
unmarshall the variable content into a more specific class.


You can then pass the AnyNode content to another Castor Unmarshaller to
obtain the object you really want.

Cheers,

Andy.   




----------------------------------------------------------- If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-user

Reply via email to