- From: Tobias Reif <tobiasreif@pinkjuice.com>
- Date: Tue, 29 Apr 2003 11:55:21 +0200
- To: public-qt-comments@w3.org
Hi I need to serialize forrests into the output (not to a file). There are more than four different ways to do this, but all I know are are clumsy and verbose. I suggest to add something like xsl:serialize to XSLT 2. Use cases: All cases where some tree or forrest is to be included in the result tree or forrest, in serialized form. This can be desired when the result of a transformation is to be included in a program listing. Real world example: http://www.pinkjuice.com/doxy/doc/ The content will move, so here's a pair of relevant snippets: (snightly formatted and shortened) # What it looks like in the browser: ################################# Literal Test 9 failed Input <simpara> <literal>foo</literal> </simpara> Desired Output <p class="simpara"> <span class="literal">foo</span> </p> Output <p class="simpara"> <!-- literal not yet fully supported --> foo </p> # The XHTML source ################################################### <div class="section"> <h3 class="title">Literal</h3> <h4 class="title">Test 9 <em>failed</em></h4> <h3 class="title">Input</h3> <div class="para"> <pre><code><simpara> <literal>foo</literal> </simpara></code></pre> </div> <h3 class="title">Desired Output</h3> <div class="para"> <pre><code><p class="simpara"> <span class="literal">foo</span> </p></code></pre> </div> <h3 class="title">Output</h3><div class="para"> <pre><code><p class="simpara"> <!-- literal not yet fully supported --> foo </p></code></pre> </div> </div> ###################################################################### Example showing the suggested feature: $snippet is a forrest, for example the result of a transformation: <xsl:variable name="snippet"> <xsl:apply-templates select="$input_snippet" mode="foo"/> </xsl:variable> Serialized it looks like this: <p>f</p> <p>f</p> Pseudo code showing what I suggest: ###################################################################### <xsl:output name="xml_snippet" method="xml" indent="no" omit-xml-declaration="yes" /> <programlisting> <xsl:serialize format="xml_snippet"> <xsl:copy-of select="$snippet"/> </xsl:serialize> </programlisting> # Output: ############################################################ <programlisting><p>f</p> <p>f</p></programlisting> ###################################################################### Definition of xsl:serialize: <!-- Category: instruction --> <xsl:serialize format = qname type-information = "strict" | "lax" | "preserve" | "none"> <!-- Content: content-constructor --> </xsl:serialize> xsl:serialize has the same attributes as xsl:result-document, except href. It serializes its content just as xsl:result-document does; But the result is output in place, instead of being written to a file. [an example like the above] ###################################################################### Alternatively, instead of adding xsl:serialize, the definition of xsl:result-document could be changed, to include something like "If the href attribute is present, the result of evaluating the xsl:result-document instruction is an empty sequence. This means it does not contribute any nodes to the result of the content constructor it is part of. If the href attribute is not present, the result of the serialization is output in place, and not written to a file. This means it contributes one text node [correct?] to the result of the content constructor it is part of." Tobi -- http://www.pinkjuice.com/
Received on Tuesday, 29 April 2003 05:56:21 UTC