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

📄 boxes.xtp

📁 resinweb服务器源文件
💻 XTP
字号:
<s1 title="Using XSL for common formatting boxes"><p>Many common formatting idioms, like boxes, are repeated throughout aweb site.  Each box has the same design throughout the site, butits HTML implementation is a verbose combination of tables.  Changing the site design involves changing each of the tables.  Themany identical changes make the site more brittle and less changeable.<p>An XSL box formatting library lets a site create a consistentlook, keeping the design stored in one place.  Instead of cuttingand pasting table definitions, the page refers to the name of a box,like <var/border-box/>, and lets XSL do the formatting.</p><s2 title="A Screen Box"><p>The first element is a simple screen box.  Like the screen of thefollowing example, the <var/screen-box/> creates a rectangle with asolid background.  In the following, the bgcolor and title are optional.</p><example title="Using screen-box">&lt;screen-box bgcolor="#ff8080">&lt;title>A Sample Box&lt;/title>This is a little bit of data.&lt;/screen-box></example><p>The example, with title looks as follows, basically the same as theexample above.</p><center><table cellspacing="3" cellpadding="3"       border="0" width="60%" bgcolor="#ff8080"><caption>A Sample Box</caption><tr><td>This is a little bit of data.</td></tr></table></center><p>The XSL template gives additional flexibility to the tag.  Thatcomplicates the template slightly.  Any attribute in the screen-boxwill be automatically added to the table.  In addition, the &lt;title>tag is optional adding an extra $if.</p><example title="screen-box XSL">screen-box &lt;&lt;  &lt;table cellpadding="3" cellspacing="0"         border="0" width="100%" bgcolor="silver">    $for-each(@*) &lt;&lt; $copy(); >>    $if (title) &lt;&lt;      &lt;caption>$apply-templates(title/node());&lt;/caption>    >>    &lt;tr>&lt;td>      $apply-templates(node()[name(.)!="title"]);    &lt;/td>&lt;/tr>  &lt;/table>>></example></s2><s2 title="A Border Box"><p>The second box is just a different style.  It has a colored borderand a colored in title bar.  The HTML is entirely different, but byusing the stylesheet, the XML source can be identical.  The XMLspecifies the formatting and the stylesheet carries it out.</p><example title="Using border-box">&lt;border-box bgcolor="#ff8080">&lt;title>A Sample Box&lt;/title>This is a little bit of data.&lt;/border-box></example><p>With a similar XML source, the result is entirely different. </p><center><table cellspacing="3" cellpadding="3"       border="0" width="60%" bgcolor="#ff8080"><tr><td><font size="+1">A Sample Box</font></td></tr><tr><td>    <table border=0 cellpadding=3 cellspacing=0 width="100%">    <tr><td bgcolor="white">      This is a little bit of data.    </td></tr>    </table></table></center><p>To provide the full flexibility of the screen-box, the attributesmust be split between the generated tables.  It's straightforward, ifa bit verbose.  The <var/border/> attribute, for example, needs to beconverted to a <var/cellpadding/> of an inner table.</p><example title="border-box stylesheet">border-box &lt;&lt;  &lt;table border=0 cellspacing=0 cellpadding=1         width='100%' bgcolor="silver">    $if (@border) &lt;&lt;      $attribute(cellpadding) &lt;&lt; $(@border) >>    >>    $for-each(@*[name(.)!="border" and name(.)!="cellpadding"]) &lt;&lt;      $copy();    >>  $if (title) &lt;&lt;    &lt;tr>&lt;td>      &lt;table border=0 cellpadding=0 cellspacing=0 width='100%'>      &lt;tr>&lt;td>&lt;font size="+1">&nbsp;&lt;b>            $apply-templates(title/node());      &lt;/b>&lt;/font>&lt;/td>&lt;/tr>      &lt;/table>    &lt;/td>&lt;/tr>  >>  &lt;tr>&lt;td>    &lt;table border=0 cellpadding=3 cellspacing=0 width='100%'>      $for-each(@cellpadding) &lt;&lt; $copy(); >>    &lt;tr>&lt;td bgcolor="white">      $apply-templates(node()[name(.)!="title"]);    &lt;/td>&lt;/tr>    &lt;/table>  &lt;/td>&lt;/tr>  &lt;/table>>></example></s2><s2 title="An Example Box"><p>The example box shows nothing new technically, but does show animportant organizational difference.  screen-box and border-boxare formatting tags.  An <var/example/> tag is meaningful to thesource XML.  The advantage of an <var/example/> tag is that theformatting can be changed meaningfully for an entire site.</p><p>It makes sense to change the formatting of an example from ascreen-box to a border-box.  It doesn't make sense to change theformatting of the border-box to a screen-box.  By using moremeaningful tags like <var/example/>, the site can more easily changeto formatting to make it more readable.</p><example title="Using example">&lt;example>&lt;title>An Example Box&lt;/title>This is a little bit of example data.&lt;/example></example><center><table cellspacing="3" cellpadding="3"       border="0" width="60%" bgcolor="#ff8080"><tr><td><font size="+1">An Example Box</font></td></tr><tr><td>    <table border=0 cellpadding=3 cellspacing=0 width="100%">    <tr><td bgcolor="white">      This is a little bit of example data.    </td></tr>    </table></table></center><p>Because the <var/example/> tag has a definite style, the XSLimplementation is simpler than the more general <var/border-box/> thatachieves a similar result.</p><example title="example stylesheet">example &lt;&lt;  &lt;table border=0 cellspacing=0 cellpadding=1         width='100%' bgcolor="#ff8080">  $if (title) &lt;&lt;    &lt;tr>&lt;td>      &lt;table border=0 cellpadding=0 cellspacing=0 width='100%'>      &lt;tr>&lt;td>&lt;font size="+1">&nbsp;&lt;b>            $apply-templates(title/node());      &lt;/b>&lt;/font>&lt;/td>&lt;/tr>      &lt;/table>    &lt;/td>&lt;/tr>  >>  &lt;tr>&lt;td>    &lt;table border=0 cellpadding=3 cellspacing=0 width='100%'>    &lt;tr>&lt;td bgcolor="white">      $apply-templates(node()[name(.)!="title"]);    &lt;/td>&lt;/tr>    &lt;/table>  &lt;/td>&lt;/tr>  &lt;/table>>></example></s2></s1>

⌨️ 快捷键说明

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