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

📄 hello.xtp

📁 resinweb服务器源文件
💻 XTP
字号:
<s1 title="XTP Hello, World"><p>XSL is a pattern matching language like Prolog.  It looks at XML nodes oneby one and checks the stylesheet for matching patterns.  XSL uses XPath asthe pattern-matching language.  Like Prolog, each XSL "rule" has a matchpattern and an execution program, the template.</p><p>To use XTP, you need an XTP file and an XSL stylesheet.  XTP parsesthe XTP files as HTML and then evaluates the HTML using the stylesheet.Since XTP is a standard XSL processor, the following tutorials willapply to any other XSL engine.  The main difference between XTP andan XSL engine like Xalan, is that XTP will automatically compilethe page to a JSP page.  You can achieve the same effect with Xalan,but it takes a little more work.<p>The following example has a single template, matching any &lt;hello>tag.  When the XSL engine evaluates a &lt;hello> tag it matches the rulein the stylesheet.  In this case, it replaces the &lt;hello> with"Hello, World".  The &lt;xsl:text> marks a text replacement.</p><example title='default.xsl'>&lt;xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform">&lt;xsl:template match="hello">  &lt;xsl:text>Hello, World&lt;/xsl:text>&lt;/xsl:template>&lt;/xsl:stylesheet></example><p>The following XTP file is first parsed as an HTML file and thenprocessed by the <var/default.xsl/> stylesheet.  As mentioned above,the &lt;hello/> tag is replaced by "Hello, World".</p><example title='hello.xtp'>My First Tag: &lt;hello/></example><results>My First Tag: Hello, World</results><p>This above example hides a few details, namely the default XSL rules.XTP's parser automatically inserts the &lt;html> and &lt;body> elements,but as you see, they're not included in the result.  If an XML node doesn'tmatch any stylesheet pattern, XSL applies a default rule.  The default rulefor elements recursively evaluates the element children, but does not copythe element itself.  Text nodes are copied.  In the above example, thedefault rules eat the &lt;html> and &lt;body> elements, evaluating thechildren, but copy the "My First Tag: " text.</p><s2 title="StyleScript equivalent"><p>Resin provides an alternate syntax for XSL.  XSL does not scan well; it'shard to find templates and figure out what they're doing.  In other words, XSL can become a write-only language.  StyleScript aims at having the samefunctionality of XSL, but making it more maintainable.</p><example title='default.xsl'>$template(hello) &lt;&lt;Hello, World>></example></s2><s2 title="Summary"><ul><li>XTP needs an XML file (the .xtp) and an XSL stylesheet.<li><var/default.xsl/> is the default stylesheet.<li><var/xsl:template/> matches an XML tag and replaces it with new XML.<li>The XPath pattern <var/name/> matches a named element.<li><var/&lt;&lt; ... >>/> describes the replacement XML in StyleScript.<li>XTP stylesheets provide syntactic sugar to XSL stylesheets, but arecompletely equivalent.<li><var/$template(foo)/> expands to <var/&lt;xsl:template match="foo">/>.<li><var/xsl:text/> returns verbatim text.</ul></s2></s1>

⌨️ 快捷键说明

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