Question I need help understanding the xsl transformation process of xml.

groadsvb

Well-known member
Joined
Nov 13, 2006
Messages
75
Programming Experience
Beginner
I am missing a key point of the xsl transformation process. This makes getting the result I want very challanging. If some one would look at my sample maybe they can explain my faulty idea of how the processing work. With the example below I thought I would at least have a result that included "Now on the root" since there is a root to the xml and to see "got my stuff" since two nodes match that template. I overrode the two templates on purpose to stop their output. Why am I wrong in the assumption? Thanks.

My sample XML:

VB.NET:
<?xml version="1.0" encoding="utf-8"?>
<treasure>
  <x>
    <stuff>jjj</stuff>
    <stuff>rrrr</stuff>
  </x>
</treasure>


My sample XSL:

VB.NET:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/">
  Now on the root
</xsl:template>

<xsl:template match="*|/">
</xsl:template>

 <xsl:template match="text()|@*">
 </xsl:template>

<xsl:template match="//stuff">
  got my stuff
</xsl:template>

</xsl:stylesheet>


The results I am getting, but not expecting:

VB.NET:
<?xml version="1.0" encoding="utf-16"?>
 
I thought I would at least have a result that included "Now on the root" since there is a root to the xml
Add some output to your other templates and see which one match.
and to see "got my stuff" since two nodes match that template
You're not selecting any 'stuff' nodes.
 
Back
Top