Merging files with xsl:merge and uri-collection

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Merging files with xsl:merge and uri-collection

Julian Richter
Hello there

I’m struggling with another issue right now. And I guess it’s me again missing something pretty trivial… 
I’m trying to merge several files with xsl:merge. It works perfectly if I write all the files down separately, but as soon as I want to use the function uri-collection, Saxon throws a NullPointerException at me:
java.lang.NullPointerException
at net.sf.saxon.resource.DirectoryCollection.directoryContents(DirectoryCollection.java:151)

Here’s my stylesheet:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:math="http://www.w3.org/2005/xpath-functions/math" exclude-result-prefixes="xs math"
    version="3.0">

   
<xsl:output indent="true"/>

   
<xsl:mode streamable="yes" on-no-match="shallow-copy"/>

   
<xsl:template match="/">
       
<xsl:apply-templates/>
   
</xsl:template>

   
<xsl:template match="Books">
       
<xsl:result-document href="books_large_merged.xml">
           
<Books>
               
<xsl:merge>
                   
<xsl:merge-source for-each-stream="uri-collection('large_files')"
                        select="Books/Book" streamable="yes">
                       
<!--<xsl:merge-source
                            for-each-stream="('large_files/part1.xml', 'large_files/part2.xml', 'large_files/part3.xml', 'large_files/part4.xml', 'large_files/part5.xml', 'large_files/part6.xml')"
                            select="Books/Book" streamable="yes">-->
                       
<xsl:merge-key select="@lfNr" data-type="number"/>
                   
</xsl:merge-source>
                   
<xsl:merge-action>
                       
<xsl:copy-of select="current-merge-group()"/>
                   
</xsl:merge-action>
               
</xsl:merge>
           
</Books>
       
</xsl:result-document>
   
</xsl:template>

</xsl:stylesheet>

If I take the source that is in comment instead, my stylesheet works. The source files are in a directory called „large_files“ which is a subdirectory of the folder where the xslt is located. So from my understanding this should be correct (as far as I could see from the examples in the spec).

My setup:
Mac OS X 10.11.2
Oxygen 17.1
Saxon EE 9.7.0.1 (Java)

I’m starting the transformation in Terminal with a command like the following (empty.xml is an existing but empty xml file; all files are in the same directory where „large_files“ is a subdirectory):
java -jar saxon9ee.jar -s:empty.xml -o:out.xml merge.xsl

@M. Kay: thanks for your quick and really helping reply to my question before! Really appreciate that.


Kind regards and thanks in advance,
Julian

------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 

signature.asc (859 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Merging files with xsl:merge and uri-collection

Martin Honnen-2
Julian Richter wrote:
> <xsl:merge-sourcefor-each-stream="uri-collection('large_files')"

Try

<xsl:merge-source
for-each-stream="uri-collection('.?select=large_files/*.xml')"


------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Merging files with xsl:merge and uri-collection

Michael Kay
In reply to this post by Julian Richter
I think the NPE is caused by the code expecting to find query parameters where there are none. As a workaround, try uri-collection('large-files?select=*.*')

Michael Kay
Saxonica

On 14 Jan 2016, at 15:31, Julian Richter <[hidden email]> wrote:

Hello there

I’m struggling with another issue right now. And I guess it’s me again missing something pretty trivial… 
I’m trying to merge several files with xsl:merge. It works perfectly if I write all the files down separately, but as soon as I want to use the function uri-collection, Saxon throws a NullPointerException at me:
java.lang.NullPointerException
at net.sf.saxon.resource.DirectoryCollection.directoryContents(DirectoryCollection.java:151)

Here’s my stylesheet:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:math="http://www.w3.org/2005/xpath-functions/math" exclude-result-prefixes="xs math"
    version="3.0">

   
<xsl:output indent="true"/>

   
<xsl:mode streamable="yes" on-no-match="shallow-copy"/>

   
<xsl:template match="/">
       
<xsl:apply-templates/>
   
</xsl:template>

   
<xsl:template match="Books">
       
<xsl:result-document href="books_large_merged.xml">
           
<Books>
               
<xsl:merge>
                   
<xsl:merge-source for-each-stream="uri-collection('large_files')"
                        select="Books/Book" streamable="yes">
                       
<!--<xsl:merge-source
                            for-each-stream="('large_files/part1.xml', 'large_files/part2.xml', 'large_files/part3.xml', 'large_files/part4.xml', 'large_files/part5.xml', 'large_files/part6.xml')"
                            select="Books/Book" streamable="yes">-->
                       
<xsl:merge-key select="@lfNr" data-type="number"/>
                   
</xsl:merge-source>
                   
<xsl:merge-action>
                       
<xsl:copy-of select="current-merge-group()"/>
                   
</xsl:merge-action>
               
</xsl:merge>
           
</Books>
       
</xsl:result-document>
   
</xsl:template>

</xsl:stylesheet>

If I take the source that is in comment instead, my stylesheet works. The source files are in a directory called „large_files“ which is a subdirectory of the folder where the xslt is located. So from my understanding this should be correct (as far as I could see from the examples in the spec).

My setup:
Mac OS X 10.11.2
Oxygen 17.1
Saxon EE 9.7.0.1 (Java)

I’m starting the transformation in Terminal with a command like the following (empty.xml is an existing but empty xml file; all files are in the same directory where „large_files“ is a subdirectory):
java -jar saxon9ee.jar -s:empty.xml -o:out.xml merge.xsl

@M. Kay: thanks for your quick and really helping reply to my question before! Really appreciate that.


Kind regards and thanks in advance,
Julian
------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help


------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Merging files with xsl:merge and uri-collection

Michael Kay
Logged here:


Michael Kay
Saxonica

On 14 Jan 2016, at 22:14, Michael Kay <[hidden email]> wrote:

I think the NPE is caused by the code expecting to find query parameters where there are none. As a workaround, try uri-collection('large-files?select=*.*')

Michael Kay
Saxonica

On 14 Jan 2016, at 15:31, Julian Richter <[hidden email]> wrote:

Hello there

I’m struggling with another issue right now. And I guess it’s me again missing something pretty trivial… 
I’m trying to merge several files with xsl:merge. It works perfectly if I write all the files down separately, but as soon as I want to use the function uri-collection, Saxon throws a NullPointerException at me:
java.lang.NullPointerException
at net.sf.saxon.resource.DirectoryCollection.directoryContents(DirectoryCollection.java:151)

Here’s my stylesheet:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:math="http://www.w3.org/2005/xpath-functions/math" exclude-result-prefixes="xs math"
    version="3.0">

   
<xsl:output indent="true"/>

   
<xsl:mode streamable="yes" on-no-match="shallow-copy"/>

   
<xsl:template match="/">
       
<xsl:apply-templates/>
   
</xsl:template>

   
<xsl:template match="Books">
       
<xsl:result-document href="books_large_merged.xml">
           
<Books>
               
<xsl:merge>
                   
<xsl:merge-source for-each-stream="uri-collection('large_files')"
                        select="Books/Book" streamable="yes">
                       
<!--<xsl:merge-source
                            for-each-stream="('large_files/part1.xml', 'large_files/part2.xml', 'large_files/part3.xml', 'large_files/part4.xml', 'large_files/part5.xml', 'large_files/part6.xml')"
                            select="Books/Book" streamable="yes">-->
                       
<xsl:merge-key select="@lfNr" data-type="number"/>
                   
</xsl:merge-source>
                   
<xsl:merge-action>
                       
<xsl:copy-of select="current-merge-group()"/>
                   
</xsl:merge-action>
               
</xsl:merge>
           
</Books>
       
</xsl:result-document>
   
</xsl:template>

</xsl:stylesheet>

If I take the source that is in comment instead, my stylesheet works. The source files are in a directory called „large_files“ which is a subdirectory of the folder where the xslt is located. So from my understanding this should be correct (as far as I could see from the examples in the spec).

My setup:
Mac OS X 10.11.2
Oxygen 17.1
Saxon EE 9.7.0.1 (Java)

I’m starting the transformation in Terminal with a command like the following (empty.xml is an existing but empty xml file; all files are in the same directory where „large_files“ is a subdirectory):
java -jar saxon9ee.jar -s:empty.xml -o:out.xml merge.xsl

@M. Kay: thanks for your quick and really helping reply to my question before! Really appreciate that.


Kind regards and thanks in advance,
Julian
------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help

------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help


------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Merging files with xsl:merge and uri-collection

Julian Richter
In reply to this post by Julian Richter
Works perfectly now, thanks a lot!

----------


Logged here:
On 14 Jan 2016, at 22:14, Michael Kay <mi@saxonica.com> wrote:
I think the NPE is caused by the code expecting to find query parameters where
there are none. As a workaround, try uri-collection('large-files?select=*.*')
On 14 Jan 2016, at 15:31, Julian Richter <jr0@hdm-stuttgart.de
<mailto:jr0@hdm-stuttgart.de>> wrote:
Hello there
I’m struggling with another issue right now. And I guess it’s me again missing
something pretty trivial… I’m trying to merge several files with xsl:merge. It works perfectly if I write
all the files down separately, but as soon as I want to use the function
uri-collection, Saxon throws a NullPointerException at me: java.lang.NullPointerException at
net.sf.saxon.resource.DirectoryCollection.directoryContents(DirectoryCollection.java:151)
Here’s my stylesheet: <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform
<http://www.w3.org/1999/XSL/Transform>" xmlns:xs="http://www.w3.org/2001/XMLSchema
<http://www.w3.org/2001/XMLSchema>" xmlns:math="http://www.w3.org/2005/xpath-functions/math
<http://www.w3.org/2005/xpath-functions/math>" exclude-result-prefixes="xs math" version="3.0">
<xsl:output indent="true"/>
<xsl:mode streamable="yes" on-no-match="shallow-copy"/>
<xsl:template match="/"> <xsl:apply-templates/> </xsl:template>
<xsl:template match="Books"> <xsl:result-document href="books_large_merged.xml"> <Books> <xsl:merge> <xsl:merge-source
for-each-stream="uri-collection('large_files')" select="Books/Book" streamable="yes"> <!--<xsl:merge-source for-each-stream="('large_files/part1.xml',
'large_files/part2.xml', 'large_files/part3.xml', 'large_files/part4.xml',
'large_files/part5.xml', 'large_files/part6.xml')" select="Books/Book" streamable="yes">--> <xsl:merge-key select="@lfNr" data-type="number"/> </xsl:merge-source> <xsl:merge-action> <xsl:copy-of select="current-merge-group()"/> </xsl:merge-action> </xsl:merge> </Books> </xsl:result-document> </xsl:template>
</xsl:stylesheet>
If I take the source that is in comment instead, my stylesheet works. The source
files are in a directory called „large_files“ which is a subdirectory of the
folder where the xslt is located. So from my understanding this should be
correct (as far as I could see from the examples in the spec).
The source files can be downloaded here:
https://www.dropbox.com/sh/y8wenpqd8eoexaa/AACd7FNWx-dFE4_MvnAz7J_1a?dl=0
<https://www.dropbox.com/sh/y8wenpqd8eoexaa/AACd7FNWx-dFE4_MvnAz7J_1a?dl=0> My setup: Mac OS X 10.11.2 Oxygen 17.1 Saxon EE 9.7.0.1 (Java)
I’m starting the transformation in Terminal with a command like the following
(empty.xml is an existing but empty xml file; all files are in the same
directory where „large_files“ is a subdirectory): java -jar saxon9ee.jar -s:empty.xml -o:out.xml merge.xsl
@M. Kay: thanks for your quick and really helping reply to my question before!
Really appreciate that.
Kind regards and thanks in advance, Julian
------------------------------------------------------------------------------ Site24x7 APM Insight: Get Deep Visibility into Application Performance APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month Monitor end-to-end web transactions and take corrective actions now Troubleshoot faster and improve end-user experience. Signup Now!

------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 

signature.asc (859 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Merging files with xsl:merge and uri-collection

Julian Richter
In reply to this post by Julian Richter
Sorry to bother again...

Just downloaded 9.7.0.2 and it won’t work anymore. New error in Terminal says this:
„Requested initial mode is streamable: must supply a StreamSource or SAXSource“
Since the sources have been streamable, I don’t see a reason why this should have changed.


----------


Works perfectly now, thanks a lot!
----------
Logged here:
Michael Kay Saxonica
On 14 Jan 2016, at 22:14, Michael Kay <mi... <>@saxonica.com> wrote:
I think the NPE is caused by the code expecting to find query parameters where there are none. As a workaround, try uri-collection('large-files?select=*.*')
Michael Kay Saxonica
On 14 Jan 2016, at 15:31, Julian Richter <jr0... <>@hdm-stuttgart.de <mailto:jr0... <>@hdm-stuttgart.de>> wrote:
Hello there
I’m struggling with another issue right now. And I guess it’s me again missing something pretty trivial… I’m trying to merge several files with xsl:merge. It works perfectly if I write all the files down separately, but as soon as I want to use the function uri-collection, Saxon throws a NullPointerException at me: java.lang.NullPointerException at net.sf.saxon.resource.DirectoryCollection.directoryContents(DirectoryCollection.java:151)
<xsl:output indent="true"/>
<xsl:mode streamable="yes" on-no-match="shallow-copy"/>
<xsl:template match="/"> <xsl:apply-templates/> </xsl:template>
<xsl:template match="Books"> <xsl:result-document href="books_large_merged.xml"> <Books> <xsl:merge> <xsl:merge-source for-each-stream="uri-collection('large_files')" select="Books/Book" streamable="yes"> <!--<xsl:merge-source for-each-stream="('large_files/part1.xml', 'large_files/part2.xml', 'large_files/part3.xml', 'large_files/part4.xml', 'large_files/part5.xml', 'large_files/part6.xml')" select="Books/Book" streamable="yes">--> <xsl:merge-key select="@lfNr" data-type="number"/> </xsl:merge-source> <xsl:merge-action> <xsl:copy-of select="current-merge-group()"/> </xsl:merge-action> </xsl:merge> </Books> </xsl:result-document> </xsl:template>
</xsl:stylesheet>
If I take the source that is in comment instead, my stylesheet works. The source files are in a directory called „large_files“ which is a subdirectory of the folder where the xslt is located. So from my understanding this should be correct (as far as I could see from the examples in the spec).
I’m starting the transformation in Terminal with a command like the following (empty.xml is an existing but empty xml file; all files are in the same directory where „large_files“ is a subdirectory): java -jar saxon9ee.jar -s:empty.xml -o:out.xml merge.xsl
@M. Kay: thanks for your quick and really helping reply to my question before! Really appreciate that.
Kind regards and thanks in advance, Julian
------------------------------------------------------------------------------ Site24x7 APM Insight: Get Deep Visibility into Application Performance APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month Monitor end-to-end web transactions and take corrective actions now Troubleshoot faster and improve end-user experience. Signup Now!
------------------------------------------------------------------------------ Site24x7 APM Insight: Get Deep Visibility into Application Performance APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month Monitor end-to-end web transactions and take corrective actions now Troubleshoot faster and improve end-user experience. Signup Now!
------------------------------------------------------------------------------ Site24x7 APM Insight: Get Deep Visibility into Application Performance APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month Monitor end-to-end web transactions and take corrective actions now Troubleshoot faster and improve end-user experience. Signup Now!
------------------------------------------------------------------------------ Site24x7 APM Insight: Get Deep Visibility into Application Performance APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month Monitor end-to-end web transactions and take corrective actions now Troubleshoot faster and improve end-user experience. Signup Now!

------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 

signature.asc (859 bytes) Download Attachment
Loading...