开发者

Generating XSL from XML

Can I create an XSL file from existing XML file?

From comments:

My requirement is as follows: I have an existing xsl file which transforms XML1 to XML2. The XSL is created by a college of mine and the resource no more available. I have source and I know how the target should look like. But I do not know how to XSL. Hence I want to use the target xm2 to generate XSL for me.

开发者_高级运维


The answer is the same as for the question that is obtained from this one by replacing XSL with program and XML with data.

Generally, it is not possible to have a program that would automatically create another program that, given any input data will produce the coresponding correct result.

The answer, of course, is: NO.

If this were possible, then the profession of computer programmer would not exist.

Not to mention, that a finite number of inputs and their corresponding outputs don't define a single function. If we have a finite set of functions that satisfy this finite sample-set and then add just one more sample to it, it may be the case that none of our functions satisfies the new sample-set, and yet there would be still possibly an infinite number of new functions that satisfy the new sample-set.


Sarma, I agree with mikerobi that you can't just automatically generate the XSLT from the source XML and destination XML. However, if the transform is not too complicated, some XSLT mapping tools may help.

Axizon (Tiger), Stylus Studio, and Altova and all offer XSLT mapping tools, with free trial editions. If it were me I would probably try them in that order. See also Tools for XSL.

However, tools that claim to be able to do the programming for you usually only work in limited situations. If the above don't work, you can take a stab at the XSLT yourself, and come here with specific questions if you run into problems.


Yes and No. You can definitely paste all of the xml from one file into an xsl, so that executing the xsl file will return the original xml document, but that isn't very usefull.

If you are looking for a way to automatically generate an xsl transform that will transform document X into document Y, then the answer is definitely no.


The short answer is no. (But like LarsH said there are tools but the odds of them helping could be low.)

If I were you. I would run the source through the XSL that you college wrote and see if the output is close to what is desired. If it is perhaps there are only a few tweeks needed to the .xsl file. This would be less intimidating then starting from scratch.

When you get to specifics in your xsl file, you can use Google. Or ask on here because there are a lot of XSL experts on this site.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜