[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: copying namespaces question

Subject: Re: copying namespaces question
From: Wolfgang Laun <wolfgang.laun@xxxxxxxxx>
Date: Tue, 3 Jul 2012 10:57:13 +0200
Re:  copying namespaces question
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!

-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>

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.