- This topic has 7 replies, 3 voices, and was last updated 18 years, 7 months ago by
Riyad Kalla.
-
AuthorPosts
-
henkMemberI’m not sure whether I have to post this as a regular question, a bug report or a feature request but here it goes anyway:
We’re having some JSP pages that process an XML fragment. The problem is that people tend to make mistakes in writing down the XML. In case of using a seperate file (.xml) the Eclipse XML editor utilizes the supplied XSD of DTD for validation. I’m not sure what I need to do (much less if it’s possible at all) for making this work in the JSP editor.
For example a stripped down version of what we are using.
<c:if test="${customer.payed}" > <or:order id="foobarkaz" > <or:item id="xyz" price="1200" description="A shiny new iMac" /> </or:order> </c:if>
In this case, one would like to have both validation and autocompletion on the XML elements in the or namespace. Adding the .xld to the xmlns:or attribute of the jsp:root element does not help.
Also, if I’m not mistaken JSP 2.0 allows for introducing namespaces in local elements, e.g.:
<c:if test="${customer.payed}" > <orders xmlns:or="http://www.mycomp.com/orders.xsd" > <or:order id="foobarkaz" > <or:item id="xyz" price="1200" description="A shiny new iMac" /> </or:order> </orders> </c:if>
But this also does not trigger the editor into doing validation.
Any thoughts on this?
Riyad KallaMemberCan you post a full page example that I can copy and paste into tools on my end to test it out? Please make sure the example uses all publically available resources so I don’t have resolution problems.
It might be a bug… I didn’t even know you could do this.
henkMember@support-rkalla wrote:
Can you post a full page example that I can copy and paste into tools on my end to test it out? Please make sure the example uses all publically available resources so I don’t have resolution problems.
I’m just about to leave for a long-weekend away, but I’ll put something together next week.
[quote
It might be a bug… I didn’t even know you could do this.You can read about this feature in the official JSP 2.0 spec, which can be downloaded from SUN. At page 1-143 (on top of page, real page number is 179), section 6.4.2 it given an example of Generating Namespace-aware documents. No I might be mistaken, but I think this is exactly what I’m looking for.
To quote directly from the spec:
JSP.6.4.2 Example: Generating Namespace-aware documents
<table xmlns="http://table.com/Table1" size="${3}"> <c:forEach xmlns:c="http://java.sun.com/jsp/jstl/core" var="counter" begin="1" end="${3}"> <row>${counter}</row> </c:forEach> </table>
This example is essentially the same as the one above, except that a default
namespace is introduced in the top element The namespace applies to the unqualified
elements: <table> and <row>. Also note that if the default namespace were to
correspond to a custom action, then the elements so effected would be interpreted as
invocations on custom actions or tags.Although the JSP container understands that this document is a namespaceaware
document. the JSP 2.0 container does not really understand that the
generated content is a well-formed XML document and, as the next example
shows, a JSP document can generate other types of content.In this example I would like the editor to validate that <table> and <row> are valid, but for example <rwo> would not be valid.
arjan.tijmsMemberLike Henk we also need XML validation in the JSP editor, although we use it for a different purpose. We don’t generate XML from the JSP document, but we have created a set of taglib tags that take an XML fragment as input (using <jsp:attribute>). Whether XML is send to the response or not should really not matter for the editor.
For example, suppose I wanted to use the Quartz job scheduling XML format in a JSP document. This might look a bit like this:
<jsp:root version="2.0" xmlns="http://www.w3.org/1999/xhtml" xmlns:jsp="http://java.sun.com/JSP/Page" xmlns:q="http://www.opensymphony.com/quartz/JobSchedulingData" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opensymphony.com/quartz/JobSchedulingData http://www.opensymphony.com/quartz/xml/job_scheduling_data_1_5.xsd" > <jsp:directive.page contentType="text/html;charset=UTF-8"/> <q:job> <q:job-detail> </q:job-detail> </q:job> </jsp:root>
In this example, the JSP 2.0 container (e.g. Tomcat 5.5) understands that “q” relates to the namespace “http://www.opensymphony.com/quartz/JobSchedulingData” and doesn’t resolve to a taglib. If you’d try to execute this JSP document, you’ll find the namespaced XML fragment in your output (instead of an error for not being able to locate a tld).
Unfortunately, the MyEclipse editor does not use the provided schema to do a validation of the XML elements used on the page for that namespace.
Riyad KallaMemberarjan,
If you can send along a sample project with example pages (more than just this one if it’s valuable, if not, I’ll just use this one) for us to test again that would help immensly. (support@genuitec.com ATTN Riyad, with a link to this thread so I know why I’m getting it).
arjan.tijmsMemberHi Riyad,
The example I gave you above is basically it, there’s really not more to it than that. You might want to use the given fragment as attribute or body of a taglib tag, but for the editor that shouldn’t matter.
For example:
<custom:myTag> <q:job> <q:job-detail> </q:job-detail> </q:job> </custom:myTag>
Here myTag would be resolved from a .tld file and is a regular taglib tag (an action as the official spec calls it).
A slightly different variation would be:
<custom:myTag> <jsp:attribute name="someAttribute" > <q:job> <q:job-detail> </q:job-detail> </q:job> </jsp:attribute> </custom:myTag>
Hope this helps.
henkMemberAny updates on this yet?
Riyad KallaMemberNo, this will likely come later with editor updates the first of which will go into 5.0.3, then more in 5.1. I have no commitment from management on this yet.
-
AuthorPosts