這一次我打算使用 XML+XSLT=>XHTML+CSS 的方式來 implement,技術難度上算最高,但又有最好的 standard compliant 及 flexible。
不過,這條路還滿遠的...
你可以把這邊提的東西當做是做網頁的一些經驗、guideline。
<xml>
<header/>
<content>
blah blah blah
<blog>
<date>date</date>
blog content
</bog>
<box>
<bar>bar-header </bar>
</box>
</content>
<sidebar/>
<footer/>
</xml>
Of course, 這些語法不太正確,只是初稿。不過它展現了我期望成果
使用的形式。
<html> # for root element
<title>$TITLE<title/> # the title (h1) of your current document
<logo>$LOGO<logo/> # the logo, like company name
<navbar/> # navigation(header) bar if required
<sidebar>myname<sidebar> # generate sidebar, and apply some rule if match name
<body> # start of content, will do apply-templates here
<box>
</box>
</body>
<footer/> # end footer
</html>
body 的目的是後面可以放 [xsl:apply-templates],若是沒有 body 時
logo/title 什麼的都有可能被重展一次。
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
(<meta http-equiv="Content-Language" content="zh-tw" />)
</xsl:template>
</xsl:stylesheet>
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="YOUR_XSL.xsl"?>
<html>
<body>
</body>
</html>
<xsl:template match="/html/title">
<title>
<xsl:if test="string-length(/html/logo) > 0">
<xsl:value-of select="/html/logo"/>:
</xsl:if>
<xsl:value-of select="/html/title"/>
</title>
</xsl:template>
<xsl:template match="a">
<a>
<xsl:attribute name="href">
<xsl:value-of select="attribute::href"/>
</xsl:attribute>
<xsl:value-of select='current()'/>
</a>
</xsl:template>