Transforming file compliant with Xml Schema A into a file compliant with XML schema B using XSLT -


i have searched question, seems fiendishly hard express problem involving xsl in words, i've come nothing.

the problem have thus:

a company produces application uses xml files store 'documents'. these files enforced against schema version 1.1

however, company decides release new version of software validates against new schema different structure, schema 1.2

in order customer seamlessly use new version, want programmatically convert 1.1-compliant files 1.2-compliance on file open. ideally, using xsl transformation.

of 2 schemas, types identical, types have new or renamed members, , stored in totally different structure. therefore writing transformation 1 other quite tedious, , maintaining more so.

it nice write kind of transform-generating transform can match unchanged types old schema new one, , emit placeholder elements (<xsl:message> elements, example) wherever can't so, in order prompt developer write custom logic hand it's needed, guarantee everywhere else compliant.

so procedure goes:

  • run transform against schema 1.2. generates transform b;
  • run transform b against schema 1.1. matches schema 1.2 schema 1.1 possible, producing transform c;
  • transform c used skeleton developer write watertight transformation instance 1.1 instance 1.2.

i have gotten fair way through implementing this, few particulars of xslt 1.0 causing me problems.

transform b requires automatic generation of <xsl:call-template> statements typename of each element encountered pencilled name attribute. correctly run transformation logic each type in order generate transform c.

however, call-template not seem accept xpath syntax whatsoever. insists name must contain nmtoken , nmtoken only. can understand design point of view it's quite irritating, because want run logic on element based on type, not name. i'd state call-template name="@type" inside xsl:template match="element" template. stage 1 generation ensures matching named template exist call.

i not sure how proceed. has tried before? there fundamental theory of computer science declares isn't possible in declarative syntax? (i hope not!)

i hope explanation clear. i'll post code if not.

firstly, there number of tools on market attempt generate transformations based on source , target schema, , graphical tools define relationship between them. personally, i've had little joy these tools, people seem them, give them try. examples can found in popular xml tools such xml spy , stylus studio.

secondly, seems odd trying use xsl:call-template this. it's case rule-based transformation using template rules , xsl:apply-templates. mechanism dispatching based on element's type apply-templates rather call-template. in xslt 2.0 can you're asking directly schema-aware stylesheet has rules of form

<xsl:template match="element(*, type-name)"> 

where type-name name of type in schema.


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -