tags:

views:

6486

answers:

3

I am looking for at tool for semi automatic XSLT generation.

Given 2 XLM 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 interventions 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.

+3  A: 

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:

Kosi2801
Question clarification: in case of conflicts manual interventions is needed.
Jan B. Kjeldsen
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.
Jan B. Kjeldsen
A: 

I wonder if such a tool would solve the halting problem...?

Guess not, it does not need to.
Jan B. Kjeldsen
A: 

Have you checked Altova MapForce? It is not freeware, but I believe it handles what you're looking for. http://www.altova.com/mapforce.html

Skaue
Looks similar to Stylus Studio 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. Like: <X:field name="abc"> to map to: <verylongnameABC>. I did not try MapForce, so maybe I am wrong. Grafical field mappers look pretty confusing too when applied to +30 fields. I guess there is no easy solution.
Jan B. Kjeldsen
MapForce is very strong, and I am pretty sure you can map attributes to tags. I have only tried the demo once to let the software generate an XSLT for me. It's a very strong (and expensive) tool, but I am 99% sure it will cover your needs. It can even produce XML to EDI conversion XSLT.
Skaue