How to generate XSLT from XML samples

81,826

I doubt that even simple transformation rules are possible to be generated automatically.

For example take the XML

<family>
  <father>Paul</father>
  <mother>Maria</mother>
  <child>Paul</child>
</family>

and the target

<person>Paul</person>

which should be a quite common combination. I could not even manually decide (without help from the one wanting the transformation) from which tag the target <person> has been created, from <father> or <child> so I doubt that an application would produce something sane here.

Update: If some sort of drag&drop-XSLT-generation would be ok for you, there are some commercial products available, but they cannot produce XSLT from a target file. But drag&drop should be at least a better solution than writing it completely by hand:

Share:
81,826
Jan B. Kjeldsen
Author by

Jan B. Kjeldsen

X++ system developer. X++ is a Java like language for Microsoft Dynamics AX (former Axapta).

Updated on September 21, 2020

Comments

  • Jan B. Kjeldsen
    Jan B. Kjeldsen over 3 years

    I am looking for a tool for semi-automatic XSLT generation.

    Given 2 XML files, source:

    <elm>XXX</elm>
    

    and target:

    <exx>XXX</exx>
    

    The tool should make the XSLT file, which produces the target from the source. Looking at the content, it should identify changes in level, placement, element names etc. There is no general solution to this, but I would need simple transformations only.

    Possible implementation:

    1. scan the source, map XML data "XXX" to element path "elm"
    2. scan the target, map XML data "XXX" to element path "exx"
    3. output target XML structure, output XSLT mapping of "XXX", "elm" -> "exx"
    

    In case of conflicts manual intervention is needed. A conflict could be "XXX" in more than on place in source.

    It would be nice if the tool was XSD/DTD aware also, for example to do manual "field" mappings.

    Edit: clarification.

  • Jan B. Kjeldsen
    Jan B. Kjeldsen over 15 years
    Question clarification: in case of conflicts manual interventions is needed.
  • Jan B. Kjeldsen
    Jan B. Kjeldsen about 15 years
    I ended up writing the XSLT myself, using Stylos Studio, as you suggested, thanks. Stylus Studio has an XSLT mapper, but in my case it was useless as it was element to element mapping only and I needed to select on attributes as well. But it has a nice interface including debugging. But you still need to understand XSLT and XPath to really use the thing.
  • Blackvault
    Blackvault over 8 years
    The link to Tiger XSLT Mapper is now dead at the time of writing this comment Feb 2016