xsl-list
[Top] [All Lists]

Re: [xsl] copying namespaces question

2012-07-03 03:57:34
On 03/07/2012, Robby Pelssers <Robby(_dot_)Pelssers(_at_)nxp(_dot_)com> 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!

-W

<xsl:stylesheet version="2.0"
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
   xmlns:mycompany="www.mycompany.com">

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

    <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:copy>
            <xsl:apply-templates select="@*"/>
            <xsl:copy-of select="$elem"/>
          </xsl:copy>
        </xsl:result-document>
      </xsl:for-each>
    </xsl:template>

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

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>