xsl-list
[Top] [All Lists]

RE: Multiple input files

2003-09-25 08:13:23
From: Ricardo Saraiva [mailto:rss(_at_)dee(_dot_)fct(_dot_)unl(_dot_)pt]
Sent: Thursday, September 25, 2003 8:46 AM
Subject: [xsl] Multiple input files


My question is how to read all the xml files in one directory as input
files to my XSL file?

The document() function does not provide for using wildcards to resolve
URIs, so it's not possible to fully automate the process by doing something
like

<xsl:apply-templates select="document('*.xml')"/>

One solution is to create an XML source document listing all the files you
want to process, then use it as the input for the stylesheet.  Given source
such as:

<file-list>
  <file>a.xml</file>
  <file>b.xml</file>
  <!-- etc. -->
</file-list>

you can do something like this:

<xsl:template match="/file-list">
  <xsl:for-each select="document(file)">
    <!-- do something -->
  </xsl:for-each>
</xsl:template>

This is expensive, as it selects the root node (in other words, the entire
document) as the context for each iteration--see the FAQ
(http://www.dpawson.co.uk/xsl/sect2/N2602.html#d2874e403) for more ideas on
processing multiple documents.

hth,
b.

| brian martinez                           
brian(_dot_)martinez(_at_)cendant(_dot_)com |
| lead gui programmer                                    303.357.3548 |
| cheap tickets, part of trip network                fax 303.357.3380 |
| 6560 greenwood plaza blvd., suite 400           englewood, co 80111 |
| cendant travel distribution services   http://www.cheaptickets.com/ |

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



<Prev in Thread] Current Thread [Next in Thread>