I've been losing lots of time trying to figure out how xslt's work
I have this xml
<?xml version="1.0" encoding="UTF-8"?>
<lvl:map xsi:schemaLocation="http://www.ohmeudeus.com lvlMl-v2.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:lvl="http://www.ohmeudeus.com">
<name>String</name>
<myColor>fffffffff</myColor>
</lvl:map>
and now i want to make an html, by using xslt, with the word String
so my xslt is something like
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:lvl="http://www.ohmeudeus.com lvlMl-v2.xsd">
<xsl:template match="lvl:map">
<html>
<head>
<title>
normal title
</title>
<link href="style.css" rel="stylesheet" type="text/css"/>
</head>
<body>
The name is <xsl:value-of select="name"/>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
the result gives me back both name and color like this:
String fffffffff
I don't understand what I'm doing wrong here... please help me...
Also i accept any tips you have to help me to find bugs
It's because the xmlns in your XML:
xmlns:lvl="http://www.ohmeudeus.com"
Does not match the xmlns in your XSLT:
xmlns:lvl="http://www.ohmeudeus.com lvlMl-v2.xsd"
I've spotted 2 problems.
</xsl:stylesheet>
is missing.<xmlns:lvl>
should not have a schema location, only the namespace.After fixing this you should get The name is String.
When I run the posted XSLT with the namespace fixed against the posted XML I get the following. Is this not the required output?
<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:lvl="http://www.ohmeudeus.com">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>normal title</title>
<link href="style.css" rel="stylesheet" type="text/css" />
</head>
<body>The name is String</body>
</html>