Compile time label (XSLT pre-processes for JSP)

zhaozj2021-02-16  58

An old text, turned out and reviewed it. BTW, protesting 9CBS classification, how can XML be attributed to .NET! !

Sender: HAX (Hai Yan), News District: WebDevelop

Title: Compile time label (XSLT pre-processes for JSP)

Sending station: Drinking water Source (February 12, 2002 00:10:32 Tuesday), station letter

Compile time label (XSLT pre-processes for JSP)

Original: http://www.mail-archive.com/taglibs-dev@jakarta.apache.org/msg00390.html

From: James Strachan

Subject: [OT]: Compile Time Tags. (XSLT Preprocessing Of JSP)

Date: WED, 21 Mar 2001 12:20:55 -0800

Translation: Hax at Sjtu Dot Edu Dot CN

Here is the idea that I have fallen about the separation here ...

I like JSP and custom labels, let us put complex performance (Presentation) and

Business logic abstract, hidden to the XML tag. I also like fast JSP development.

Ring - Edit a JSP, press Reload in the browser, Ula!

I noticed some replacement of JSP tags using XSLT. For example Cocoon

XTP of XSP and RESIN.

http://xml.apache.org/cocoon/xsp.html

http://www.caucho.com/articles/xtp_templates.xtp

It makes me amazed, adding to our tools to our tools while using standard JSP

What will the "compile time" tag of the SLT?

What is necessary? The answer is: We only need to use JSP in XML format, and in our

The servlet engine is trying to run them, apply our XSLT document to these JSPs.

XSLT can prepare a specific XML tag to complete simple format conversion or join dynamic code

. These tags give namespaces like a general JSP custom label. Have a compilation

Translate tag, after we can do more ...

----

achieve:

If the servlet engine is not fully supported (JSP) XML format (I have tried many engines

So this), then we can always use the XSLT pre-processing process to put JSP XML format

Convert to standard <% =%> format.

Today we can immediately realize XSLT pretreatment, just in using our web application

Before, build (BULID) all JSP files with Ant Build System.

However, this interrupted our wonderful "editing JSP and then Reload" development environment. Instant

With that we can integrate the XSLT 'pretreatment' stage into our JSP compiler, that will

It is very Cool.

(This section is an example in Tomcat / Jasper, translated)

... I have been roughly seen Jasper's source code, it looks to it to join some pretreatment

The configuration of the device is not too difficult. (Of course, if you have Web Deployment in the JSP standard

Descriptor's entry (entry) for XSLT pre-processing, which will be better ;-))

----

example:

Compile time tags can only use compile time variables, although it can output JSP small scripts

(Scriptlet) expression. For example, here is an example of a normal HTML form in a JSP fragment.

First Name:


Last Name:


Email:


Using XSLT pretreatment, we can add a small script expression to use the current form

State in the form field into the corresponding value, (then becoming):

First Name:

TYPE = "text" name = "firstname"

Value = '<% = getFormValue (PageContext, "Firstname")%>' />


Last Name:

TYPE = "text" name = "lastname"

Value = '<% = getFormValue (PageContext, "Lastname")%>' />


Email:

TYPE = "text" name = "email"

Value = '<% = getFormValue (PageContext, "Email")%>' />


Functions getFormValue () can use any real Java code to get the form field value,

To be a custom form package or only the parameters requested by the servlet.

This means that from the perspective of developer / designer (Designer),

JSP maintains 'Clear' and class HTML in the form of HTML without a small script - all smart fills

Charge when we compile JSP to Java code.

Note that this also means we don't need to write JSP for each type (TYPE) INPUT label.

Custom label, do not need to make each of the possible property values ​​we want to use, Java

Bean property. At runtime, there is no label being created. Only a little dynamic Java code will call getFormValue (). So, the page will be really efficient.

Note that I am not advocating an alternative JSP custom label, just advocating combined with XSLT pre-

Processing and JSP Custom Tags, this truly elegant way to build web applications ...

Comments?

James strachan

=============

Email: james@metastuff.com

Web: http://www.metastuff.com

_________________________________________________________

-

※ Source: · Drinking water Source bbs.sjtu.edu.cn · [from: 211.154.68.29]

转载请注明原文地址:https://www.9cbs.com/read-27383.html

New Post(0)