[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] copying namespaces question

Subject: Re: [xsl] copying namespaces question
From: Wolfgang Laun <wolfgang.laun@xxxxxxxxx>
Date: Tue, 3 Jul 2012 10:57:13 +0200

On 03/07/2012, Robby Pelssers <Robby.Pelssers@xxxxxxx> wrote:
> For the ones interested ... I wrote an article explaining 2 approaches used
> to solve the problem:

This is the solution I had in mind when I wrote that copying (rather than
constructing) the element might avoid hard-coding the namespace. It's
not as elegant as the other solution but I hope that it isn't marred by
serious flaws. If so, I'd like to learn!


<xsl:stylesheet version="2.0"

    <xsl:template match="/mycompany:objects">
       <xsl:apply-templates select="./*">
         <xsl:with-param name="root" select="."/>

    <xsl:template match="mycompany:object">
      <xsl:param name="root"/>
      <xsl:variable name="elem" select="."/>
      <xsl:for-each select="$root">
        <xsl:result-document href="{concat('file:///home/wlaun/XSLT/',
                                   $elem/mycompany:name, '.xml')}" method="xml">
            <xsl:apply-templates select="@*"/>
            <xsl:copy-of select="$elem"/>

    <xsl:template match="@*">
      <xsl:copy-of select="."/>

Current Thread