XSLT and XPath something wrong

Go To StackoverFlow.com


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"

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:lvl="http://www.ohmeudeus.com lvlMl-v2.xsd">
<xsl:template match="lvl:map">
                normal title
            <link href="style.css" rel="stylesheet" type="text/css"/>
            The name is <xsl:value-of select="name"/>


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

2012-04-04 17:52
by Navy Seal


It's because the xmlns in your XML:


Does not match the xmlns in your XSLT:

xmlns:lvl="http://www.ohmeudeus.com lvlMl-v2.xsd"
2012-04-04 18:06
by Daniel Haley


I've spotted 2 problems.

  • The closing </xsl:stylesheet> is missing.
  • The <xmlns:lvl> should not have a schema location, only the namespace.

After fixing this you should get The name is String.

2012-04-04 18:05
by phlogratos
about the stylesheet closure it was a stack overflow paste error. i removed the lvlMl-v2.xsd from the xmlns:lvl and didnt changed anything but its true that was an erro - Navy Seal 2012-04-04 18:11


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">
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
      <title>normal title</title>
      <link href="style.css" rel="stylesheet" type="text/css" />
   <body>The name is String</body>
2012-04-04 19:19
by Kevan
"When I run the posted XLST with the namespace fixed against the posted XML I get the following." - The namespace was the only issue - Daniel Haley 2012-04-05 01:27