- From: Michael Kay <mhk@mhk.me.uk>
- Date: Mon, 9 Feb 2004 16:10:10 -0000
- To: "'Andre Cusson'" <ac@hyperbase.com>, <public-qt-comments@w3.org>
Thanks for the comment, Andre. The WG will discuss this. I personally
sympathize with the requirement; I think the simplest solution might be
to make the format attribute into an AVT. I don't actually recall why we
removed the individual serialization parameters from the
xsl:result-document element but there was probably a good reason.
Michael Kay
> -----Original Message-----
> From: public-qt-comments-request@w3.org
> [mailto:public-qt-comments-request@w3.org] On Behalf Of Andre Cusson
> Sent: 09 February 2004 14:02
> To: public-qt-comments@w3.org
> Subject: parametrized result-document
>
>
>
> Hi,
>
> In XSLT1.1, attributes like method and indent could easily be
> parametrized
> or calculated.for the xsl:document instruction, allowing one,
> for example,
> to render some documents in HTML, others in XML, some with
> indentation,
> some not.
>
> With XSLT2.0, there seems to be no way to parametrize the
> output format of
> a document :
>
> One can define multiple corresponding xsl:output
> instructions, each with a
> different specific combination of output format attributes;
> then one can
> define an xsl:result-document instruction and assign the
> corresponding
> xsl:output format name to the xsl:result-document format
> attribute, but the
> format attribute is a litteral QName and cannot be assigned,
> calculated, or
> parametrized, even with cast to xs:QName. The only remaining
> alternative
> is to duplicate the xsl:result-document instruction block (and an
> xsl:output instruction) for every possible xsl:output attribute value
> combination and to xsl:choose between them, based on the
> specific values
> and their combination.
>
> I find this inelegant, clumsy, redundant and difficult to maintain.
>
> Why can't result-document have its own output attributes ?
>
> If not, why can't the xsl:result-document format attribute be
> assigned a
> value other than a litteral QName ?
>
> Serializing output documents is a fundamental operation in
> XSLT and it
> should be parametrizable.
>
> Why separate the output format attribute from the only
> instruction that
> uses them ?
>
> Why force a litteral QName to join them later ?
>
> Thank you.
>
> Andre
>
>
> Here is some sample code of what it may look like in XSLT2.0
> if you could
> assign to the format attribute. Now, this does not work.
>
> <xsl:output name="xmlyes" method="xml" version="1.0"
> encoding="ISO-8859-1" omit-xml-declaration="no" indent="yes"
> media-type="text/html"/>
> <xsl:output name="xmlno" method="xml" version="1.0"
> encoding="ISO-8859-1" omit-xml-declaration="no" indent="no"
> media-type="text/html"/>
> <xsl:output name="htmlyes" method="html" version="1.0"
> encoding="ISO-8859-1" omit-xml-declaration="no" indent="yes"
> media-type="text/html"/>
> <xsl:output name="htmlno" method="html" version="1.0"
> encoding="ISO-8859-1" omit-xml-declaration="no" indent="no"
> media-type="text/html"/>
> ...
> <xsl:template name="persist-file">
> ...
> <xsl:result-document href="filename"
> format="{xs:QName(concat(@method, @indent))}">
> <xsl:apply-templates
> mode="buildpage" select="."/>
> </xsl:result-document>
>
> or even
>
> <xsl:result-document href="filename">
> <xsl:attribute name="format"><xsl:value-of
> select="xs:QName(concat(@method, @indent))"/></xsl:attribute>
> <xsl:apply-templates
> mode="buildpage" select="."/>
> </xsl:result-document>
> ...
> </xsl:template>
>
>
>
> Here is a sample of what works today, if we only have four
> attribute value
> combinations :
>
> <xsl:output name="xmlyes" method="xml" version="1.0"
> encoding="ISO-8859-1" omit-xml-declaration="no" indent="yes"
> media-type="text/html"/>
> <xsl:output name="xmlno" method="xml" version="1.0"
> encoding="ISO-8859-1" omit-xml-declaration="no" indent="no"
> media-type="text/html"/>
> <xsl:output name="htmlyes" method="html" version="1.0"
> encoding="ISO-8859-1" omit-xml-declaration="no" indent="yes"
> media-type="text/html"/>
> <xsl:output name="htmlno" method="html" version="1.0"
> encoding="ISO-8859-1" omit-xml-declaration="no" indent="no"
> media-type="text/html"/>
> ...
> <xsl:template name="persist-file">
> ...
> <xsl:choose>
> <xsl:when test="@indent = 'yes' ">
> <xsl:choose>
> <xsl:when test="@method = 'xml' ">
> <xsl:result-document
> href="filename" format="xmlyes">
>
> <xsl:apply-templates mode="buildpage" select="."/>
> </xsl:result-document>
> </xsl:when>
> <xsl:when test="@method = 'html' ">
> <xsl:result-document
> href="filename" format="htmlyes">
>
> <xsl:apply-templates mode="buildpage" select="."/>
> </xsl:result-document>
> </xsl:when>
> </xsl:choose>
> <xsl:when>
> <xsl:when test="@indent = 'no' ">
> <xsl:choose>
> <xsl:when test="@method = 'xml' ">
> <xsl:result-document
> href="filename" format="xmlno">
>
> <xsl:apply-templates mode="buildpage" select="."/>
> </xsl:result-document>
> </xsl:when>
> <xsl:when test="@method = 'html' ">
> <xsl:result-document
> href="filename" format="xmlno">
>
> <xsl:apply-templates mode="buildpage" select="."/>
> </xsl:result-document>
> </xsl:when>
> </xsl:choose>
> <xsl:when>
> </xsl:choose>
> ...
> </xsl:template>
>
>
> Finally, in XSLT1.1, this is all that is required (whatever
> the number of
> attribute value combinations) isn't this much nicer ?
>
> <xsl:template name="persist-file">
> ...
> <xsl:document href="filename" method="@method"
> indent="@indent"
> version="@version" media-type="@media-type" encoding="@encoding"
> omit-xml-declaration="@omit-xml-declaration">
> <xsl:apply-templates mode="buildpage"
> select="."/>
> </xsl:result-document>
> ...
> </xsl:template>
>
>
> What happens, in XSLT2.0, if we need to support more methods
> and if we also
> need to vary the version number, the encoding, the
> omit-xml-declaration,
> and the media-type ?
>
Received on Monday, 9 February 2004 11:09:50 UTC