开发者

What is wrong with this simple XSL Transformation

开发者 https://www.devze.com 2023-02-06 21:22 出处:网络
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 -

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 transfo开发者_C百科rmation 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消