Framework Serveur J2EE ACube V3.1.0
CLASSE PRECEDANTE CLASSE SUIVANTE
SOMMAIRE: ATTR CONSTR METH DETAIL: ATTR CONSTR METH

acube.framework.struts2.views
Classe XSLTResult
java.lang.Object
  acube.framework.struts2.views.XSLTResult
Interfaces à implémenter:
com.opensymphony.xwork2.Result, Serializable
Sous classes directement connues:

public class XSLTResult
hérite de Object
implémente com.opensymphony.xwork2.Result
XSLTResult uses XSLT to transform action object to XML. Recent version has been specifically modified to deal with Xalan flaws. When using Xalan you may notice that even though you have very minimal stylesheet like this one
 <xsl:template match="/result">
   <result />
 </xsl:template>
 

then Xalan would still iterate through every property of your action and it's all descendants.

If you had double-linked objects then Xalan would work forever analysing infinite object tree. Even if your stylesheet was not constructed to process them all. It's becouse current Xalan eagerly and extensively converts everything to it's internal DTM model before further processing.

Thet's why there's a loop eliminator added that works by indexing every object-property combination during processing. If it notices that some object's property were already walked through, it doesn't get any deeper. Say, you have two objects x and y with the following properties set (pseudocode):

 x.y = y;
 and
 y.x = x;
 action.x=x;
 

Due to that modification the resulting XML document based on x would be:

 <result>
   <x>
     <y/>
   </x>
 </result>
 

Without it there would be endless x/y/x/y/x/y/... elements.

The XSLTResult code tries also to deal with the fact that DTM model is built in a manner that childs are processed before siblings. The result is that if there is object x that is both set in action's x property, and very deeply under action's a property then it would only appear under a, not under x. That's not what we expect, and that's why XSLTResult allows objects to repeat in various places to some extent.

Sometimes the object mesh is still very dense and you may notice that even though you have relatively simple stylesheet execution takes a tremendous amount of time. To help you to deal with that obstacle of Xalan you may attach regexp filters to elements paths (xpath).

Note: In your .xsl file the root match must be named result.
This example will output the username by using getUsername on your action class:

 <xsl:template match="result">
   <html>
   <body>
   Hello <xsl:value-of select="username"/> how are you?
   </body>
   <html>
 <xsl:template/>
 

In the following example the XSLT result would only walk through action's properties without their childs. It would also skip every property that has "hugeCollection" in their name. Element's path is first compared to excludingPattern - if it matches it's no longer processed. Then it is compared to matchingPattern and processed only if there's a match.

 <!-- START SNIPPET: description.example -->
 <result name="success" type="xslt">
   <param name="location">foo.xslt</param>
   <param name="matchingPattern">ˆ/result/[ˆ/*]$</param>
   <param name="excludingPattern">.*(hugeCollection).*</param>
 </result>
 <!-- END SNIPPET: description.example -->
 

In the following example the XSLT result would use the action's user property instead of the action as it's base document and walk through it's properties. The exposedValue uses an ognl expression to derive it's value.

 <result name="success" type="xslt">
   <param name="location">foo.xslt</param>
   <param name="exposedValue">user$</param>
 </result>
 
* This result type takes the following parameters:

struts.properties related configuration:

Example:
 <!-- START SNIPPET: example -->
 <result name="success" type="xslt">foo.xslt</result>
 <!-- END SNIPPET: example -->
 

Sommaire des Attributs
private org.apache.struts2.views.xslt.AdapterFactory
static final String
DEFAULT_PARAM
'stylesheetLocation' parameter.
private String
excludingPattern
Indicates the property name patterns which should be excluded from the xml.
private String
exposedValue
Indicates the ognl expression respresenting the bean which is to be exposed as xml.
protected static final org.apache.commons.logging.Log
LOG
Log instance for this result.
private String
matchingPattern
Indicates the property name patterns which should be exposed to the xml.
protected boolean
noCache
Determines whether or not the result should allow caching.
private boolean
private static final long
private String
stylesheetLocation
Indicates the location of the xsl template.
private static final Map
templatesCache
Cache of all tempaltes.
Sommaire des Constructeurs
XSLTResult(String stylesheetLocation)
Sommaire des Méthodes
void
execute(com.opensymphony.xwork2.ActionInvocation invocation)
protected org.apache.struts2.views.xslt.AdapterFactory
protected Source
getDOMSourceForStack(Object value)
String
String
String
String
protected Templates
getTemplates(String path)
protected URIResolver
getURIResolver()
Get the URI Resolver to be called by the processor when it encounters an xsl:include, xsl:import, or document() function.
protected void
setAdapterFactory(org.apache.struts2.views.xslt.AdapterFactory adapterFactory)
void
setExcludingPattern(String excludingPattern)
void
setExposedValue(String exposedValue)
void
setLocation(String location)
Deprecated. Use #setStylesheetLocation(String)
void
setMatchingPattern(String matchingPattern)
void
setNoCache(String val)
void
setParse(boolean parse)
If true, parse the stylesheet location for OGNL expressions.
void
setStylesheetLocation(String location)
Méthodes héritées de la classe java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Méthodes héritées de l'interface com.opensymphony.xwork2.Result
execute
Détail des Attributs
serialVersionUID
private static final long serialVersionUID

LOG
protected static final org.apache.commons.logging.Log LOG
Log instance for this result.

DEFAULT_PARAM
public static final String DEFAULT_PARAM
'stylesheetLocation' parameter. Points to the xsl.

templatesCache
private static final Map templatesCache
Cache of all tempaltes.

noCache
protected boolean noCache
Determines whether or not the result should allow caching.

stylesheetLocation
private String stylesheetLocation
Indicates the location of the xsl template.

matchingPattern
private String matchingPattern
Indicates the property name patterns which should be exposed to the xml.

excludingPattern
private String excludingPattern
Indicates the property name patterns which should be excluded from the xml.

exposedValue
private String exposedValue
Indicates the ognl expression respresenting the bean which is to be exposed as xml.

parse
private boolean parse

adapterFactory
private org.apache.struts2.views.xslt.AdapterFactory adapterFactory
Détail des Constructeurs
XSLTResult
public XSLTResult()

XSLTResult
public XSLTResult(String stylesheetLocation)
Détail des méthodes
setNoCache
public void setNoCache(String val)

setLocation
public void setLocation(String location)
Dépréciée. Use #setStylesheetLocation(String)

setStylesheetLocation
public void setStylesheetLocation(String location)

getStylesheetLocation
public String getStylesheetLocation()

getExposedValue
public String getExposedValue()

setExposedValue
public void setExposedValue(String exposedValue)

getMatchingPattern
public String getMatchingPattern()

setMatchingPattern
public void setMatchingPattern(String matchingPattern)

getExcludingPattern
public String getExcludingPattern()

setExcludingPattern
public void setExcludingPattern(String excludingPattern)

setParse
public void setParse(boolean parse)
If true, parse the stylesheet location for OGNL expressions.

execute
public void execute(com.opensymphony.xwork2.ActionInvocation invocation)
             throws Exception
Spécifié par:
execute in interface com.opensymphony.xwork2.Result
Exceptions:
Exception

getAdapterFactory
protected org.apache.struts2.views.xslt.AdapterFactory getAdapterFactory()

setAdapterFactory
protected void setAdapterFactory(org.apache.struts2.views.xslt.AdapterFactory adapterFactory)

getURIResolver
protected URIResolver getURIResolver()
Get the URI Resolver to be called by the processor when it encounters an xsl:include, xsl:import, or document() function. The default is an instance of ServletURIResolver, which operates relative to the servlet context.

getTemplates
protected Templates getTemplates(String path)
                          throws TransformerException,
                                 IOException
Exceptions:
TransformerException
IOException

getDOMSourceForStack
protected Source getDOMSourceForStack(Object value)
                               throws IllegalAccessException,
                                      InstantiationException
Exceptions:
IllegalAccessException
InstantiationException

Framework Serveur J2EE ACube V3.1.0
CLASSE PRECEDANTE CLASSE SUIVANTE
SOMMAIRE: ATTR CONSTR METH DETAIL: ATTR CONSTR METH

Version 3.1.0 du 06/11/2009 / Etat : Validé
Cette création est mise à disposition selon le Contrat Paternité - Pas d'Utilisation Commerciale - Partage des Conditions Initiales à l'Identique disponible en ligne http://creativecommons.org/licenses/by-nc-sa/2.0/fr/ ou par courrier postal à Creative Commons, 559 Nathan Abbott Way, Stanford,California 94305, USA.
Documentation generated by DocFlex