RE: [Serial] additional last call comment about xml:lang

Yes, this code looks correct.

Michael Kay 

> -----Original Message-----
> From: public-qt-comments-request@w3.org 
> [mailto:public-qt-comments-request@w3.org] On Behalf Of Martin Duerst
> Sent: 27 May 2004 07:26
> To: Michael Kay; public-qt-comments@w3.org
> Cc: w3c-i18n-ig@w3.org; 'Liam Quin'
> Subject: RE: [Serial] additional last call comment about xml:lang
> 
> 
> At 08:47 04/05/26 +0100, Michael Kay wrote:
> 
> > > Hello Michael,
> > >
> > > Are you saying that this can indeed be done with a single 
> invocation
> > > of an XSLT implementation, with a single stylesheet? Your use of
> > > "pre-processing phase" and so on in your previous mail wasn't
> > > totally clear on this, at least not for me.
> >
> >Yes, it can all be done within a single transformation in a single
> >stylesheet.
> 
> This sounds great!
> 
> > > If this is true, it would be very nice, and I would 
> assume that our
> > > WG would then be very happy with the result. For our 
> reference, can
> > > you please either point to the section in the spec where this
> > > multi-pass thing is described, or can you resend the code in
> > > your earlier mail with some framework code added that shows how
> > > to define the various passes?
> >
> >There's a simple example showing how temporary trees can be 
> used to support
> >multi-phase transformations in section 9.4 of the spec:
> >
> >http://www.w3.org/TR/xslt20/#temporary-trees
> >
> >I'm afraid I'm too busy today to do a worked example for you.
> 
> Okay, I took this example, and the code fragments that you sent
> earlier, and put something together below. I'd appreciate if you
> could check it. I'm not sure I got everything right, in particular
> all the modes.
> 
> How to create a stlyesheet that cleanly copies xml:lang:
> [assuming for simplicity that all xml:lang information
> is comming from the source, not from the stylesheet, and
> that only whole elements are transferred, not independent
> textual pieces]
> [I'm using a tree-pass solution; this could be done in
> many cases as a two-pass solution]
> 
> - Start with your stylesheet.
> - Make sure that on all elements, xml:lang is copied.
> - Assumes that the main mode for the original stylesheet
>    is the default mode.
> 
> 
> <xsl:stylesheet
>    version="2.0"
>    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
> 
> <xsl:template match="*" mode="expandXmlLang">
>    <xsl:copy>
>      <xsl:copy-of select="@* | 
> ancestor-or-self::*/@xml:lang[last()]"/>
>      <xsl:apply-templates mode="expandXmlLang"/>
>    </xsl:copy>
> </xsl:template>
> 
> <xsl:template match="*" mode="cleanXmlLang">
>    <xsl:copy>
>      <xsl:copy-of select="@* except @xml:lang[. =
> ancestor::*/@xml:lang[last()]]"/>
>      <xsl:apply-templates mode="cleanXmlLang"/>
>    </xsl:copy>
> </xsl:template>
> 
> <!-- rest of your stylesheet here or somewhere -->
> 
> <xsl:variable name="xmlLangExpanded">
>    <xsl:apply-templates select="/" mode="expandXmlLang"/>
> </xsl:variable>
> 
> <xsl:variable name="processedMain">
>    <xsl:apply-templates select="$xmlLangExpanded" mode="#default"/>
> </xsl:variable>
> 
> <xsl:template match="/">
>    <xsl:apply-templates select"$processedMain" mode="cleanXmlLang"/>
> <xsl:template>
> </xsl:stylesheet>
> 
> 
> Regards,     Martin.
> 

Received on Thursday, 27 May 2004 06:56:50 UTC