Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 8th, 2008, 01:50 PM
Authorized User
 
Join Date: Jun 2007
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Default multiple input documents

I want to read in multiple XML documents and build a main nodeset. The number of xml documents is unknown, but can be passed in as a comman delimited list within a parameter:

<xsl:param name="docs"/>
<xsl:variable name="docSequence" select="tokenize($docs, ',')"/>

Can I then build a variable that includes all document nodesets using:

<xsl:variable name="mainNodeset">
  <xsl:for-each select="document($docSequence)">
     <xsl:copy-of select="."/>
  </xsl:for-each>
</xsl:variable>

I think I have the logic turned around a bit how to loop thru the tokenized list. Any help is greatly appreciated.

Is there a better way to work with a unknown number of input documents?

Also, I am curious about performance impact as a result of storing the nodesets as a variable and working from that variable instead of an XML file.

Thanks.
 
Old January 8th, 2008, 05:28 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Actually, all you need is

<xsl:variable name="mainNodeset" select="document($docSequence)"/>

since document() in 2.0 accepts a sequence of strings as its input.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old January 8th, 2008, 07:51 PM
Authorized User
 
Join Date: Jun 2007
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks. Even easier.






Similar Threads
Thread Thread Starter Forum Replies Last Post
outputting to multiple documents? wilgartw XSLT 3 November 7th, 2007 07:52 PM
Multiple Input files? edubble XSLT 5 July 31st, 2007 03:42 AM
Referencing multiple XML documents... qornboy XML 3 October 9th, 2003 09:40 AM
Multiple file input single file output.... jdm_mboy Biztalk 1 July 2nd, 2003 03:35 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.