Jump to content

Can XSLT do this?


shulin
 Share

Recommended Posts

Suppose I have an xml file looks like:<components> <component> <name> PC1</name> <property> HP </property> <component> <name> OS </name> <property> WinXP<property> </component> </component> <component> <name> PC2</name> <property> HP </property> <component> <name> OS </name> <property> Linux<property> </component> </component></components>Is it possible to write an XSLT to convert this into 4 HTML files, one for PC1, one for OS on PC1, one for PC2 and one for OS on PC2? That is, each <component> tag maps to an HTML file?Also I would like to organize the file as:components/PC1.htmcomponents/PC1/OS.htmcomponents/PC2.htmcomponents/PC2/OS.htmA sample code is highly appreciated.shu-lin

Link to comment
Share on other sites

In XSLT 1.0 at least, you can't write to multiple documents without the help of extensions (different for every processor).If you're forced to use XSLT 1.0, you may try the exsl:document element which however is only available in libxslt (available with a bundled PECL extension to PHP, natively to C, and with wrappers for other languages).If you can use XSLT 2.0 (regardless of the exact processor), you can use the xsl:document element.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...