parameterizing serialization

Hi,

I do realize that I had suggested using override serialization attributes 
for result-document but further requirements and experience allowed me to 
see that further improvements are possible and would be simpler, more 
elegant and more in tune with XSLT2.0 and the <xsl:output/> 
approach/philosophy.  The solution requires that the format attribute is 
not limited to a literal QName.  For example, given something like:

         <xsl:output method="xml" version="1.0" encoding="UTF-8" 
omit-xml-declaration="no" indent="yes" media-type="application/xml"/>
         <xsl:output name="jasper" method="xml" version="1.0" 
encoding="UTF-8" omit-xml-declaration="no" indent="yes" 
media-type="application/xml" 
doctype-system="http://jasperreports.sourceforge.net/dtds/jasperreport.dtd" 
doctype-public="//JasperReports//DTD Report Design//EN"/>
         <xsl:output name="xmlyes" method="xml" version="1.0" 
encoding="UTF-8" omit-xml-declaration="no" indent="yes" 
media-type="application/xml"/>
         <xsl:output name="xmlno" method="xml" version="1.0" 
encoding="UTF-8" omit-xml-declaration="no" indent="no" 
media-type="application/xml"/>
         <xsl:output name="htmlyes" method="html" version="1.0" 
encoding="UTF-8" omit-xml-declaration="no" indent="yes" 
media-type="text/html"/>
         <xsl:output name="htmlno" method="html" version="1.0" 
encoding="UTF-8" omit-xml-declaration="no" indent="no" media-type="text/html"/>
         <xsl:output name="packed" method="xml" version="1.0" 
omit-xml-declaration="yes" encoding="UTF-8" indent="no" 
media-type="text/html"/>


and a doctype variable set to the name of one of these output formats, I 
would rather have :

         <xsl:result-document href="{$path}" format="{$doctype}">
                 <xsl:apply-templates mode="buildpage" select="."/>
         </xsl:result-document>


than:

<xsl:choose>
         <xsl:when test="$doctype = 'jasper'">
                 <xsl:result-document href="{$path}" format="jasper">
                         <xsl:apply-templates mode="buildpage" select="."/>
                 </xsl:result-document>
         </xsl:when>
         <xsl:when test="$doctype = 'xmlyes'">
                 <xsl:result-document href="{$path}" format="xmlyes">
                         <xsl:apply-templates mode="buildpage" select="."/>
                 </xsl:result-document>
         </xsl:when>
         <xsl:when test="$doctype = 'xmlno'">
                 <xsl:result-document href="{$path}" format="xmlno">
                         <xsl:apply-templates mode="buildpage" select="."/>
                 </xsl:result-document>
         </xsl:when>
         <xsl:when test="$doctype = 'htmlyes'">
                 <xsl:result-document href="{$path}" format="htmlyes">
                         <xsl:apply-templates mode="buildpage" select="."/>
                 </xsl:result-document>
         </xsl:when>
         <xsl:when test="$doctype = 'htmlno'">
                 <xsl:result-document href="{$path}" format="htmlno">
                         <xsl:apply-templates mode="buildpage" select="."/>
                 </xsl:result-document>
         </xsl:when>
         <xsl:otherwise>
                 <xsl:result-document href="{$path}" format="xmlyes">
                         <xsl:apply-templates mode="buildpage" select="."/>
                 </xsl:result-document>
         </xsl:otherwise>
</xsl:choose>


or even than:

         <xsl:result-document href="{$path}" method="{$method}" 
indent="{$indent}" encoding="{$encoding}" version="{$version}" 
omit-xml-declaration="{@omit-xml-declaration}" 
doctype-system="{@doctype-system}" doctype-public="{@doctype-public}" 
media-type="{@media-type}">
                 <xsl:apply-templates mode="buildpage" select="."/>
         </xsl:result-document>


I thank you for your consideration, hoping that something can still be done 
to improve the standard before its official release.

Andre Cusson
01 COMMUNICATIONS
(1) 514 583 0601

Received on Thursday, 7 April 2005 15:25:14 UTC