Rename global entities in an XML Schema
Please, please, please tell me I'm over thinking this.
I'm using OxygenXML 11.2 which uses Saxon PE, HE, or EE for transformations.
I have a set of schemas to define the structure of some XML I'm developing. There are 3 schemas in the set, one is considered the 'base' schema and it imports the next, which in turn imports the last. Each schema has it's own namespace definition. I tend to write my schemas using global entities (elements, attributes, types, groups) and access them through references.
The problem I have is a customer has come along and want to generate Java code from the schemas using something called Castor. I don't know much about Castor, except that it generates Java classes based on global entities defined in the schema.
Castor apparently does not understand namespaces very well and some of the element names I've chosen are already in use by the customer in other XML areas (elements like 'table', and types like 'alpha-numeric') which is why I used namespaces in the first place.
So the customer wants me to rename all my elements to have a unique name. I don't really want to do this as it would affect all my XSLT code, XML files and schemas. So I told them I would use a script to generate custom schemas for them from my schemas and prefix all global entities with a string of their choosing (they chose 'nms_' as they are a network management system) and deliver these schemas to them to use with Castor.
So I did pretty well with renaming elements using a basic recursive 'copy' template as laid out in the XSLT 2.0 3rd edition by Mr. Kay. I've got a few templates to override the straight copy so I can insert the new element names where needed. I leave all non-global element names alone and only change the global names and the references to them.
I suspect attributes and groups will be just as easy.
It starts getting tricky with the types. To do these I need to locate the global types, then search through the sheet to find anything that is referencing it and change the names.
I also need to know if a type is referencing a definition in another namespace and deal with that correctly. Not impossible, but it sounds like a lot of code to me.
As I said, I hope I'm over thinking this and there is really a simpler way to do this.
Please?
Thanks,
Michael Hare
__________________
------------------------
Keep Moving Forward
GnuPG Key fingerprint = 1AD4 726D E359 A31D 05BF ACE5 CA93 7AD5 D8E3 A876
Michael Hare
|