开发者

use multiple xsl files with one xml document

开发者 https://www.devze.com 2022-12-27 01:09 出处:网络
I have a single xml document (data.xml), which I display as HTML using an XSLT document (transform.xsl) with the following line in data.xml.

I have a single xml document (data.xml), which I display as HTML using an XSLT document (transform.xsl) with the following line in data.xml.

<?xml-stylesheet type="text/xsl" href="transform.xsl"?>

Suppose, however, I want to display this information in two different ways, one at http://www.domain.com/data.xml and one at http://www.domain.com/data2.xml. Both of these dis开发者_如何转开发plays will use the same xml document but with different xsl's. Is there a way to do this without duplicating the xml file?


If you are going to use a XSLT linked directly in the XML file, you will have to duplicate your XML.

There are several options:

  • If you generate the XML dynamically, you can detect which URL is being used and link a different XSLT.

  • If your platform has an XSLT transformation class, you can specify a different XSLT. In .NET you can do this using the XslTransform class.

0

精彩评论

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

关注公众号