xproc / Vnext

Assembly point for all issues for a next version of XProc
1 stars 0 forks source link

Provide function for determining the URI that a given output port will serialize to #35

Open gimsieke opened 1 year ago

gimsieke commented 1 year ago

While the connection of an output port to an external document is implementation-defined, it may make sense to provide an interoperable function to query the URI that an output port will be written to by the processor, if the port is connected to a document on invocation.

A use case is: Write the primary output to a document that contains xi:include instructions using the implementation-defined way (-o result=uri for XML Calabash) and to use p:store in order to write the files-to-be-xincluded to a location that is relative to the primary output location. Currently you cannot find out the output port’s destination document URI within the pipeline, therefore you cannot compute relative locations for p:store/@href.

Such a thing, to my knowledge, can currently only achieved if the user specifies an output URI as a pipeline option, instead of writing the primary output to a certain document upon invocation. This output URI can then be used to write all outputs, both the top-level document that contains the XIncludes and the xincluded secondary documents, via p:store.

We can introduce a function p:output-uri($port as xs:string) → xs:anyURI?, where port is, for example, 'result'. If no serialization is requested (in an implementation-defined way), the empty sequence will be returned. If no output port with such a name is declared on the closest containing p:declare-step, a static error will be raised.

So far we don’t have functions that accept port names AFAIK, but this should be doable, shouldn’t it?

gimsieke commented 1 year ago

It can be useful for a p:declare-step that is contained in another p:declare-step to query an output port connection URI of an outer p:declare-step. Therefore p:output-uri('result@outer-step') should also be possible.