tags:

views:

116

answers:

2

Let's say I have a system that stores data for some complex objects in xml. These objects have a weak inheritance relationship: maybe 4 fields common to all of them and then another 20 that are unique to each type of object, say 6 to 8 different types of object.

The data that is unique to each object may itself be complex: things like enums, other complex types, and items that are only used conditionally. Each type of object has an xml schema to describe it.

This system builds up a record for each object over a series of steps, and so it will be very common to have only a partial record. What goes into each step is not defined: a user may fill in as much as they know and then pass it up the chain for someone more knowledgeable to complete.

What I want to do is create an ASP.Net page to show these records. Given a record number (and type) load the schema for that type into a form, and then populate the form from the record itself. I don't think the record by itself will be enough to create the page, because the record may not yet list each field I want to include on the form and won't implicitly include data for types like enums.

What would be an elegant way to accomplish this? I'm sure I'm missing something obvious about a simple way to do this, but Xslt probably won't cut it.

This is a follow up to this question, and at the moment is purely hypothetical. Based on responses here I may go a different way completely.

+1  A: 

When you say "Xslt probably won't cut it", I'm wondering which Xslt approach you have in mind.

One approach would be to somehow transform the instance data for the form. (I'm not sure how that would work in practice, and maybe that's why you said Xslt wouldn't work.)

Another approach would be to use Xslt to produce a customized, one-off schema that's tailored for the current state of the form data. You'd then use this schema to build the form. For example, the transformed schema would exclude definitions for fields that aren't ready for display yet. This sounds quite feasible to me (not that I'm volunteering :-)

UPDATE (responding to comments): Tell the truth, I don't know asp.net well enough to say if its caching would be suitable for your needs. I'd have thought that you don't want caching, for reasons that I'll get to.

To try to clarify what I meant: What I was hearing in your description is that the current state of the record may affect the structure of the form. For example, the legal values for field A may be constrained by the values of fields X, Y, and Z, some of which may actually be unknown and unknowable at a given time; this ambiguity might make it difficult to present the form using a single, unified structure.

My thought was that perhaps you don't have to limit yourself to an immutable schema. If the current state of the data would be better represented by a modified schema (e.g., one that reflects the allowed enumeration values for field A, or the union choice that is currently allowed for field B), then I proposed that perhaps transforming the schema before creating the form might do the trick. To your comment about caching, I'd be concerned that caching might result in stale form definitions being served up when newer ones are needed, due to changes to the data and the schema. Perhaps you could avoid this by permuting the namespace URL based on the current state of the customized schema.

I hope this helps.

Dan Breslau
I need to always show all fields, even if there's no data yet. The transform of a record would exclude those fields and the transform a schema and adding record data later would likely be more complex than just building it.
Joel Coehoorn
Or are you suggesting building a template from the schema on first demand, and then letting ASP.Net cache it? Hmm... there might be something to that.
Joel Coehoorn
A: 

Maybe try using WSDL2XForms to get XForms for the schema. Then render these XForms to HTML with Chiba equivalent (this one is a java webapp, but i guess you could find an ASP counterpart).

erwinston