2011/9/28 Konstantin Kolinko <knst.koli...@gmail.com>:
> 2011/9/28 Paul Wilson <paulalexwil...@gmail.com>:
>> Hi there,
>>
>
> 1. What exactly build of Tomcat x.y.z  you are using?
>
>> I'm trying use taglibs with a JSPX page, but also specify a namespace
>> declaration for elements rendered by the JSP. An example:
>>
>> <foo:xyz xmlns:foo="path/to/foo/ns" xmlns:bar="path/to/bar/ns">
>>   <foo:p/>
>>   <bar:q/>
>> </foo:xyz>
>>
>> In the above example, I have a taglib registered for only 'foo', whereas I'd
>> like 'bar' to be considered verbatim and added to the body content as such.
>> What actually happens is the xmlns declaration is removed and is not made
>> available to the taglib component processing 'foo:xyz'. Jasper then
>> complains that 'bar' is not bound.
>>
>
> 2. What happens if you wrap all with <jsp:root> element and move your
> xmlns:bar there?
> (and not xmlns:foo like in your example below)
>
>> I've also tried:
>>
>> <jsp:root xmlns:jsp="..." version="2.1" xmlns:foo="path/to/foo/ns">
>>   <foo:xyz xmlns:bar="path/to/bar/ns">
>>         <foo:p/>
>>         <bar:q/>
>>   </foo:xyz>
>> </jsp:root>
>>
>
> 3. What version of specification is specified at the top of your web.xml file?


Just a quick test with current trunk of Tomcat:

Using the standard examples application that comes with Tomcat.
I edited the following page:
\webapps\examples\jsp\jsp2\jspx\textRotate.jspx

1) I replaced opening svg tag with:

<svg xmlns="http://www.w3.org/2000/svg";
     width="450" height="500" viewBox="0 0 450 500"
     xmlns:c="http://java.sun.com/jsp/jstl/core";
     xmlns:fn="http://java.sun.com/jsp/jstl/functions";
     xmlns:jsp="http://java.sun.com/JSP/Page";
     xmlns:foo="bar">
  <jsp:directive.page contentType="image/svg+xml" />
  <title>JSP 2.0 JSPX</title>
<foo:x>Bar!</foo:x>

Note xmlns declaration and foo:x element.

The page,
http://localhost:8080/examples/jsp/jsp2/jspx/textRotate.jspx?name=JSPX
renders correctly and gives me:

<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns:foo="bar" xmlns="http://www.w3.org/2000/svg"; viewBox="0 0
450 500" height="500" width="450"><title>JSP 2.0
JSPX</title><foo:x>Bar!</foo:x><g id="testContent">(....)


With correct xmlns:foo="bar" and <foo:x>Bar!</foo:x>.


2) But if I move xmlns declaration from <svg> element to the new
<jsp:root element> (adding it around the document):
<jsp:root version="2.2" xmlns:jsp="http://java.sun.com/JSP/Page";
xmlns:foo="bar">
<svg xmlns="http://www.w3.org/2000/svg";
     width="450" height="500" viewBox="0 0 450 500"
     xmlns:c="http://java.sun.com/jsp/jstl/core";
     xmlns:fn="http://java.sun.com/jsp/jstl/functions";
     >
  <jsp:directive.page contentType="image/svg+xml" />
  <title>JSP 2.0 JSPX</title>
<foo:x>Bar!</foo:x>

(...)
</jsp:root>

It generates invalid XML document where the foo prefix is not declared:
<svg xmlns="http://www.w3.org/2000/svg"; viewBox="0 0 450 500"
height="500" width="450"><title>JSP 2.0
JSPX</title><foo:x>Bar!</foo:x><g id="testContent"> (...)


So, from practical point of view, I think that the problem is the following:
- <jsp:root> tag by definition does not generate any content
- your custom tag can only generate text (from Tomcat perspective)

Thus it has no XML element in its possession to set xmlns attribute on it.
(Nor it is clever enough to add xmlns attribute to some other element,
as in the example of svg document it does not add it to the <svg>
element).

I think the cause for this behaviour might be that
the generated xml document can be included as a part into another xml
document (with <jsp:include>) and thus there should be a mechanism to
suppress unneeded xmlns declarations.

Best regards,
Konstantin Kolinko

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to