Re: [xsl] combine xml files

Subject: Re: [xsl] combine xml files
From: "Thomas B. Passin" <tpassin@xxxxxxxxxxxx>
Date: Wed, 10 Apr 2002 15:01:24 -0400
[Ming]

>
> I'm very new to XSLT and here is one of my problems. I have several xml
files
> with same structure.
>
> <xml>
>   <db>
>      <title>  title in db </title>
>      <author> author names </author>
>   </db>
> </xml>
>
> And what I want is to output to html with the formats for each xml record:
>
> Title: title in db
> Author: author names
>
> Do you have any suggestions on what I should do this? Should I process the
xml
> files in my java servlet, recombine my xml files into one and pass to my
> stylesheet or process each xml file separately? The second case produce a
> problem of generating <html><body> </body></html> for each record. So, in
my
> final html page, the <html><body> </body></html> tags appear for each
record
> which doesn't seem right to me.
>

I would create an xml file that contains the name of each file.  It might
look like this:

<files>
    <file name='xml1.xml'/>
    <file name='xml2.xml'/>
</files>

I would use that file as the source.   I would do something like

<xsl:for-each select='files/file'>
<tr><td><xsl:value-of select='document(@name)/xml/db/title'/></td></tr>
</xsl:for-each>

You can probably create a list of files using a batch file or a shell
script, if they are all in the same set of directories.

BTW, the use of element names starting with "xml" and its variations is
reserved for W3C use.  Best not to use it even if your processor doesn't
complain about it.

Cheers,

Tom P


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread