You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by "Uther, James" <Ja...@F-Secure.com> on 2001/09/27 16:18:56 UTC

RE: %=x% expression syntax in template text

Hi Eduardo,

I had to go and check the tomcat-dev archives for your mail :) sorry it's
taken a while to reply.

The problem with using something like

<jsp:element name="text">
  <jsp:attribute name="y" value="10"/>
  <jsp:attribute name="x" value="%=xpos%"/>
</jsp:element>

is that the result is no longer a *valid* chunk of SVG document. or rather,
the <svg:text> tag will not be checked as such by a validating parser.

As it stands i've gone back to the old jsp syntax and am not worrying about
validity. However, in a perfect world (tm) it'd be nice to have a jsp page
with xhtml+svg+mathml and jsp namespaces that a validating parser would
accept. But perhaps that's what xslt is for...

cheers, 

james

>-----Original Message-----
>From: Eduardo Pelegri-Llopart [mailto:pelegri@sun.com]
>Sent: Thursday, September 27, 2001 5:07 PM
>To: Uther, James
>Cc: jsp-spec-comments@eng.sun.com
>Subject: Re: %=x% expression syntax in template text
>
>
>Did you see the reply I posted to tomcat-dev?  Does that help you?
>
>	- eduard/o
>

Re: %=x% expression syntax in template text

Posted by Eduardo Pelegri-Llopart <pe...@sun.com>.
Hi James,

I think I understand what you mean: that the source of the JSP does not
validate against a SVG schema/DTD.  But there are just a few things that
you can do in JSP that will preserve that; simple template expansion
will but many others won't.  This is not at all a JSP-specific problem,
you will encounter it in any powerful enough mechanism that generates 
content.

If I got it right, you want to know that the JSP you are authoring will
generate valid SVG documents.  I can think of at least three approaches.

One approach is the one you are exploring, look for pages that will
satisfy all the constraints (using some name-space aware validation
mechanism, like XML schema).  In JSP 1.2, that approach does have the
problem you are describing: in the XML syntax there is no expression
substitution inside template data (XML fragments).  We are about to
start working on JSP 1.3, I'm recording this as an RFE that we can
discuss within the expert group.

Another approach is to test the validity of the generated content at
generation time.  This may be expensive but if you are doing enough
caching anyhow, it may be workable.

Another approach is to use the TagLibraryValidator mechanism of JSP 1.2
to do the validation.  That mechanism is quite open-ended so you could
arrange the following:

 * Use a specific tag library to do your SVG generation.  Say that has
the x:element and x:attribute I mentioned.
 * Associate a TagLibraryValidator to that tag library
 * Author in XML syntax, as you were trying to do.
 * The TLV for that tag library can now:
  ** take the XML view of the JSP page (essentially the same XML syntax
you used) and instead of just validating the tree against the SVG
schema, it will first do a pass where the uses that you are doing are
replaced by the relevant stand-in (e.g. <x:element
name="text">...<x:attribute/>...</x:element> is replaced by
"<svg:text...>"
  ** now use the SVG schema to do the validation.

This approach can be extended to do similar things with other tags.  It
should not be that hard to do and since everything happens at
translation time, the performance is not super-critical.  It does have
some limitations.  For example the validation of one tag library cannot
pass information to other tag libraries validations.  And if a custom
action is very complex you may not be able to replace it with a
'representative' fragment.  But, from what you have said, it seems that
you could do something like that.

I like this third approach because it is all translation-time and it
gives the author very strong confidence on what it is doing.

If you follow this approach let me know.  I'm interested in how it goes
since we could try to expand on this approach for JSP 1.3.  And, as I
said, it is possible that we will do something in JSP 1.3 that would
address the simple expansion approach.

Hope this helps,

	- eduard/o

"Uther, James" wrote:
> 
> Hi Eduardo,
> 
> I had to go and check the tomcat-dev archives for your mail :) sorry it's
> taken a while to reply.
> 
> The problem with using something like
> 
> <jsp:element name="text">
>   <jsp:attribute name="y" value="10"/>
>   <jsp:attribute name="x" value="%=xpos%"/>
> </jsp:element>
> 
> is that the result is no longer a *valid* chunk of SVG document. or rather,
> the <svg:text> tag will not be checked as such by a validating parser.
> 
> As it stands i've gone back to the old jsp syntax and am not worrying about
> validity. However, in a perfect world (tm) it'd be nice to have a jsp page
> with xhtml+svg+mathml and jsp namespaces that a validating parser would
> accept. But perhaps that's what xslt is for...
> 
> cheers,
> 
> james
> 
> >-----Original Message-----
> >From: Eduardo Pelegri-Llopart [mailto:pelegri@sun.com]
> >Sent: Thursday, September 27, 2001 5:07 PM
> >To: Uther, James
> >Cc: jsp-spec-comments@eng.sun.com
> >Subject: Re: %=x% expression syntax in template text
> >
> >
> >Did you see the reply I posted to tomcat-dev?  Does that help you?
> >
> >       - eduard/o
> >