#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    16
    Rep Power
    0

    Xsl template match="*" processing misunderstanding


    I am new to xsl and I am not completely understanding the transformation process. When I have the template with match="*" I am expecting that each node in the xml will match this template. Can someone explain what I am missing in my understanding of the transformation process with my example below. I though I would have gotten something from each node in my transformation output. Thank you very much.

    My sample xml:

    Code:
    <?xml version="1.0" encoding="utf-8"?>
    <treasure>
      <x>
        <stuff>jjj</stuff>
      </x>
    </treasure>
    My sample XSL:

    Code:
    <?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
     <xsl:template match="*">
     <xsl:copy/>
     </xsl:template>
     </xsl:stylesheet>
    My transformation Result:

    Code:
    <?xml version="1.0" encoding="utf-16"?><treasure />
  2. #2
  3. Did you steal it?
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    13,961
    Rep Power
    9397
    xsl:copy does not copy attributes or children of the node, only the node itself. Typically it's used as
    Code:
    <xsl:copy>
        <xsl:apply-templates select="@*|node()" />
    </xsl:copy>

IMN logo majestic logo threadwatch logo seochat tools logo