xsl-list
[Top] [All Lists]

Re: [xsl] deep copy without attributes

2013-05-20 18:02:36
On Mon, May 20, 2013 at 10:34:31PM +0100, Ihe Onwuka scripsit:
On Mon, May 20, 2013 at 8:48 PM, Graydon <graydon(_at_)marost(_dot_)ca> wrote:
You can't make the solution simpler than the problem.

But you can make the solution more complicated than the problem.

Say I wanted to copy a directory structure but not carry over the
symbolic links.

 I'd expect to be able to accomplish that  by setting an option on my
copy command rather than having to implement a recursive shell script.

Symbolic links, in XML terms, would be elements from some other tree
inserted by reference.  XML doesn't do that, and if it did do that,
there'd be a case for some kind of "is it really there, or referenced?"
distinction.  (Attributes, by file system analogy, would be things like
mtime and ctime.)

What you were describing, if I'm remembering it right, is wanting a
result tree that was just like your source tree only without the
attribute nodes.

<xsl:template match="node()">
    <xsl:copy>
        <xsl:apply-templates select="node()"/>
    </xsl:copy>
</xsl:template>

does that; it's not recursive, it's a single template.  It'll get
applied to all the nodes, but that's the magic of the XSLT declarative
model.

-- 
Graydon Saunders
graydon(_at_)marost(_dot_)ca

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