xsl-list
[Top] [All Lists]

RE: Moving an element to a new location in the Result-tree

2005-09-07 18:39:44
Jim Graves wrote:
Good ideas! More details to get closer to a solution. It's copying and
maintaining the tree as it is, yet still not 'moving' (figuratively, not
literally, since it's a new tree) the elements to the new location in
the new (result) tree. I think I see your logic, but I'm still missing a
crucial insight. Can you pinpoint what it is -- to see the result
desired, below?

Your transformation is pretty good, but its output isn?t well-formed.

<xsl:template match="Transfer">
    <xsl:apply-templates select="Person"/>
</xsl:template>

That template causes the Transfer element to disappear; only its content
is output.

<xsl:template match="Person">
     <xsl:apply-templates select="*[not(self::OTHER_NAME)]"/>
     <xsl:apply-templates select="OTHER_NAME"/>
</xsl:template>

Similarly, this processes the contents of Person, but doesn?t output a
Person element itself.  Note this in my sample transform:

<xsl:template match="document1">
  <document222>
    <xsl:apply-templates select="*[not(self::b1)]"/>
    <xsl:apply-templates select="b1"/>
  </document222>
</xsl:template>

The template for document1 creates a document222 element, and processes
its own children inside that result element.  You need something more like

<xsl:template match="Person">
  <xsl:copy>
     <xsl:apply-templates select="*[not(self::OTHER_NAME)]"/>
     <xsl:apply-templates select="OTHER_NAME"/>
  </xsl:copy>
</xsl:template>

~Chris
-- 
Christopher R. Maden, Principal Consultant, crism consulting
XML-SGML-HTML-DTDs-schemas-XSL-DSSSL-conversion-training-ebooks-B2B
<URL: http://crism.maden.org/consulting/ >
PGP Fingerprint: BBA6 4085 DED0 E176 D6D4  5DFC AC52 F825 AFEC 58DA


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