Re: [xsl] XSLT template from XSLT + XML

Subject: Re: [xsl] XSLT template from XSLT + XML
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Mon, 30 Sep 2002 18:37:16 -0400
Mike,

At 06:16 PM 9/30/2002, you wrote:
> I guess that you haven't discovered the delights of
> xsl:namespace-alias, then. You can define an "alias" namespace which
> takes the place of the XSLT namespace within your stylesheet and then
> gets replaced on output. That makes it a lot easier to write the
> stylesheets (though it's still a little confusing) because you can use
> literal result elements rather than xsl:element/xsl:attribute.

Delight is exactly the word I would use!

That made what I was trying to do as easy as a search and replace.

Just out of curiosity, is it possible to create a stylesheet that will go in
and recreate all elements and attributes?  I can see it being possible for
the elements, but the attributes would be tough, unless you can do a
for-each select="attributes" type of thing.

What's wrong with xsl:apply-templates select="@*"/> ?


If you're referring to an identity stylesheet ("recreate all elements and attributes"), it works with a single template, that looks like this:

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

This variant copies all element and attribute nodes, preserving their organization, but leaves processing instructions and comments out.

It's the basis for quite a number of utility operations (and a FAQ).

Cheers,
Wendell


====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Direct Phone: 301/315-9635 Suite 207 Phone: 301/315-9631 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ======================================================================


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



Current Thread