Re: [xsl] naive identity transform question

Subject: Re: [xsl] naive identity transform question
From: "Jesper Tverskov" <jesper.tverskov@xxxxxxxxx>
Date: Mon, 20 Nov 2006 23:47:30 +0100
I think my article:

will help you out.

Jesper Tverskov

On 11/20/06, Jon Crump <jjcrump@xxxxxxxxxxxxxxxx> wrote:
I'm sure this is a very straightforward task, but I'm missing something
fundamental about the identity transformation.

I want to copy an xml file exactly except if nodeX lacks a childY write
element Y.

The consensus on the identity transform suggested something like this:

xsl file identity.xsl

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

xsl file intended transformation.xsl

<xsl:import href="identity.xsl"/>

  <xsl:template match="//snotes:SourceNote[not(snotes:sourceDate)]">
      <xsl:element name="sourceDate"><xsl:text>0000-00-00</xsl:text></xsl:element>

IE: copy all elements complete, except where //snotes:SourceNote has no
snotes:sourceDate child. In that case, write a snotes:sourceDate element
with the value 0000-00-00.

Anyone willing to point out the obvious to the naive?

Current Thread