views:

4036

answers:

4

I've got some jsp files that are supposed to output xhtml. They seem to have the correct doctype etc but Eclipse is not parsing the xhtml attributes. For instance for the root element:

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

I get the warning: "Undefined attribute name (xmlns)." What's the best way to solve this in Eclipse?

edit: The doctype for this particular file was wrong apparently, it was set to:

<!DOCTYPE html PUBLIC 
   "-//W3C//DTD XHTML 1.1 Transitional//EN" 
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;

Which does not exist obviously. Eclipse is now complaining about taglib tags though, i.e.:

<%@taglib prefix="s" uri="/struts-tags" %>

generates the warning: "Tag (jsp:directive.taglib) should be an empty-element tag."

A: 

That seems odd, I use the same in Eclipse but with PHP and it works fine.

What is the DOCTYPE that you use? I've used

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;

Ian Devlin
I've accepted this since it answered the original question. Don't suppose you know how to fix the taglib error?
wds
A: 

Eventually, you can install JBoss Tools (update site for Eclipse, guides) which provides quite good XHTML / JSP editors.

romaintaz
+1  A: 

If you're going to ouput xml (in my understanding xhtml is xml) then you should be using the jsp document syntax, for instance your

<%@taglib prefix="s" uri="/struts-tags" %>

should instead be a namespace in some top-level tag. For the project I'm working on all the jsp are like this

<?xml version="1.0" encoding="UTF-8" ?>
<jsp:root version="2.0"
      xmlns:jsp="http://java.sun.com/JSP/Page"
      xmlns:c="http://java.sun.com/jsp/jstl/core"
      xmlns:fmt="http://java.sun.com/jsp/jstl/fmt"
      xmlns:fn="http://java.sun.com/jsp/jstl/functions"&gt;
<jsp:directive.page language="java"
    contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"/>
<jsp:text><![CDATA[<?xml version="1.0" encoding="UTF-8" ?> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;]]&gt;
</jsp:text>
<html xmlns="http://www.w3.org/1999/xhtml"&gt;
...
</html>
</jsp:root>
agnul
cheers, can't accept two answers (should've asked two questions really) but that looks like what I'll need.
wds
A: 

hello , i don't kown , how to use the "<%@taglib prefix="s" uri="/struts-tags" %>" in xhtml page?

<jsp:directive.taglib uri="/WEB-INF/struts-html.tld" prefix="html" /> too late? :-P
jneira