Output of p:xslt and p:xslt2 / xpointer

I don't think prohibiting text transformations by saying
"
This step does not serialize the result document. Any serialization
parameters specified on a xsl:output element inside the stylesheet are
ignored. Further, the output on the result port must be a well-formed XML
document; transformations that use non-XML output methods (e.g. the 'text'
method) may cause a dynamic error.
"
Is a solution. There are certainly use cases where one may need text output
or (especially!) HTML output. XProc should answer those uses cases somehow.

How about placing all output in a c:result element?

If the transformation uses the "xml" or "xhtml" method (regardless of
whether the actual XML output has one or more elements at the root level)
place all of the output "as is" in the c:result element, so that for example
<root/>
<root/>
Would become
<c:result>
<root/>
<root/>
</c:result>

If the transformation uses the "html" method, serialize with the "xhtml"
method instead, thus resulting in the same thing as above, with HTML
specifics in mind. In the case of XSLT 1.0 transformations, implementations
may reparse the output to turn it into XML or simply switch transformations
using "html" to "xml".

If the transformation uses the "text" method or another non "xml" method,
escape all output and place it in the c:result, so that for example the text
'This is greater than (">") me and less than ("<") us and ("&") the rest of
the world'
Would be seen by XProc as
<c:result>This is greater than ("&gt;") me and less than ("&lt;") us and
("&amp;") the rest of the world</c:result>

This does create a problem though. XProc would need to provide some way with
which a fragment of this result could be selected. I mean, how would you for
example save only the output of a transformation to an URI if p:store would
save the whole document? I see a possible solution with XPointer. A new
attribute "xpointer" could be added to p:pipe, and p:document to select only
portions of XML documents.

For example: 
<p:pipeline>
	<p:xslt name="transform">
		<p:input port="source">
			<p:document href="document.xml" xpointer="/*/*[1]"/>
		</p:input>
		<p:input port="stylesheet">
			<p:document href="document.xml" xpointer="/*/*[2]"/>
		</p:input>
	</p:xslt>
	<p:store href="result.xml">
		<p:input port="source">
			<p:pipe step="transform" port="result"
xpointer="c:result/*[1]"/>
		</p:input>
	</p:store>
</p:pipeline>

Will transform the contents of the first element from document.xml with a
stylesheet that is actually the second element of that same document and
save the exact output of the transformation to "result.xml".

Since XPointer could select text nodes as well, I assume some steps (notably
p:store) should make it clear if they DO allow text nodes to be matched. The
spec will have to say somewhere (I assume in xpointer's definition) "unless
otherwise indicated by a step, the xpointer attribute must select a single
element node".

Regards,
Vasil Rangelov

Received on Saturday, 29 September 2007 09:52:47 UTC