public class XsltView extends AbstractUrlBasedView
XSLT Source オブジェクトはモデルのパラメーターとして提供され、レスポンスのレンダリング中に detected として提供されます。ユーザーは、sourceKey プロパティを使用してモデルの特定のエントリを指定するか、Spring に Source オブジェクトを配置させることができます。このクラスは、オブジェクトの Source 実装への基本的な変換も提供します。詳細については、here を参照してください。
すべてのモデルパラメーターは、パラメーターとして XSLTTransformer に渡されます。さらに、ユーザーは output properties を Transformer に渡すように構成できます。
DEFAULT_CONTENT_TYPEloggerPATH_VARIABLES, RESPONSE_STATUS_ATTRIBUTE, SELECTED_CONTENT_TYPE| コンストラクターと説明 |
|---|
XsltView() |
| 修飾子と型 | メソッドと説明 |
|---|---|
protected void | configureIndentation(TransformerSE transformer) 提供されている TransformerSE のインデント設定を構成します。 |
protected void | configureResponse(MapSE<StringSE, ObjectSE> model, HttpServletResponseEE response, TransformerSE transformer) 提供されている HttpServletResponseEE を構成します。 |
protected void | configureTransformer(MapSE<StringSE, ObjectSE> model, HttpServletResponseEE response, TransformerSE transformer) 提供された TransformerSE インスタンスを構成します。 |
protected SourceSE | convertSource(ObjectSE source) |
protected void | copyModelParameters(MapSE<StringSE, ObjectSE> model, TransformerSE transformer) 提供されたマップのすべてのエントリを、提供された TransformerSE の parameter setSE にコピーします。 |
protected void | copyOutputProperties(TransformerSE transformer) |
protected ResultSE | createResult(HttpServletResponseEE response) 変換の結果をレンダリングするために使用される XSLT ResultSE を作成します。 |
protected TransformerSE | createTransformer(TemplatesSE templates)XSLT 変換を優先するために使用される TransformerSE インスタンスを作成します。 |
protected ClassSE<?>[] | getSourceTypes() |
protected SourceSE | getStylesheetSource()configured URL にある XSLT テンプレートの XSLT SourceSE を取得します。 |
protected TransformerFactorySE | getTransformerFactory() この XsltView が使用する TransformerFactory を返します。 |
protected void | initApplicationContext() この XsltView の TransformerFactory を初期化します。 |
protected SourceSE | locateSource(MapSE<StringSE, ObjectSE> model) 必要に応じてオブジェクトを変換し、提供されたモデルで SourceSE オブジェクトを見つけます。 |
protected TransformerFactorySE | newTransformerFactory(ClassSE<? extends TransformerFactorySE> transformerFactoryClass) このビューの新しい TransformerFactory をインスタンス化します。 |
protected void | renderMergedOutputModel(MapSE<StringSE, ObjectSE> model, HttpServletRequestEE request, HttpServletResponseEE response) ビューを実際にレンダリングするには、サブクラスでこのメソッドを実装する必要があります。 |
void | setCacheTemplates(boolean cacheTemplates)XSLT TemplatesSE インスタンスのキャッシュをオン / オフにします。 |
void | setErrorListener(ErrorListenerSE errorListener) 変換エラーと警告のカスタム処理のために ErrorListenerSE インターフェースの実装を設定します。 |
void | setIndent(boolean indent)XSLT トランスフォーマーが結果ツリーを出力するときに空白を追加するかどうかを設定します。 |
void | setOutputProperties(PropertiesSE outputProperties) スタイルシートに適用される任意のトランスフォーマー出力プロパティを設定します。 |
void | setSourceKey(StringSE sourceKey)XSLT ソースを表すモデル属性の名前を設定します。 |
void | setTransformerFactoryClass(ClassSE<? extends TransformerFactorySE> transformerFactoryClass) 使用する XSLT TransformerFactory クラスを指定します。 |
void | setUriResolver(URIResolverSE uriResolver) 変換で使用される URIResolver を設定します。 |
afterPropertiesSet, checkResource, getUrl, isUrlRequired, setUrl, toStringaddStaticAttribute, createMergedOutputModel, createRequestContext, createTemporaryOutputStream, exposeModelAsRequestAttributes, formatViewName, generatesDownloadContent, getAttributesMap, getBeanName, getContentType, getRequestContextAttribute, getRequestToExpose, getStaticAttributes, isExposePathVariables, prepareResponse, render, setAttributes, setAttributesCSV, setAttributesMap, setBeanName, setContentType, setExposeContextBeansAsAttributes, setExposedContextBeanNames, setExposePathVariables, setRequestContextAttribute, setResponseContentType, writeToResponsegetServletContext, getTempDir, getWebApplicationContext, initApplicationContext, initServletContext, isContextRequired, setServletContextgetApplicationContext, getMessageSourceAccessor, obtainApplicationContext, requiredContextClass, setApplicationContextcloneSE, equalsSE, finalizeSE, getClassSE, hashCodeSE, notifySE, notifyAllSE, waitSE, waitSE, waitSEpublic void setTransformerFactoryClass(ClassSE<? extends TransformerFactorySE> transformerFactoryClass)
指定されたクラスのデフォルトコンストラクターが呼び出され、このビューの TransformerFactory が構築されます。
public void setSourceKey(StringSE sourceKey)
次のソース型がそのまま使用できます: SourceSE、DocumentSE、NodeSE、ReaderSE、InputStreamSE、Resource。
public void setUriResolver(URIResolverSE uriResolver)
URIResolver は、XSLT document() 関数への呼び出しを処理します。
public void setErrorListener(@Nullable ErrorListenerSE errorListener)
ErrorListenerSE インターフェースの実装を設定します。 設定しない場合、デフォルトの SimpleTransformErrorListener が使用され、ビュークラスのロガーインスタンスを使用して警告をログに記録し、エラーを再スローして XML 変換を中止します。
public void setIndent(boolean indent)
デフォルトは true (オン)です。これを false (オフ)に設定して、「インデント」キーを指定しないようにします。選択はスタイルシートに任せます。
OutputKeys.INDENTSEpublic void setOutputProperties(PropertiesSE outputProperties)
ここで指定した値は、このビューがプログラムで設定するデフォルトを上書きします。
public void setCacheTemplates(boolean cacheTemplates)
TemplatesSE インスタンスのキャッシュをオン / オフにします。デフォルト値は "true" です。キャッシングがパフォーマンスに深刻な影響を与えない開発では、これを "false" にのみ設定してください。
protected void initApplicationContext()
throws BeansExceptionApplicationObjectSupport の initApplicationContext ApplicationContextException - 初期化エラーの場合 BeansException - ApplicationContext メソッドによってスローされた場合 ApplicationObjectSupport.setApplicationContext(org.springframework.context.ApplicationContext)protected TransformerFactorySE newTransformerFactory(@Nullable ClassSE<? extends TransformerFactorySE> transformerFactoryClass)
デフォルトの実装では、単に TransformerFactory.newInstance()SE を呼び出します。"transformerFactoryClass" が明示的に指定されている場合、指定されたクラスのデフォルトのコンストラクターが代わりに呼び出されます。
サブクラスでオーバーライドできます。
transformerFactoryClass - 指定されたファクトリクラス (もしあれば)setTransformerFactoryClass(java.lang.Class<? extends javax.xml.transform.TransformerFactory>), getTransformerFactory()protected final TransformerFactorySE getTransformerFactory()
null)protected void renderMergedOutputModel(MapSE<StringSE,ObjectSE> model, HttpServletRequestEE request, HttpServletResponseEE response) throws ExceptionSE
AbstractView最初のステップは、リクエストの準備です。JSP の場合、これはモデルオブジェクトをリクエスト属性として設定することを意味します。2 番目のステップは、たとえば RequestDispatcher を介した JSP を含む、実際のビューのレンダリングです。
AbstractView の renderMergedOutputModel model - 静的な属性よりも動的な値が優先される、結合された出力マップ(非 null)request - 現在の HTTP リクエスト response - 現在の HTTP レスポンス ExceptionSE - レンダリングに失敗した場合 protected ResultSE createResult(HttpServletResponseEE response) throws ExceptionSE
ResultSE を作成します。 デフォルトの実装では、提供された HttpServletResponse の OutputStreamEE をラップする StreamResultSE を作成します。
response - 現在の HTTP レスポンス ExceptionSE - 結果を構築できない場合 @Nullable protected SourceSE locateSource(MapSE<StringSE,ObjectSE> model) throws ExceptionSE
必要に応じてオブジェクトを変換し、提供されたモデルで SourceSE オブジェクトを見つけます。デフォルトの実装では、supported type のオブジェクトを見つける前に、構成済みの source key がある場合は、その下を調べようとします。
model - マージされたモデルマップ null )ExceptionSE - ソースの検索中にエラーが発生した場合 setSourceKey(java.lang.String), convertSource(java.lang.Object)protected ClassSE<?>[] getSourceTypes()
SourceSE への変換時にサポートされる ClassesSE の配列を返します。 現在、SourceSE、DocumentSE、NodeSE、ReaderSE、InputStreamSE、Resource をサポートしています。
protected SourceSE convertSource(ObjectSE source) throws ExceptionSE
source - 元のソースオブジェクト IllegalArgumentExceptionSE - 指定されたオブジェクトがサポートされている型ではない場合 ExceptionSEprotected void configureTransformer(MapSE<StringSE,ObjectSE> model, HttpServletResponseEE response, TransformerSE transformer)
TransformerSE インスタンスを構成します。 デフォルトの実装では、モデルからパラメーターを Transformer の parameter setSE にコピーします。この実装では、output properties を TransformerSE output propertiesSE にコピーします。インデントプロパティも設定されます。
model - マージされた出力マップ (非 null)response - 現在の HTTP レスポンス transformer - ターゲットトランス copyModelParameters(Map, Transformer), copyOutputProperties(Transformer), configureIndentation(Transformer)protected final void configureIndentation(TransformerSE transformer)
TransformerSE のインデント設定を構成します。transformer - ターゲットトランス TransformerUtils.enableIndenting(javax.xml.transform.Transformer), TransformerUtils.disableIndenting(javax.xml.transform.Transformer)protected final void copyOutputProperties(TransformerSE transformer)
transformer - ターゲットトランス protected final void copyModelParameters(MapSE<StringSE,ObjectSE> model, TransformerSE transformer)
TransformerSE の parameter setSE にコピーします。model - マージされた出力マップ (非 null)transformer - ターゲットトランス protected void configureResponse(MapSE<StringSE,ObjectSE> model, HttpServletResponseEE response, TransformerSE transformer)
HttpServletResponseEE を構成します。 このメソッドのデフォルト実装は、TransformerSE で指定された「メディア型」および「エンコーディング」出力プロパティから content typeEE および encodingEE を設定します。
model - マージされた出力マップ (非 null)response - 現在の HTTP レスポンス transformer - ターゲットトランス protected TransformerSE createTransformer(TemplatesSE templates) throws TransformerConfigurationExceptionSE
TransformerSE インスタンスを作成します。 デフォルトの実装では、単に Templates.newTransformer()SE を呼び出し、指定されている場合はカスタム URIResolverSE で TransformerSE を構成します。
templates - Transformer を作成する XSLT テンプレートインスタンス TransformerConfigurationExceptionSE - 作成に失敗した場合 protected SourceSE getStylesheetSource()
configured URL にある XSLT テンプレートの XSLT SourceSE を取得します。