INRIA
[Up]
Warning

Work in progress

This version may be updated without notice.

I/O Module Specification

An I/O module specification for Active Tags

Working Draft 26 november 2007

Editor
Philippe Poulard  <Philippe · Poulard [at] sophia · inria · fr>

Copyright © INRIA

Abstract

This specification describes an I/O optional module for Active Tags. This I/O module provides tags, attributes, functions and predefined properties related to I/O problematics.

This module intends to deal with several I/O sources but as it provides general purpose I/O features, dedicated modules may be more suitable to handle a specific source. Anyway, this module also provide a basic support for requestable I/O sources, such as querying native XML databases with XQuery queries.

With the I/O module, XPath can also be used to traverse various file systems.

Requirement levels

The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119.

Note that for reasons of style, these words are not capitalized in this document.

Active Tags specifications

The following specifications are part of the Active Tags technologies.

Table of contents

1 The I/O module

1.1 Traversing the file system
1.2 URI handling
1.3 URI schemes support
1.4 Parameters
1.5 MIME types
1.6 File content and encoding
1.7 Fixing non-canonalizable file information with catalogs
2 Examples
2.1 Batch processing
2.2 Synchronized copy to a WebDAV server
2.3 Querying XML:DB in a Web application
3 I/O module reference
3.1 Elements
3.2 Foreign attributes
3.3 Predefined properties
3.4 Extended XPath functions
3.5 Data types

Appendix

A Glossary
B Related Active Tags specifications
C Lists

C.1 Examples list
C.2 Figures list
D Active Schema for the I/O module


1 The I/O module

This Active Tags module has been designed to provide basic I/O support, including the capability of browsing file systems with XPath and querying native XML databases with XQuery queries. Both local files and remote files might be supported according to the protocols covered by the underlying implementation. Additionally, this module supplies a consistent support of URIs and their underlying resources.

Few objects are provided by this module :

The former is a cross operable object that provides useful informations about the file ; the 2 latters are just marker types to handle by actions.

1.1 Traversing the file system

Traversing the file system with XPath is not the same as traversing the file system without XPath.

For example, assuming that file:///path/to/ is an empty directory, the expression io:file('file:///path/to/my/file') will return a file object corresponding to a file that doesn't exist, whereas the expression io:file('file:///path/to/')/my/file will return nothing. Actually, the XPath expression will be evaluated regarding the directory and as this expression consist on traversing its existing children, it returns nothing.

Attempting to write to a file that doesn't exist will create it and its parent directories when needed, but will fail in the second example because no file is held.

In order to create a handler to a file (or a subdirectory) that doesn't necessary exist inside a base directory, simply use the io:resolve-uri() function : io:resolve('file:///path/to/', 'my/file') will be resolved to the expected path file:///path/to/my/file. Attempting to create a file on a file system where a directory of the same name already exists (or the opposite) will fail.

1.2 URI handling

Before traversing any file system, this module is also intended to work with URIs. The string representation of hierarchic URIs must take care of whether the path represent a file or a directory. To achieve this, the string representation of the path of files must not end with "/", and the path of directories must end with "/". On the opposite, the last step involved in an XPath expression applied to an #io:x-file object doesn't need a trailing slash since the XPath syntax doesn't allow it ; as each step consist on looking up for the child resource, the kind of the resource (file or directory) is supplied by the underlying file system ; thus, if the last step denotes a directory, a slash will be automatically appended to its path name.

This is specifically important for resolving URIs : io:resolve-uri('file:///path/to', 'my/file') will be resolved to the URI file:///path/my/file whereas io:resolve-uri('file:///path/to/', 'my/file') will be resolved to the URI file:///path/to/my/file ; additionally, this last URI stands for a file whereas this one : io:resolve-uri('file:///path/to/', 'my/file/') will be resolved to the URI file:///path/to/my/file/ that stands for a directory since it ends with a "/".

The underlying file system will be invoked only if an operation requires it, such as accessing with XPath to the children of a directory, or reading its creation date. Notice that the trailing "/" is forbidden in XPath expressions, and io:file('file:///path/to/')/my/file can lead either to a file that would have the URI file:///path/to/my/file, or to a directory that would have the URI file:///path/to/my/file/, or to nothing according to what would return the underlying file system.

As most of URI handling are performed without accessing resources, resolving a relative path regarding a base URI must be understand as specified in RFC 3986. Other operations that need resource access can be involved implicitely, particularly when the user browse the file system, e.g io:file('file:///path/to/')/my/file as explained above. More generally, the #io:x-file type contains characteristics that are intrinsic to an instance (such as the components of the URI), and others that require an access to the underlying file system.

1.3 URI schemes support

If an URL is used when opening a stream, the underlying implementation may support several additional protocols such as WebDAV or FTP. How these protocols are registered to the engine is implementation dependant.

An implementation must at least implement the file scheme ; other well-known schemes are welcome :

  • file
  • ftp
  • ftps
  • gz
  • http
  • https
  • jar
  • smb
  • tmp
  • web
  • webdav
  • webdavs
  • xmldb
  • zip

Additionally, specific URN schemes might be considered if the underlying implementation would support some.

More suitable modules could define specific scheme handling, for example when user interaction is needed. However, the <io:file> element is also convenient to pass additional parameters when accessing the resource ; generally, io:file() can be substituted to <io:file> when no additional parameters are expected.

1.4 Parameters

Parameters are somewhat unusual in file systems. URIs intend to be a canonical representation of all informations expected to handle a file. However, some schemes may accept parameters either in the aim of changing the normal behaviour, or because it is expected to access the resource.

For example, in addition to an HTTP URL, it is possible to send pairs of { key , value } that are not part of the URL with the POST HTTP method. These additional datas are not part of the URL.

Note
The request parameters that appear in the URL and accepted by some scheme like HTTP ("?param=val1&param=val2...") is not necessary relevant here because a scheme could use both request parameters, and those we are talking about here.

The XML Control Language provides the <xcl:param> element which is useful for this purpose and can be used in this module with the <io:file> or <io:request> elements. In fact, parameters in this I/O module could be understand like "headers" for HTTP, considering that this kind of feature is extended to other file system types. Each file system type is free to understand or ignore parameters, and this module doesn't expect any of them to support parameters.

1.5 MIME types

MIME types are additional information that indicates the file format and are also called content types.

Some files must endorse a MIME type to store their content on their file systems. Actually, when storing a file to an XML Native Database through XML:DB, the type of the resource to store must be specified :

    <io:file mime-type="application/xml" name="myFile"
uri="xmldb:provider://user:pwd@host:port/path/to/resource"/> <io:save content="..." uri="{ $myFile }"/>

As this data is also available in the #io:x-file created, it can be set on it at a later stage :

    <io:file name="myFile" uri="xmldb:provider://user:pwd@host:port/path/to/resource"/>
    <!--do something-->
    <xcl:set-attribute content="application/xml" name="io:mime-type" referent="{ $myFile }"/>
    <io:save content="..." uri="{ $myFile }"/>

Instead of setting the MIME type to the target resource, it can also be set to the source :

    <io:file mime-type="application/xml" name="source" uri="file:///path/to/resource"/>
    <io:file name="target" uri="xmldb:provider://user:pwd@host:port/path/to/resource"/>
    <io:copy source="{ $source }" target="{ $target }"/>

If the underlying file system is able to supply the MIME type of the resource, it can be omitted :

    <!--the web host supplies the MIME type of the resource-->
    <io:file name="source" uri="http://host:port/path/to/resource"/>
    <io:file name="target" uri="xmldb:provider://user:pwd@host:port/path/to/resource"/>
    <io:copy source="{ $source }" target="{ $target }"/>

...or override :

    <!--the web host MIGHT supply the MIME type of the resource, but we want to be sure-->
    <io:file mime-type="application/xml" name="source"
uri="http://host:port/path/to/resource"/> <io:file name="target" uri="xmldb:provider://user:pwd@host:port/path/to/resource"/> <io:copy source="{ $source }" target="{ $target }"/>

Some file systems have means to bind MIME types to file extensions. This is implementation dependant :

    <!--this implementation sets the MIME type
        thanks to a mapping of ".xml" to "application/xml" -->
    <io:file name="source" uri="file:///path/to/resource.xml"/>
    <io:file name="target" uri="xmldb:provider://user:pwd@host:port/path/to/resource"/>
    <io:copy source="{ $source }" target="{ $target }"/>

It is also possible to explicitely invoke the mapper thanks to the io:mime-type() function. How the MIME types are mapped to the file extensions is implementation dependant.

    <!--set the MIME type mapped to ".xml"-->
    <io:file mime-type="{ io:mime-type('xml') }" name="source"
uri="file:///path/to/resource.xml"/> <io:file name="target" uri="xmldb:provider://user:pwd@host:port/path/to/resource"/> <io:copy source="{ $source }" target="{ $target }"/>

The function can also be invoked after the creation of the file object :

    <!--set the MIME type mapped to ".xml"-->
    <io:file mime-type="{ io:mime-type('xml') }" name="source"
uri="file:///path/to/resource.xml"/> <xcl:set-attribute content="{ io:mime-type( $source ) }" name="io:mime-type"
referent="{ $source }"/> <io:file name="target" uri="xmldb:provider://user:pwd@host:port/path/to/resource"/> <io:copy source="{ $source }" target="{ $target }"/>

1.6 File content and encoding

This module intends to process XML documents as well as binary resources or other (non-XML) text files. XML parsers have means to fix which charset is used in an XML document. By definition, binary resources are not read neither write as text, thus no encoding must be supplied. On the opposite, to process healthily a text file, a specific encoding must be supplied.

Some file systems may provide an encoding by themselves : for example, http, https, webdav and webdavs may set the encoding to a file thanks to an HTTP header. In this case, such files can be handled safely as the right encoding has been set to the file by the underlying file provider.

However, in many cases, the expected encoding is missing. The #io:x-file object uses the @io:encoding attribute that may be set or overriden, or even removed (to force a text file to be read as binary datas). To achieve this, an #io:x-file instance may be created with the <io:file> active tag, and with the right HTTP header as a parameter.

When opening a file, the #io:input or #io:output will be read or written with the encoding supplied by the file, if any ; if no encoding is provided, the content will be processed as binary data.

Note

Default encoding

The $sys:encoding property may be used to set to a file the encoding of the underlying locale.

The files :

<io:file name="f1" uri="http://www.acme.org/boats/titanic.jpg"/>
should have no encoding.
<io:file name="f2" uri="http://www.acme.org/boats/titanic.html"/>
should have an encoding.
<io:file encoding="" name="f3" uri="http://www.acme.org/boats/titanic.jpg"/>
is forced to have no encoding.
<io:file name="f4" uri="file:///path/to/titanic.jpg"/>
has no encoding.
<io:file encoding="iso-8859-1" name="f5" uri="file:///path/to/titanic.txt"/>
has the encoding specified.
<io:file encoding="{ $sys:encoding }" name="f6" uri="file:///path/to/titanic.txt"/>
has the locale encoding.

The same source file may also be handled both in a binary form or with different text encodings. For example, assuming that <tool:text-dump> and <tool:binary-dump> are custom actions that are dumping a file, the following snippet code will dump the same file in text and binary :

    <io:file name="myBinary" uri="file:///path/to/file"/>
    <io:file encoding="{ $sys:encoding }" name="myText" uri="{ $myBinary }"/>
    <tool:text-dump source="{ $myText }"/>
    <tool:binary-dump source="{ $myBinary }"/>

Of course, a low-level implementation of these actions could also bypass this mechanism if necessary.

1.7 Fixing non-canonalizable file information with catalogs

As shown previously, a file is not necessary defined entirely with a sole URI ; an encoding and other parameters may be added.

An Active Catalog may be advantageously used to arrange URIs mapping to full parameterized files.

[TODO]

Forcing catalog usage

Active Catalog defines selectors to define specific settings. See the specification.

<io:file name="file" selector="my:selector" uri="urn:scheme:scheme-specific-part"/>

By specifying a selector, the catalog will be forced to resolve the URI (which is an URN in the above example, but that could be an URL as well). The catalog entry that will match the selector and the URI will be used to resolve it ; the catalog might supply a resolved file with its additional informations (encoding and special purpose parameters).


2 Examples

2.1 Batch processing

With XML technologies, it is often useful to publish an entire XML repository in HTML or PDF ; Active Tags allows to describe such a publishing process.

Batch example

Very few tags are necessary to transform XML files of a whole directory in HTML.

<?xml version="1.0" encoding="iso-8859-1"?>
<xcl:active-sheet xmlns:io="http://ns.inria.org/active-tags/io" xmlns:xcl="http://ns.inria.org/active-tags/xcl"> <!-- the same stylesheet for all XML files --> <xcl:parse-stylesheet name="xslt" source="file:///path/to/myStylesheet.xsl"/> <xcl:set name="myXMLFiles"
value="{io:file( 'file:///path/to/my/xml/docs/' )//*[@io:is-file][@io:extension='xml']}"/> <xcl:for-each name="file" select="{$myXMLFiles}"> <xcl:parse name="xml" source="{$file}"/> <xcl:transform name="html" output="{substring-before( $file/@io:path, '.xml' )}.html"
source="{$xml}" stylesheet="{$xslt}"/> </xcl:for-each> </xcl:active-sheet>

Here we use an iterative tag (<xcl:for-each>) that nests subactions.

io:file() is an XPath function of the I/O module that produces an #io:x-file# file object which behaves like an XML object : when the XPath step // is applied on such object, the subdirectories are crossed recursively, as expected. The XPath predicate [@io:is-file] is applied on the result to keep only files, not directories, and the next predicate is applied to keep files that end with ".xml".

Objects that behaves like XML objects, like the file objects in this example, are called cross operable or X-operable objects. They may have attributes (like @io:is-file), and may support other XPath axes.

Modularization and cross operable objects are one of the most powerfull concepts of Active Tags.

2.2 Synchronized copy to a WebDAV server

[TODO]

2.3 Querying XML:DB in a Web application

The <io:request> element allows to query a data source. It can be used for querying native XML databases, and XQuery queries can be submitted to the databases that support it.

An XQuery query with an external parameter

The following XQuery query list the number of persons involved in the projects of a given department, passed as a parameter to the XQuery engine :

xquery version "1.0";
declare variable $dept as xs:string external;
<html>{ attribute xmlns {"http://www.w3.org/1999/xhtml"} }
    <head><title>Project summary</title></head>
    <body><h1>Project summary in { $dept }</h1>
        <table border="2">
            <tr><th>Project</th><th>Persons</th></tr>
            {
                for $project in //project
                let $persons := count($project//person)
                where string($project/@dept) = $dept
                return <tr><td valign="top">{ string($project/name) }</td><td>{ $persons }</td></tr>
            }
        </table>
    </body>
</html>

The projects are stored in a native XML database that is accessible via XML:DB with the following active sheet :

<?xml version="1.0" encoding="iso-8859-1"?>
<xcl:active-sheet xmlns:io="http://ns.inria.org/active-tags/io" xmlns:sys="http://ns.inria.org/active-tags/sys" xmlns:xcl="http://ns.inria.org/active-tags/xcl"> <xcl:set name="connexion"
value="{ io:file('xmldb:provider://example.com:1234/xmlrpc/db/') }"/> <io:request connect="{ $connexion }" name="result" source="{ string( $sys:env/query ) }"
style="stream" type="XQueryService"> <xcl:param name="dept" value="{ string( $sys:env/department ) }"/> </io:request> <xcl:transform output="{ $sys:out }" source="{ $result }" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xcl:param name="xsl:method" value="xml"/> <xcl:param name="xsl:encoding" value="iso-8859-1"/> </xcl:transform> </xcl:active-sheet>

In this active sheet, the query must be set as an environment variable (query) ; the parameter passed to the XQuery query must also be set as an environment variable (department).

From this base, the same logic can be embedded within a Web server :

<?xml version="1.0" encoding="iso-8859-1"?>
<web:service xmlns:io="http://ns.inria.org/active-tags/io" xmlns:xcl="http://ns.inria.org/active-tags/xcl" xmlns:web="http://ns.inria.org/active-tags/web"> <!-- [webapp]/projects.html?department=RD --> <web:mapping match="^/projects.xml$" mime-type="application/xml"> <xcl:set name="connexion"
value="{ io:file('xmldb:provider://example.com:1234/xmlrpc/db/') }"/> <io:request connect="{ $connexion }" name="result" source="web:///WEB-INF/projects.xqy"
style="stream" type="XQueryService"> <xcl:param name="dept" value="{ $web:request/department ) }"/> </io:request> <xcl:transform output="{ value( $web:response/@web:output ) }" source="{ $result }" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xcl:param name="xsl:method" value="xml"/> <xcl:param name="xsl:encoding" value="iso-8859-1"/> </xcl:transform> </web:mapping> </web:service>

3 I/O module reference

I/O : Input/Ouput module
I/O namespace URI : http://ns.inria.org/active-tags/io
Usual prefix : io
Elements Foreign attributes Extended functions Data types
<io:close>
<io:copy>
<io:create-dir>
<io:delete>
<io:file>
<io:open>
<io:read>
<io:request>
<io:save>
<io:write>
@io:version
io:file()
io:exists()
io:root-files()
io:resolve-uri()
io:relativize-uri()
io:mime-type()
#io:input
#io:output
#io:x-file

Must be an adt:expression that computes an object of the type expected.
Must be a hard-coded value (litteral)
Can be either a hard-coded value or an adt:expression
This material may be missing
Denotes a value to use by default
Allows a read operation.
Allows a write operation.
Allows a rename operation.
Allows an update operation.
Allows a delete operation.

3.1 Elements

<io:close>

Closes a stream.

Attributes runtime | hard-coded | both
NameTypeValue optional | default value
runtimestream#io:input The input stream to close.
#io:output The output stream to close.

<io:copy>

[TODO: Synchronized copy]

Copies a file. If the source to copy is a directory, all its descendant are candidate to copy ; each candidate may be filtered.

If the source to copy is a file with a MIME type and/or an encoding and the target is a file, the MIME type and/or the encoding of the source is set to the target file. The MIME type and the encoding of the source can be either set explicitely or set automatically by the underlying file system ; notice that in any case they can be also unset explicitely.

Copying with a filter
<io:copy filter="{ @io:extension='xml' }" source="file:///path/to/srcdir/"
target="file:///path/to/targetdir/"/>

Attributes runtime | hard-coded | both
NameTypeValue optional | default value
runtimesource#io:input The input stream to copy.
#io:x-file The file to copy.
#xs:anyURI The URI of the file to copy.
runtimetarget#io:output The output stream to copy.
#io:x-file The target file or directory.
#xs:anyURI The URI of the file or directory to copy.
runtimefilteroptionalSet a filter for each candidate file to copy. The current object is set to each candidate file when the expression is evaluated.
#xs:booleantrueReject the file.
falsedefault valueAccept the file.

Note

Using complex filters

A macro function might be useful for complex filters that can't be expressed in a single expression.


<io:create-dir>

Creates a directory. When needed, the parent directories are also created.

A #io:x-file property is added to the data set. When the @name attribute is omitted, the property is set as the current object.

Attributes runtime | hard-coded | both
NameTypeValue optional | default value
runtimeuri#xs:anyURI The URI of the directory to create, or the base directory that will contain the directory to create if the is specified.
#io:x-file The directory to create, or the base directory that will contain the directory to create if the is specified.
runtimepathoptional#xs:string The relative path to the directory to create. The path is relative to the base URI given by the attribute
bothnameoptional#xs:QName The name of the property that contains the created dir.

<io:delete>

Deletes a file or a directory and its content if any.

Attributes runtime | hard-coded | both
NameTypeValue optional | default value
runtimeuri#xs:anyURI The URI of the file to delete.
#io:x-file The file to delete.

<io:file>

Define a file.

According to the scheme specified in the URI, some additional informations that can't be canonicalized in the address may be accepted ; for this purpose, parameters may provide them. Other I/O actions that require parameters but don't open a parameter context at runtime should use this action before.

A file that doesn't need parameters can be handled directly with the io:file() function.

This action create a property of the #io:x-file type. If some parameters are found while performing the subactions, they are set as attributes of the property created if their name is not bound to a namespace URI, and will be used by the underlying scheme provider to access the resource. Parameters irrelevant for the provider are ignored.

runtime phase

Attributes runtime | hard-coded | both
NameTypeValue optional | default value
runtimeuri#xs:anyURI The URI of the file.
#io:x-file The file given is returned with additional parameters if some were found while performing the subactions.
bothnameoptional#xs:QName The name of the property to add to the data set.
bothmime-typeoptional#xs:string The MIME type of that file.
bothencodingoptional#xs:string The encoding of the content of that file.

<io:open>

Opens a file.

Create a property that is either an #io:input or an #io:output, according to the mode used.

Attributes runtime | hard-coded | both
NameTypeValue optional | default value
runtimeuri#xs:anyURI The URI of the file to open.
#io:x-file The file to open.
hard-codedmodeoptionalThe open mode.
#xs:stringappenddefault valueOpens an input stream for appending content.
readOpens an input stream for reading content.
writeOpens an output stream for writing content.
bothnameoptional#xs:string The name of the property to add to the data set.

<io:read>

Reads an input stream.

A property that contains the data read is added to the data set. When the @name attribute is omitted, the property is set as the current object.

Attributes runtime | hard-coded | both
NameTypeValue optional | default value
runtimeinput#io:input The input stream to read.
hard-codedmodeoptionalThe reading mode.
#xs:stringlinedefault valueReads an entire line.
charReads a single char.
byteReads a single byte.
bothnameoptional#xs:string The name of the property to add to the data set.

<io:request>

Sends a request to an I/O source. This operation is relevant for XML:DB sources.

runtime phase

error handling phase

If an error is encountered and <xcl:fallback> elements are children of this element, they will be invoked according to their identifier :

IDCondition of invokation
io:serviceNotRegistered Denotes that the driver has not been registered.
io:serviceNotCompatible Denotes that the query service is not understood by the underlying implementation.

Each of the fallback actions above will be invoked with the same data set as those used when the parsing starts. A property of the type #xml:x-error is previously added.

Additionally, a default <xcl:fallback> element may be supplied.

@source
Attributes runtime | hard-coded | both
NameTypeValue optional | default value
bothnameoptional#xs:QName The name of the property to add to the data set.
hard-codedscopeoptional The scope of the property to create.
#xs:stringlocaldefault valueLocal.
globalGlobal.
sharedShared.
runtimeconnect#xs:anyURI The connexion to the I/O source, such as : "xmldb:provider://user:password@host:port/path".
#io:x-file The connexion to the I/O source.
bothstyleoptionalThe type of the items of the result. Some provider may deliver the result as a list of items that is accessible as soon as the first item is available.
missing attributedefault value The result is delivered as is.
#xs:stringtreeXML DOM document, if relevant.
streamXML SAX events, if relevant.
xmlXML character stream, if relevant.
as-isAs returned by the query.
hard-codedtype#xs:string The name of the query service ; the query service establishes the request language to use for the query. May be :
  • "XQuery",
  • "XPath",
  • a provider-dependant language request such as "XyQL",
  • or anything else registered as a query service to the XML:DB provider.
hard-codedversionoptionalThe version of the query service.
#xs:string1.0default valueThe version.
other
bothqueryoptional#xs:string The query to submit, that depends on the query service given by the @type attribute. If missing, the query is defined either with the attribute or thanks to some parameters accepted by this action, which are dependant to the provider.
bothsourceoptionalThe URI to the source of the query to submit, that depends on the query service given by the @type attribute. If missing, the query is defined either with the @query attribute or thanks to some parameters accepted by this action, which are dependant to the provider.
#xs:anyURI The source URI.
#io:x-file The source file.

<io:save>

Saves a content to a file.

Attributes runtime | hard-coded | both
NameTypeValue optional | default value
bothuri#xs:anyURI The file to save to.
#io:x-file The file to save to.
bothcontent#xs:string The content to write.

<io:write>

Writes to an output stream.

Attributes runtime | hard-coded | both
NameTypeValue optional | default value
runtimeoutput#io:output The output stream to write to.
bothcontent#xs:string The content to write.
#other The content to write, taken from the string value of the object given.

3.2 Foreign attributes

@io:version

The version of the I/O module to use. This attribute should be encountered before any I/O element, but it takes precedence on the element inside which it is hosted.

3.3 Predefined properties

No predefined properties are defined by this module.

3.4 Extended XPath functions

io:file()

  • Return: #io:x-file
  • Represent a file. If the file to be represented needs parameters, use the <io:file> element instead.

    Arguments
    1#xs:anyURI The URI of the file.
    Arguments
    1#io:x-file A parent file.
    2#xs:anyURI A child path.

    io:exists()

  • Return: #xs:boolean
  • Test if a file exist or not.

    Arguments
    1#io:x-file The file to test.
    Arguments
    1#xs:anyURI The URI of the file to test.

    io:root-files()

  • Return: #adt:list of #io:x-file
  • This function returns the collection of the available filesystem roots.


    io:resolve-uri()

  • Return: #xs:anyURI
  • Resolve an URI regarding a base URI, or relocate an URI regarding a base URI to a target base URI.

    Resolving an URI

    Resolving more-path/to/file upon file:///path/to/base/ will give file:///path/to/base/more-path/to/file.

    Arguments
    1 The base URI.
    #io:x-file A file.
    #xs:anyURI An URI.
    2 The URI to resolve.
    #io:x-file A file.
    #xs:anyURI An URI.

    Relocating an URI

    Relocating consist on relativizing then resolving.

    Relocating the URI file:///path/to/base/more-path/to/file upon the base file:///path/to/base/ to the target http://www.somehost.org/somepath/ will give http://www.somehost.org/somepath/more-path/to/file.

    Arguments
    1 The base URI.
    #io:x-file A file.
    #xs:anyURI An URI.
    2 The URI to resolve.
    #io:x-file A file.
    #xs:anyURI An URI.
    3 The base target URI used for the resolution.
    #io:x-file A file.
    #xs:anyURI An URI.

    io:relativize-uri()

  • Return: #xs:anyURI
  • Relativize an URI regarding a base URI.

    Arguments
    1 The base URI.
    #io:x-file A file.
    #xs:anyURI An URI.
    2 The URI to relativize with the base.
    #io:x-file A file.
    #xs:anyURI An URI.

    io:mime-type()

  • Return: #xs:string
  • Return the MIME type bound to the given file extension, or the empty string if none.

    How the extensions are mapped to the MIME types is implementation dependant.

    Arguments
    1
    #io:x-file A file. The MIME type returned is not those set to the file but those mapped to its extension if any. Implementations are free to access resources content to examine which type it is.
    2
    #xs:string A file extension, without the dot : "xml", "gif", "jpeg", "txt" etc

    3.5 Data types

    #io:input type

    Represents an input stream of bytes or characters.


    #io:output type

    Represents an output stream of bytes or characters.


    #io:x-file type

    Represents a file or directory on the file system.

    Operation read | write | rename | update | delete
    TypeValueComment
    rename#xs:QName The new name of the file.
    type()
    #xs:QName#io:x-fileThis type
    name()
    read#xs:QName The name of the file.
    position()
    read#xs:integer The position of the file in its parent directory.
    string()
    read#xs:string The path of this file.
    parent::
    read#io:x-file The parent directory of this file.
    child::
    read#adt:list of #io:x-file The files contained in this directory.
    attribute::
    A set of attributes including those specified below (and that can't be removed). Additional attributes may be set, removed or updated, if they are not bound to a namespace URI (see <io:file>).
    read#adt:map of #adt:NItem All attributes are readable.
    write#adt:map of #adt:NItem Any attribute not bound to a namespace URI may be written.
    update#adt:map of #adt:NItem Any attribute not bound to a namespace URI may be updated. Others are updated as specified below.
    delete#adt:map of #adt:NItem Any attribute not bound to a namespace URI may be removed.
    rename#adt:map of #adt:NItem Any attribute not bound to a namespace URI may be renamed if the new name is not bound to a namespace URI.
    @io:can-read
    Indicates whether or not this file can be read.
    read#xs:booleantrueThis file can be read.
    falseThis file can't be read.
    write#xs:booleantrueMark this file so that read operations are allowed.
    falseMark this file so that read operations are disallowed.
    @io:can-write
    Indicates whether or not this file can be written.
    read#xs:booleantrueThis file can be written.
    falseThis file can't be written.
    write#xs:booleantrueMark this file so that write operations are allowed.
    falseMark this file so that write operations are disallowed.
    @io:exists
    Indicates whether or not this file exists.
    read#xs:booleantrueThis file exists.
    falseThis file doesn't exist.
    @io:is-empty
    Indicates whether or not this file is empty.
    read#xs:booleantrueThis file is empty.
    falseThis file is not empty.
    @io:extension
    read#xs:string The extension of this file (the part of the file name that follows the last dot).
    @io:short-name
    read#xs:string The name of this file without its extension if any.
    @io:path
    read#io:x-file The path of this file. This path is normalised, so that . and .. elements have been removed. Also, the path only contains / as its separator character. The path always starts with /
    @io:decoded-path
    read#xs:string The path where each escape sequence "%nn" is replaced by its character.
    @io:depth
    read#xs:string The depth of this file path. The depth of the root of a file system is 0. The depth of any other file is 1 + the depth of its parent.
    @io:is-directory
    Indicates whether or not this is a directory.
    read#xs:booleantrueThis is a directory.
    falseThis is not a directory.
    @io:is-file
    Indicates whether or not this is a file.
    read#xs:booleantrueThis is a file.
    falseThis is not a file.
    @io:is-hidden
    Indicates whether or not this file is hidden.
    read#xs:booleantrueThis file is hidden.
    falseThis file is not hidden.
    @io:last-modified
    read#xs:date The last date when this file was modified.
    write#xs:date Set the date of modification of this file.
    @io:length
    read#xs:int The length of this file.
    @io:encoding
    The encoding of this file.
    read#xs:string By default, it is those supplied by the underlying file system if any, but it can also be those set explicitely if relevant.
    write#xs:string Set the encoding of this file.
    @io:mime-type
    The MIME type of this file.
    read#xs:string By default, it is those supplied by the underlying file system if any, but it can also be those set explicitely if relevant.
    write#xs:string Set the MIME type of this file.
    @io:uri
    read#xs:anyURI The URI of this file.

    Appendix

    A Glossary

    B Related Active Tags specifications

    This list is not exhaustive; it is a list of common modules usable by an engine that implements the Active Tags specifications that implementors may use. Additional modules are welcome.

    C Lists

    C.1 Examples list

    C.2 Figures list