File TestXSL.xml
<?xml version="1.0" ?>
<?xml-stylesheet type="text/xsl" href="TestXSL.xsl"?>
<MyRoot version="1.0" date="2002-01-28" time="10:16:46" readOnly="false" language="English">
Testing, testing.
</MyRoot>
File TextXSL.xsl
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XLS/Transform">
<xsl:template match="/">
<HTML><HEAD><TITLE>Test XSL</TITLE>
</HEAD>
<BODY>
<xsl:value-of select="MyRoot/@language"/>
</BODY>
</HTML>
</xsl:template>
</xsl:stylesheet>
For testing purposes, I’d like it to simply display the word “English”, the value of the language attribute. I’ve tried lots of variations, trying to figure out what I’m doing wrong. Why doesn’t this work?!
Your code worked for me. I did add this line to the transform, though:
<xsl:output method="xml" indent="yes" encoding="UTF-8" />
Here’s the output I got:
<?xml version="1.0" encoding="UTF-8"?>
<HTML><HEAD><TITLE>Test XSL</TITLE>
</HEAD>
<BODY>English</BODY>
</HTML>
PS - I forgot, I did change one line in your source - a typo:
<xsl:stylesheet version=“1.0” xmlns:xsl=“http://www.w3.org/1999/XSL/Transform”>
You had XLS instead of XSL
Er. So typos make a difference in computer programing? :smack:
Many thanks.
No problem! Get used to hard-to-find XSL typos - it seems to happen more often than other languages. XPATH expressions are especially prone to it, since it will usually just silently fail to match, leaving you no clue where things have gone wrong.
In fact, I’m so used to it that it didn’t even register in my brain when I fixed the typo to get your code to work, and didn’t mention it in my first post!
Arjuna34