homepage Welcome to WebmasterWorld Guest from 54.237.213.31
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / XML Development
Forum Library, Charter, Moderators: httpwebwitch

XML Development Forum

    
Single XML file to multiple HTML
How, using XSL?
TheWhippinpost

10+ Year Member



 
Msg#: 20 posted 4:05 pm on Aug 12, 2004 (gmt 0)

Got an XML file where the XPATH is thus:
document/row/blah

I want, in XSL, to create a new HTM file for every "row".

I found a possible solution usin XALAN parser and the 'File' function. So I did some investigation and downloaded the XERCES processor believin that it was packaged with XALAN (as it says at Apache) but I'm Saddam Husseins future cell-mate if I can suss whether it has in fact, got XALAN with it - Java, can't stand it! - or even whether I've installed it correctly.

So, lookin for two possible answers; Can it be done in XSL on its own? If not, some straightforward guidance on installin and/or workin with XERCES/XALAN appreciated.

 

macrost

10+ Year Member



 
Msg#: 20 posted 2:51 am on Aug 13, 2004 (gmt 0)

What type of server are you on? If I read the post correct, you want to be able to create and save a new html file from an xml document right?

davidpbrown

10+ Year Member



 
Msg#: 20 posted 8:31 am on Aug 13, 2004 (gmt 0)

I expect <xsl:result-document> in XSLT 2.0 is what your looking for. The SAXON processor [saxon.sourceforge.net] handles XSLT 2.0 and should be easy to install.

see 'Feature 2: Multiple Outputs' from Five XSLT 2.0 Features [oracle.com]
which suggests a dynamic filename example.

and then maybe use <xsl:for-each select="document/row"> instead of grouping.. but then the for-each-group is worth looking at.. it's not something I'm familar with.

<added/>
This should work.. but I've not got a processor to check.
<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html"/>
<xsl:template match="/">
<xsl:for-each select="document/row">
<xsl:result-document href="../output/row{position()}.htm">
<html>
<body>
<xsl:copy-of select="*"/>
</body>
</html>
</xsl:result-document>
</xsl:for-each>
</xsl:template>
<xsl:template match="text()@*"/>
</xsl:stylesheet>

HTH

TheWhippinpost

10+ Year Member



 
Msg#: 20 posted 12:42 pm on Aug 13, 2004 (gmt 0)

Well, as it turns out, I'm not going to be Saddam Husseins future cell-mate afterall. I didn't in fact have xalan in the end... but even when I did install it, the code I had didn't work.

I did however, find multixmltextwriter [msdn.microsoft.com] over at msdn which I'm hacking and making good progress with (Actually, there's some interestin downloads over there).

davidpbrown:

That looks interesting, will check it out thanks.

macrost:
What type of server are you on?

Take ya pick ;)

If I read the post correct, you want to be able to create and save a new html file from an xml document right?

Almost - I want to generate multiple html files from the siblings of the "Row" nodes contained within one XML file.

EG:

Document
-> Row (One HTML file)
-> -> Name
-> -> Another-Name
-> -> Blah...
-> /Row

-> Row (Another HTML file)
-> -> Name
-> -> Another-Name
-> -> Blah...
-> /Row

etc..
/Document

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / XML Development
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved