如何从 XML 样本生成 XSLT [英] How to generate XSLT from XML samples

查看:80
本文介绍了如何从 XML 样本生成 XSLT的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种用于半自动 XSLT 生成的工具.

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

给定 2 个 XML 文件,来源:

Given 2 XML files, source:

<elm>XXX</elm>

和目标:

<exx>XXX</exx>

该工具应生成 XSLT 文件,该文件从源生成目标.查看内容,它应该识别级别、位置、元素名称等方面的变化.对此没有通用的解决方案,但我只需要简单的转换.

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.

可能的实现:

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"

如果发生冲突,则需要手动干预.冲突可能是XXX",而不是源代码.

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

如果该工具也能识别 XSD/DTD,那就太好了,例如进行手动字段"映射.

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

编辑:澄清.

推荐答案

我怀疑即使是简单的转换规则也能自动生成.

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

以 XML 为例

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

和目标

<person>Paul</person>

这应该是一个很常见的组合.我什至无法手动决定(没有想要转换的人的帮助)目标 > 是从哪个标签创建的,来自 > 还是 <child> 所以我怀疑应用程序会在这里产生一些理智的东西.

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.

更新:如果某种形式的拖放 XSLT 生成适合您,那么有一些商业产品可用,但它们无法从目标文件生成 XSLT.但是拖放至少应该是比完全手工编写更好的解决方案:

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:

这篇关于如何从 XML 样本生成 XSLT的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆