⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xtp-intro.xtp

📁 解压在c盘
💻 XTP
字号:
<title keywords="xsl,xslt,xml,jsp,resin,caucho,template">XML Template Pages Introduction</title><summarylist/><p>XTP (XML Template Pages) creates web pages from XML using XSLstylesheets.<p>The documentation for the specific tags is in the <a href='xsl.xtp'>XSLstylesheet</a> section.  This section describes how XTP works.<p>XTP lets web designers create active pageswithout changing the original text.  It uses a separate <ahref='xsl.xtp'>XSL</a> stylesheet to transform the original documentinto a fancy formatted document.  Because the active stylesheet isseparate from the passive content, XTP gives designers a tighterfocus.  When worrying about style, designers can concentrate on thestylesheet.  When concentrating on content, designers can focus on thetext.<p>XTP makes the input file simpler: it can be plain old HTML.  Itseparates the content (*.xtp) from the style (*.xsl).  The tradeoffis that XSL stylesheets are slightly more complicated than JSP activepages.  For JSP, scripts execute exactly where they're placed.XTP has to match HTML to script fragments using patterns.<p>XTP works by matching stylesheet patterns to the input HTML,creating the result HTML following the pattern actions.XTP analyzing the input HTML into a structured HTML treeusing the XML document object model.  Foreach node, it finds the best pattern in the XSL and applies theaction.  The action prints to the output HTML.<section name=blank title='Blank Stylesheet Example'>In this example, we're using a blank stylesheet.  Even with a blankstylesheet, <resin/> does something useful: it prints out all text,removing the tags.<example title='hello.xtp'>&lt;TITLE&gt;Hello, world&lt;/TITLE&gt;&lt;H1&gt;Hi, World!&lt;/H1&gt;&lt;P&gt;The hello, world example is simple.</example><p><resin/> first reads in the XTP file, parsing it like an HTMLfile.  It adds optional tags, like &lt;html&gt; and &lt;/p&gt; andforces all HTML tags to be lower case.<example title='hello$9342.dom'>&lt;html&gt;  &lt;head&gt;    &lt;title&gt;Hello, world&lt;/title&gt;  &lt;/head&gt;  &lt;body&gt;    &lt;h1&gt;Hi, World!&lt;/h1&gt;    &lt;p&gt;The hello, world example is simple.&lt;/p&gt;  &lt;/body&gt;&lt;/html&gt;</example><p>Next, <resin/> starts its matching process at the top.  Since the stylesheetis empty, it uses the default rules.  The default rules say: processan element's children and print a text node's data.<box class='green'><ol><li>#document, process children <ol> <li>&lt;html&gt;, process children  <ol>  <li>&lt;head&gt;, process children   <ol>   <li>&lt;title&gt;, process children    <ol>    <li>"Hello, world", print to output    </ol>   </ol>  <li>&lt;body&gt;, process children   <ol>   <li>&lt;h1&gt;, process children    <ol>    <li>"Hi, World!", print to output    </ol>   <li>&lt;p&gt;, process children    <ol>    <li>"The hello, ...", print to output    </ol>   </ol>  </ol> </ol></ol></box><example title='hello$9342.html'>Hello, worldHi, World!The hello, world example is simple.</example></section><section name=page title='Simple Page Template'><resin/>'s XTP can create standard page layout: common backgrounds,navigation, headers and footers.  This is a common use for any of theactive content creation tools.<p>This example adds two things to the default stylesheet.  Allelements are copied instead of ignored, and the body of the HTML getsa background and a margin.<p>Copying elements is easy.  The copy template matches all elements<code/match='*'/>.  When <resin/> processes a node whose patternmatches nothing else, it will execute the copy action.  The actioncopies the element (<code/xsl:copy/>) and processes thechildren (<code/xsl:apply-templates/>).<example>&lt;xsl:template match='*|@*'&gt;  &lt;xsl:copy&gt;    &lt;xsl:apply-templates select='@*|*'/&gt;  &lt;/xsl:copy&gt;&lt;/xsl:template&gt;</example><p>For the page template pattern, we use <code/match='/html/body'/>.<resin/> will execute the template in place of the body.<example>&lt;xsl:template match='/html/body'&gt;<eg-em>  &lt;!-- cyan background --&gt;  &lt;body bgcolor='cyan'&gt;  &lt;table width='100%'&gt;  &lt;!-- left margin --&gt;  &lt;tr&gt;&lt;td width='240'&gt;&lt;/td&gt;  &lt;!-- center column --&gt;  &lt;td width='80%'&gt;  &lt;!-- insert body contents --&gt;</eg-em>  &lt;xsl:apply-templates/&gt;<eg-em>  &lt;!-- copyright footer --&gt;  &lt;hr&gt;  Copyright &amp;copy; 1999 Caucho Technology  &lt;/td&gt;&lt;/tr&gt;  &lt;/table&gt;  &lt;/body&gt;</eg-em>&lt;/xsl:template&gt;</example><p>The translation follows the same order as in the blank stylesheetexample.  The body rule is used for the body and the copy ruleis used for every other tag.<example><example>&lt;TITLE&gt;Hello, world&lt;/TITLE&gt;&lt;H1&gt;Hi, World!&lt;/H1&gt;&lt;P&gt;The hello, world example is simple.</example><results>&lt;html&gt;  &lt;head&gt;    &lt;title&gt;Hello, world&lt;/title&gt;  &lt;/head&gt;  &lt;body bgcolor='cyan'&gt;  &lt;table width='100%'&gt;  &lt;tr&gt;&lt;td width='240'&gt;&lt;/td&gt;  &lt;td width='80%'&gt;    &lt;h1&gt;Hi, World!&lt;/h1&gt;   &lt;p&gt;The hello, world example is simple.   &lt;/p&gt;  &lt;hr&gt;  Copyright &amp;copy; 1999 Caucho Technology  &lt;/td&gt;&lt;/tr&gt;  &lt;/table&gt;  &lt;/body&gt;&lt;/html&gt;</results></example></section>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -