简体   繁体   中英

What is wrong with this simple XSL Transformation

I am learning XSLT and trying out a very simple example. Here is what I tried -

The source XML file which I want to transform -

<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="reverse.xslt"?>
<Configuration>
  <MyConfiguration>
    <Value>
    </Value>
  </MyConfiguration>
</Configuration>

The transformation in the reverse.xslt file -

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

When I open the source file in IE7 I am expecting the output to be -

<testNode>
  abc
</testNode>

However what I get is

abc

Where is it going wrong?

Edit: Both source and the transformation file are in the same folder.

your xslt is absolutely correct and is also producing the output you expact. But HTML-Browsers are made to display HTML code. So your expected output <testNode> abc </testNode> will also be interpreated as HTML an so only the text will be shown, as testNode is not a valid HTML-Tag.

If you open your file with Firefox and inspect it with firebug you will see what you expected.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM