Set content type for files using fn:collection() select pattern

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

Set content type for files using fn:collection() select pattern

Florent Georges-3
Hi,

The documentation for collections [1] says:

""" From Saxon 9.7, provided XPath 3.1 is enabled, collections can
return any kind of items (not only nodes, as previously). Saxon by
default recognizes four kids of resource: XML documents, JSON
documents, unparsed text documents, and binary files. The standard
collection resolver attempts to identify which kind of resource to use
based on the content type (media type), which in turn may be inferred
from HTTP headers, from sniffing the initial bytes of the content, or
from file extensions. """

I did not enabled 3.1.  I use fn:collection('.../?select=*.inc').  For
some reason, the XML files have the extension *.inc, but they are XML.
They are returned as xs:base64Binary items.

Is there any way to tell Saxon, using fn:collection(), that they are
XML document?

Regards,

[1] http://saxonica.com/documentation/index.html#!sourcedocs/collections

--
Florent Georges
H2O Consulting
http://h2o.consulting/

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
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: Set content type for files using fn:collection() select pattern

Michael Kay
You can define a mapping from file extensions to media types in the configuration file (resources/fileExtension) - see

http://www.saxonica.com/documentation/index.html#!configuration/configuration-file/config-resources

Or you can do it programmatically using the method Configuration.registerFileExtension().

Michael Kay
Saxonica

> On 29 May 2017, at 17:43, Florent Georges <[hidden email]> wrote:
>
> Hi,
>
> The documentation for collections [1] says:
>
> """ From Saxon 9.7, provided XPath 3.1 is enabled, collections can
> return any kind of items (not only nodes, as previously). Saxon by
> default recognizes four kids of resource: XML documents, JSON
> documents, unparsed text documents, and binary files. The standard
> collection resolver attempts to identify which kind of resource to use
> based on the content type (media type), which in turn may be inferred
> from HTTP headers, from sniffing the initial bytes of the content, or
> from file extensions. """
>
> I did not enabled 3.1.  I use fn:collection('.../?select=*.inc').  For
> some reason, the XML files have the extension *.inc, but they are XML.
> They are returned as xs:base64Binary items.
>
> Is there any way to tell Saxon, using fn:collection(), that they are
> XML document?
>
> Regards,
>
> [1] http://saxonica.com/documentation/index.html#!sourcedocs/collections
>
> --
> Florent Georges
> H2O Consulting
> http://h2o.consulting/
>
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> saxon-help mailing list archived at http://saxon.markmail.org/
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/saxon-help 


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
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: Set content type for files using fn:collection() select pattern

Florent Georges-3
Thank you, Mike, it works like a charm.

For some reason, the fileExtension element is not recognised by the schema used by oXygen for Saxon config files (which is very convenient by the way).  I will report it.

Regards,

-- 
Florent Georges
H2O Consulting
http://h2o.consulting/ 


On 29 May 2017 at 19:11, Michael Kay wrote:
You can define a mapping from file extensions to media types in the configuration file (resources/fileExtension) - see

http://www.saxonica.com/documentation/index.html#!configuration/configuration-file/config-resources

Or you can do it programmatically using the method Configuration.registerFileExtension().

Michael Kay
Saxonica

> On 29 May 2017, at 17:43, Florent Georges <[hidden email]> wrote:
>
> Hi,
>
> The documentation for collections [1] says:
>
> """ From Saxon 9.7, provided XPath 3.1 is enabled, collections can
> return any kind of items (not only nodes, as previously). Saxon by
> default recognizes four kids of resource: XML documents, JSON
> documents, unparsed text documents, and binary files. The standard
> collection resolver attempts to identify which kind of resource to use
> based on the content type (media type), which in turn may be inferred
> from HTTP headers, from sniffing the initial bytes of the content, or
> from file extensions. """
>
> I did not enabled 3.1.  I use fn:collection('.../?select=*.inc').  For
> some reason, the XML files have the extension *.inc, but they are XML.
> They are returned as xs:base64Binary items.
>
> Is there any way to tell Saxon, using fn:collection(), that they are
> XML document?
>
> Regards,
>
> [1] http://saxonica.com/documentation/index.html#!sourcedocs/collections
>
> --
> Florent Georges
> H2O Consulting
> http://h2o.consulting/
>
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> saxon-help mailing list archived at http://saxon.markmail.org/
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/saxon-help


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help





------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Loading...