Re: [xsl] xsl:copy

Subject: Re: [xsl] xsl:copy
From: "Marrow" <marrow@xxxxxxxxxxxxxx>
Date: Sat, 6 Jul 2002 14:25:40 +0100
Hi,

Something like...

== XSL1 ==================================
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
  <xsl:param name="copy-lang">en</xsl:param>
  <xsl:template match="/|@*|node()">
    <xsl:copy>
      <xsl:apply-templates select="(@*|node())[descendant-or-self::*[@lang =
$copy-lang] or not(@lang)]"/>
    </xsl:copy>
  </xsl:template>
</xsl:stylesheet>
== end of XSL1 =============================

or, if your were using the @xml:lang attribute, e.g.

== XML2 ==================================
<?xml version="1.0"?>
<!-- comment -->
<?pitest xxx?>
<page>
  <title xml:lang="tr">Hoºgeldiniz</title>
  <title xml:lang="en">Wellcome</title>
  <description>
    assafs aszdfsd
    <sub-desc xml:lang="en">enenen</sub-desc>
    <sub-desc xml:lang="tr">trtrtr</sub-desc>
  </description>
  <test att1="abc" xml:lang="en">ABC</test>
  <test att1="xyz" xml:lang="tr">XYZ</test>
</page>
== end of XML2 =============================

then something like...

== XSL2 ==================================
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
  <xsl:param name="copy-lang">en</xsl:param>
  <xsl:template match="/|@*|node()">
    <xsl:copy>
      <xsl:apply-templates
select="(@*|node())[descendant-or-self::*[lang($copy-lang)] or
not(@xml:lang)]"/>
    </xsl:copy>
  </xsl:template>
</xsl:stylesheet>
== end of XSL2 =============================

Cheers
Marrow
http://www.marrowsoft.com - home of Xselerator (XSLT IDE and debugger)
http://www.topxml.com/Xselerator



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread