[xsd-users] Preserving XML element order

Barrie Kovish barrie.kovish at singularsoftware.com
Wed Feb 17 19:08:24 EST 2010


Boris,

How do I customize the object model?  I had actually wanted to do something like the following:

class angle: public ::xml_schema::type, public MyClass<angle> 

Then I can use class template specialization to add specific methods to various Code Synthesis generated classes.  I tried using some of the command line regex options but couldn't figure out how to do it (or if it can be done).  It would be a problem to modify the Code Synthesis generated classes by hand because we may still update the schema.

Thanks,

Barrie

Thanks.  
On 2010-02-15, at 8:02 AM, Boris Kolpackov wrote:

> Barrie,
> 
> Barrie Kovish <barrie.kovish at singularsoftware.com> writes:
> 
>> I know that in one case we need to insert complex elements to a series 
>> of similar elements.  Likely in the future we would need to do the same 
>> plus perform some sort of fix up of other elements which were dependent 
>> upon the element order.  For example
>> 
>> Starting XML:
>> <A>x</A>  <!-- implicit index 1-->
>> <A>y</A>  <!-- implicit index 2-->
>> <A>z</A>  <!-- implicit index 3-->
>> 
>> Changed XML:
>> <A>x</A>  <!-- implicit index 1-->
>> <A>y</A>  <!-- implicit index 2-->
>> <A>u</A>  <!-- implicit index 3-->
>> <A>z</A>  <!-- implicit index 4-->
>> 
>> Other elements in the file will contain the 1, 2, and 3.  We will need to 
>> fix them up to have the new and correct indices.  The contents x,y,z, u 
>> can also be complex or simple elements.
> 
> I see several ways how this can be done fairly easily with the 
> substitution group approach[1]. For example, you could customize 
> the object model to maintain a map of "first complex element" 
> (i.e., the element with actual content) to all the "referencing
> elements" (i.e., the elements with just the id). This map would 
> be stored in the root of the object model. The complex elements 
> would then automatically add themselves to this map. Once you 
> need to adjust the id of some element and all its references, 
> you can use this map to quickly find all the places that need
> changing. 
> 
> [1] http://www.codesynthesis.com/pipermail/xsd-users/2008-May/001697.html
> 
> Boris



More information about the xsd-users mailing list