Loading...

xsl-list@lists.mulberrytech.com

[Prev] Thread [Next]  |  [Prev] Date [Next]

Re: [xsl] Multiple Template Matchingm, Attributes & Complex XML Martin Honnen Fri Feb 25 11:00:48 2011

Jeffry Proctor wrote:
ASP.Net 2008, Linq XmlCompiledTransform, XSLT ver 1.0 I assume?

1. Limited as I am, the Person node/element&  attribute is updating correctly;
How do I add other node/element?
I assume it will be to remove Person as the top level match, but I'm not finding
examples for making XML, many for HTML and mutilple tables sometimes nesting,
but for some reason that doesn't speak to me.

If you want to tranform XML to XML and you want to copy some elements, add some other, maybe delete some other then start with the template

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

That is the identity transformation template that (on its own) copies the input tree to the result tree, node by node, level by level.

Now you can add templates for the element nodes you want to change e.g.

  <xsl:template match="foo">
    <!-- make this a 'bar' element -->
    <bar>
      <xsl:apply-templates select="@* | node()"/>
    </bar>
  </xsl:template>

  <xsl:template match="baz">
    <!-- copy but add new child -->
    <xsl:copy>
      <xsl:apply-templates select="@* | node()"/>
      <new-element>...</new-element>
    </xsl:copy>
  </xsl:template>

or for the ones you want to delete e.g.
  <!-- don't copy 'foobar' -->
  <xsl:template match="foobar"/>


Does that help? If not then please post a sample of the input you have and the output you want to create from it.

--

        Martin Honnen
        http://msmvps.com/blogs/martin_honnen/

--~------------------------------------------------------------------
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:[EMAIL PROTECTED]>
--~--