From: David H. <dav...@bl...> - 2004-09-07 18:26:14
|
Sean O'Dell wrote: > On Tuesday 07 September 2004 07:42, Clark C. Evans wrote: > >>Clearly, if one 'transforms' the graph on the way in, the 'schema' >>is being altered, so if one wishes to round-trip, a reverse transform >>on the way out would be required to convert the data structure back. >>But this, once again, is an application-specific thingy. > > Schemas, I thought, are for validation and wouldn't alter the graph in any > way. A set of transformation rules would be something different from a > schema, and it would probably do nothing more than re-tag nodes, so it should > be re-emittable all the way back from the fully loaded state. As it happens, once you have the mechanisms needed to validate a graph, very little additional mechanism is needed to transform it. A schema language essentially parses the graph, yielding a parse tree in which each parse tree node corresponds to a graph node. At that point you have all the information needed to fill in unspecified types: for each node, the schema production tells you what kind of node it "should" be. In simple cases, all you then need is a mapping from schema productions to tags, which is used to change any unspecified tags. In more complicated cases, the API could call an application-provided function depending on the production for each node. -- David Hopwood <dav...@bl...> |