Project

Profile

Help

saxon9api Collection Function

Added by Anonymous over 16 years ago

Legacy ID: #4730910 Legacy Poster: pvallone (pvallone)

Hi I am using the saxon9api for .NET. Does the api allow the Collection Function? Am I passing the arguments correctly? Thanks I am receiving an error during tranformation: unknown collection c:/temp?select=*.xml;recurse=yes Here is my vb code: ' Create a Processor instance. Dim processor As Processor = New Processor() ' Load the source document Dim input As XdmNode = processor.NewDocumentBuilder().Build(New Uri("C:\temp\80-02.xml")) ' Create a transformer for the stylesheet. Dim transformer As XsltTransformer = processor.NewXsltCompiler().Compile(New Uri("C:/temp/MYXSLT.XSL")).Load() ' Param myurl is the folder being loaded for the collection function transformer.SetParameter(New QName("", "", "myurl"), New XdmAtomicValue("C:/temp")) transformer.SetParameter(New QName("", "", "manualtitle"), New XdmAtomicValue("TEST")) ' Set the root node of the source document to be the initial context node transformer.InitialContextNode = input ' Create a serializer Dim serializer As Serializer = New Serializer() serializer.SetOutputStream(New FileStream("ExampleSimple2.html", FileMode.Create, FileAccess.Write)) ' Transform the source XML to System.out. transformer.Run(serializer)


Replies (7)

Please register to reply

RE: saxon9api Collection Function - Added by Anonymous over 16 years ago

Legacy ID: #4731083 Legacy Poster: Jesper Tverskov (jesper_tverskov)

When I use the collection function in Saxon it looks like this, using your example: collection(iri-to-uri('file:///c:/temp/?select=*.xml;recurse=yes'))" see my article: http://www.xmlplease.com/collection Cheers, Jesper Tverskov http://www.xmlplease.com

RE: saxon9api Collection Function - Added by Anonymous over 16 years ago

Legacy ID: #4731095 Legacy Poster: Michael Kay (mhkay)

This has nothing to do with the API, it's the actual call on collection() within your stylesheet that matters. The parameter passed to the collection() function must be a URI - not a filename. so in your example "file:///c:/temp" should work. I assume that the error message relating to "c:/temp?select=*.xml;recurse=yes" happened when you used that, rather than "c:/temp", as the argument to collection().

RE: saxon9api Collection Function - Added by Anonymous over 16 years ago

Legacy ID: #4731117 Legacy Poster: pvallone (pvallone)

Hi Thanks for the help. When I use this stylesheet with the Saxon 9.002 .NET commandline it works. So I assumed it was not the stylesheet. I am also assuming I am messing something up. So I tried hard coded the URI in the stylesheet and recieved the following errors: collection('c:/temp') ---- Unknown collection c:/temp collection('file:///c:/temp') ---- Unknown collection file:///c:/temp collection(iri-to-uri('c:/temp')) ---- Unknown collection c:/temp collection(iri-to-uri('file:///c:/temp')) ---- Unknown collection file:///c:/temp Thanks for the help,

RE: saxon9api Collection Function - Added by Anonymous over 16 years ago

Legacy ID: #4731170 Legacy Poster: Michael Kay (mhkay)

You're right. When a Processor object is created via the .NET Saxon.Api, the underlying Configuration is initialized with a DotNetCollectionURIResolver, which has very limited functionality compared with the standard Java CollectionURIResolver. This is a hangover from earlier releases where the Java version didn't work properly on .NET. When Saxon is invoked from the command line on .NET, it uses the same CollectionURIResolver as on Java, which seems to work fine. The DotNetCollectionURIResolver only recognizes a collection whose URI has been registered using the Processor.RegisterCollection() method. This is of course far less useful than the ability to process a directory. You should be able to get Saxon to use the standard (Java) CollectionURIResolver like this: processor.Implementation.setCollectionURIResolver(new net.sf.saxon.functions.StandardCollectionURIResolver()); I'd be grateful for your feedback on whether this works. So long as the workaround works, I'm inclined to fix this as an enhancement rather than as a bug fix, to ensure that it goes through full testing before release. Michael Kay

RE: saxon9api Collection Function - Added by Anonymous over 16 years ago

Legacy ID: #4731208 Legacy Poster: pvallone (pvallone)

Hi Thanks for the Help. I would love to help any way I can. I added the following: Dim processor As Processor = New Processor() processor.Implementation.setCollectionURIResolver(New net.sf.saxon.functions.StandardCollectionURIResolver()) When I tied to transform, I received no errors but it did not transform. In a nut shell nothing happened. As a note, my XSLT uses the resulting document to output one XML file and 2 HTML files. Thanks

RE: saxon9api Collection Function - Added by Anonymous over 16 years ago

Legacy ID: #4731238 Legacy Poster: Michael Kay (mhkay)

Was the output consistent with what you would get if collection() returned an empty sequence? Is it possible that the transformation is producing output files, but in a different location from where you expected them to be?

RE: saxon9api Collection Function - Added by Anonymous over 16 years ago

Legacy ID: #4731267 Legacy Poster: pvallone (pvallone)

It works! After adding the CollectionURIResolver, I had a $path param in my xslt for the resulting documents but I never added to my code. So that was it. Thank you so much! I've been using the .NET command line which works well, but this is cleaner a lot faster. Thanks again. Pvallone

    (1-7/7)

    Please register to reply