public class XsltView extends AbstractUrlBasedView
XSLT Source オブジェクトはモデルのパラメーターとして提供され、レスポンスのレンダリング中に detected
として提供されます。ユーザーは、sourceKey
プロパティを使用してモデルの特定のエントリを指定するか、Spring に Source オブジェクトを配置させることができます。このクラスは、オブジェクトの Source 実装への基本的な変換も提供します。詳細については、here
を参照してください。
すべてのモデルパラメーターは、パラメーターとして XSLTTransformer に渡されます。さらに、ユーザーは output properties
を Transformer に渡すように構成できます。
DEFAULT_CONTENT_TYPE
logger
PATH_VARIABLES, RESPONSE_STATUS_ATTRIBUTE, SELECTED_CONTENT_TYPE
コンストラクターと説明 |
---|
XsltView() |
修飾子と型 | メソッドと説明 |
---|---|
protected void | configureIndentation(TransformerSE transformer) 提供されている Transformer SE のインデント設定を構成します。 |
protected void | configureResponse(MapSE<StringSE, ObjectSE> model, HttpServletResponseEE response, TransformerSE transformer) 提供されている HttpServletResponse EE を構成します。 |
protected void | configureTransformer(MapSE<StringSE, ObjectSE> model, HttpServletResponseEE response, TransformerSE transformer) 提供された Transformer SE インスタンスを構成します。 |
protected SourceSE | convertSource(ObjectSE source) |
protected void | copyModelParameters(MapSE<StringSE, ObjectSE> model, TransformerSE transformer) 提供されたマップのすべてのエントリを、提供された Transformer SE の parameter set SE にコピーします。 |
protected void | copyOutputProperties(TransformerSE transformer) |
protected ResultSE | createResult(HttpServletResponseEE response) 変換の結果をレンダリングするために使用される XSLT Result SE を作成します。 |
protected TransformerSE | createTransformer(TemplatesSE templates) XSLT 変換を優先するために使用される Transformer SE インスタンスを作成します。 |
protected ClassSE<?>[] | getSourceTypes() |
protected SourceSE | getStylesheetSource() configured URL にある XSLT テンプレートの XSLT Source SE を取得します。 |
protected TransformerFactorySE | getTransformerFactory() この XsltView が使用する TransformerFactory を返します。 |
protected void | initApplicationContext() この XsltView の TransformerFactory を初期化します。 |
protected SourceSE | locateSource(MapSE<StringSE, ObjectSE> model) 必要に応じてオブジェクトを変換し、提供されたモデルで Source SE オブジェクトを見つけます。 |
protected TransformerFactorySE | newTransformerFactory(ClassSE<? extends TransformerFactorySE> transformerFactoryClass) このビューの新しい TransformerFactory をインスタンス化します。 |
protected void | renderMergedOutputModel(MapSE<StringSE, ObjectSE> model, HttpServletRequestEE request, HttpServletResponseEE response) ビューを実際にレンダリングするには、サブクラスでこのメソッドを実装する必要があります。 |
void | setCacheTemplates(boolean cacheTemplates) XSLT Templates SE インスタンスのキャッシュをオン / オフにします。 |
void | setErrorListener(ErrorListenerSE errorListener) 変換エラーと警告のカスタム処理のために ErrorListener SE インターフェースの実装を設定します。 |
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, toString
addStaticAttribute, 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, writeToResponse
getServletContext, getTempDir, getWebApplicationContext, initApplicationContext, initServletContext, isContextRequired, setServletContext
getApplicationContext, getMessageSourceAccessor, obtainApplicationContext, requiredContextClass, setApplicationContext
cloneSE, equalsSE, finalizeSE, getClassSE, hashCodeSE, notifySE, notifyAllSE, waitSE, waitSE, waitSE
public void setTransformerFactoryClass(ClassSE<? extends TransformerFactorySE> transformerFactoryClass)
指定されたクラスのデフォルトコンストラクターが呼び出され、このビューの TransformerFactory が構築されます。
public void setSourceKey(StringSE sourceKey)
次のソース型がそのまま使用できます: Source
SE、Document
SE、Node
SE、Reader
SE、InputStream
SE、Resource
。
public void setUriResolver(URIResolverSE uriResolver)
URIResolver は、XSLT document()
関数への呼び出しを処理します。
public void setErrorListener(@Nullable ErrorListenerSE errorListener)
ErrorListener
SE インターフェースの実装を設定します。 設定しない場合、デフォルトの SimpleTransformErrorListener
が使用され、ビュークラスのロガーインスタンスを使用して警告をログに記録し、エラーを再スローして XML 変換を中止します。
public void setIndent(boolean indent)
デフォルトは true
(オン)です。これを false
(オフ)に設定して、「インデント」キーを指定しないようにします。選択はスタイルシートに任せます。
OutputKeys.INDENT
SEpublic void setOutputProperties(PropertiesSE outputProperties)
ここで指定した値は、このビューがプログラムで設定するデフォルトを上書きします。
public void setCacheTemplates(boolean cacheTemplates)
Templates
SE インスタンスのキャッシュをオン / オフにします。デフォルト値は "true" です。キャッシングがパフォーマンスに深刻な影響を与えない開発では、これを "false" にのみ設定してください。
protected void initApplicationContext() throws BeansException
ApplicationObjectSupport
の 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
Result
SE を作成します。 デフォルトの実装では、提供された HttpServletResponse の OutputStream
EE をラップする StreamResult
SE を作成します。
response
- 現在の HTTP レスポンス ExceptionSE
- 結果を構築できない場合 @Nullable protected SourceSE locateSource(MapSE<StringSE,ObjectSE> model) throws ExceptionSE
必要に応じてオブジェクトを変換し、提供されたモデルで Source
SE オブジェクトを見つけます。デフォルトの実装では、supported type
のオブジェクトを見つける前に、構成済みの source key
がある場合は、その下を調べようとします。
model
- マージされたモデルマップ null
)ExceptionSE
- ソースの検索中にエラーが発生した場合 setSourceKey(java.lang.String)
, convertSource(java.lang.Object)
protected ClassSE<?>[] getSourceTypes()
Source
SE への変換時にサポートされる Classes
SE の配列を返します。 現在、Source
SE、Document
SE、Node
SE、Reader
SE、InputStream
SE、Resource
をサポートしています。
protected SourceSE convertSource(ObjectSE source) throws ExceptionSE
source
- 元のソースオブジェクト IllegalArgumentExceptionSE
- 指定されたオブジェクトがサポートされている型ではない場合 ExceptionSE
protected void configureTransformer(MapSE<StringSE,ObjectSE> model, HttpServletResponseEE response, TransformerSE transformer)
Transformer
SE インスタンスを構成します。 デフォルトの実装では、モデルからパラメーターを Transformer の parameter set
SE にコピーします。この実装では、output properties
を Transformer
SE output properties
SE にコピーします。インデントプロパティも設定されます。
model
- マージされた出力マップ (非 null
)response
- 現在の HTTP レスポンス transformer
- ターゲットトランス copyModelParameters(Map, Transformer)
, copyOutputProperties(Transformer)
, configureIndentation(Transformer)
protected final void configureIndentation(TransformerSE transformer)
Transformer
SE のインデント設定を構成します。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)
Transformer
SE の parameter set
SE にコピーします。model
- マージされた出力マップ (非 null
)transformer
- ターゲットトランス protected void configureResponse(MapSE<StringSE,ObjectSE> model, HttpServletResponseEE response, TransformerSE transformer)
HttpServletResponse
EE を構成します。 このメソッドのデフォルト実装は、Transformer
SE で指定された「メディア型」および「エンコーディング」出力プロパティから content type
EE および encoding
EE を設定します。
model
- マージされた出力マップ (非 null
)response
- 現在の HTTP レスポンス transformer
- ターゲットトランス protected TransformerSE createTransformer(TemplatesSE templates) throws TransformerConfigurationExceptionSE
Transformer
SE インスタンスを作成します。 デフォルトの実装では、単に Templates.newTransformer()
SE を呼び出し、指定されている場合はカスタム URIResolver
SE で Transformer
SE を構成します。
templates
- Transformer を作成する XSLT テンプレートインスタンス TransformerConfigurationExceptionSE
- 作成に失敗した場合 protected SourceSE getStylesheetSource()
configured URL
にある XSLT テンプレートの XSLT Source
SE を取得します。