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 September 15th, 2008, 02:16 AM
Friend of Wrox
 
Join Date: Jun 2008
Posts: 291
Thanks: 9
Thanked 29 Times in 29 Posts
Default saxon:discard-document problem

Hi All,

I'm trying to read all the xml files present in a folder using collection() function. Also I'm using saxon:discard-document with that. If I use like code below, I can get the expected result.

<xsl:for-each select="for $file in
                collection('file:///D:/Ramesh/My_Projects/Repository/NMIRepository/Repository/NE/NE?select=*.xml') return saxon:discard-document($file)">
                <file-loaded href="{base-uri()}" />
            </xsl:for-each>
But if I use like code below, I get an error.

<xsl:variable name="filePath">file:///D:/Ramesh/My_Projects/Repository/NMIRepository/Repository/NE/NE/</xsl:variable>
    <xsl:variable name="allFiles" select="collection(concat($filePath, '?select=*.xml'))"></xsl:variable>

<xsl:for-each select="saxon:discard-document($allFiles)">
                <file-loaded href="{base-uri()}" />
            </xsl:for-each>
The error is:
1.Error in call to extension function
2.Extensions.discardDocument:Sequence contain more than one value; Java method expects only one.

Can anyone explain why this happens and help about this?

thanks


__________________
Rummy
 
Old September 15th, 2008, 03:44 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Why this happens: the extension function saxon:discard-document is defined to take a single document node as its argument, but you are supplying a sequence of documents. (Sorry, that's almost exactly what the error message already says - I don't know how else to explain it more clearly).

What to do about it: apply the method to each document individually:

<xsl:for-each select="collection('...')/discard-document(.)">
  ...
</xsl:for-each>

Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer's Reference
 
Old September 15th, 2008, 04:01 AM
Friend of Wrox
 
Join Date: Jun 2008
Posts: 291
Thanks: 9
Thanked 29 Times in 29 Posts
Default

Thanks Mike. I'm clear now. I understood the mistake I made. Can you explain me what "saxon:discard-document" does? How it helps in memory usage? Sorry if I had extended the topic.

 
Old September 15th, 2008, 04:32 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

I would suggest that you ask saxon-specific questions on the saxon-help mailing list or forum - go to the Saxon project on SourceForge for details. (The mailing list is better because more people use it, but you have to subscribe).

You might like to look at previous threads on the subject first:

http://saxon.markmail.org/search/?q=discard-document

Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer's Reference
 
Old September 15th, 2008, 05:08 AM
Friend of Wrox
 
Join Date: Jun 2008
Posts: 291
Thanks: 9
Thanked 29 Times in 29 Posts
Default

Thanks Mike. I have gone through the old threads present.






Similar Threads
Thread Thread Starter Forum Replies Last Post
SAXON - result-document bonekrusher XSLT 3 May 7th, 2007 08:27 AM
"Discard Saved Data on Open” juma Crystal Reports 1 December 26th, 2006 07:50 AM
How to Discard a Keycode ? minhtri Classic ASP Basics 1 May 12th, 2004 09:28 AM
document reading problem syedusman1 Classic ASP Databases 0 March 30th, 2004 01:45 AM
XML Document Problem Ben Horne XML 5 November 19th, 2003 01:49 PM





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