📄 xslt-filter.xtp
字号:
<document> <header> <product>resin</product> <title>XSLT Filter</title> <description> <p>XSLT filters can be applied to the output of a JSP page or a Servlet. XSLT simplifies creating a uniform style for a site. XSLT converts XML to HTML or XML or WAP. It's easy to create different output depending on the browser. Just choose another stylesheet. The example below creates HTML or XML results from the same JSP.</p> <p>The JSP page creates a simple XML file. It tells Resin to use XSL filtering by setting the contentType to <var>x-application/xslt</var>.</p> </description> </header> <body> <localtoc/><s1 title="web.xml Configuration"><p>The filter must be configured in the web.xml:</p><example><web-app xmlns="http://caucho.com/ns/resin"> <filter filter-name='xslt' filter-class='com.caucho.filters.XsltFilter'/> <filter-mapping url-pattern='*.jsp' filter-name='xslt'/></web-app></example></s1><s1 title="The Source Files"><example title="test.jsp"><%@ page session=false contentType='x-application/xslt' %><?xml-stylesheet href='xml.xsl'?><top> <title>Hello, world</title> <count><%= 1 + 1 %></count></top></example><p>Stylesheets belong in <var>WEB-INF/xsl</var>. If nostylesheet is selected, Resin will use <var>default.xsl</var>.</p><p>The xml.xsl stylesheet just copies the input to the output. Manystylesheets will use this rule as a default rule.</p><example title="xml.xsl"><xsl:stylesheet><xsl:template match='*|@*'><xsl:copy><xsl:apply-templates select='node()|@*'/></xsl:copy></xsl:template></xsl:stylesheet></example></s1><s1 title="HTML generation"><p>The HTML example is slightly more complicated. When it matches a<var>top</var>, it generates the HTML header information. The<var>count</var> tag just writes out the count.</p><example title="html.xsl"><xsl:stylesheet><xsl:output media-type='text/html'/><xsl:template match='top'><html><head><title><xsl:value-of select='title'/></title></head><body bgcolor='white'><h3><xsl:value-of select='title'/></h3><xsl:apply-templates/></body></html></xsl:template><xsl:template match='count'>Count: <xsl:apply-templates/><br/></xsl:template><xsl:template match='title'/></xsl:stylesheet></example></s1> </body></document>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -