views:

118

answers:

1

Whats the fastest or perhaps optimal way to read elements, node, attributes from a source class, which represents a chunk of xml, and write then back into a resultant class from the same schema.

I've got a requirement for a way to read incoming xml messages, parse them with this xpath path expression language we have invented, and then write into to a resultant composite xsd generated class. Both classes are the schema. The schema allows 1.n for certain nodes, but in general the schema is very well designed and is fairly flat.

A: 

You'll have to do this via XML, before the XML is deserialized into the objects.

John Saunders
Why do you need to do that. Sure it is easier to parse up an down an object than it is xml.
scope_creep
How do you append objects? If the objects are simple enough, you can, for each collection, add all the elements from the second object's collection to the first objects collection. Much easier to do in XML before it's parsed.
John Saunders
Funny, I spoke to somebody else a few days ago, who echoed your advice. I guess it that way then.Bob.
scope_creep
John, This is one possible approach. You have a schema, which is IETF designed You create the xsd generated classes. Then you use an xslt transformation to extract all the xpath definitions out of it, essentially flattening it. Then use the xpath defintions to create a table drive FSM, where each element combination has an action->delegate, or something similar to that. You are passed a xpath by incoming xml message, you do a lookup into the table, and delegates fire to lift the xml out of the incoming xml. Is that feasible?
scope_creep
Which xpath definitions are you referring to? And did you realize you can use an XSLT to merge documents? That would seem to be easier: merge the two XML documents, then deserialize the result.
John Saunders