日韩天天综合网_野战两个奶头被亲到高潮_亚洲日韩欧美精品综合_av女人天堂污污污_视频一区**字幕无弹窗_国产亚洲欧美小视频_国内性爱精品在线免费视频_国产一级电影在线播放_日韩欧美内地福利_亚洲一二三不卡片区

XML 和XSLT結(jié)合使你的網(wǎng)站設(shè)計(jì)渾然一體_Xml教程

編輯Tag賺U幣
教程Tag:暫無Tag,歡迎添加,賺取U幣!

推薦:XML入門指南(1)XML簡介
XML可以用來描述數(shù)據(jù),重點(diǎn)是‘數(shù)據(jù)是什么’。   HTML則是用來顯示數(shù)據(jù),重點(diǎn)是‘如何顯示數(shù)據(jù)’。   在學(xué)習(xí)XML之前你應(yīng)該已經(jīng)知道的知識   在你繼續(xù)之前你應(yīng)

如果你還未考慮采用一種單一的、緊密結(jié)合的方式進(jìn)行網(wǎng)頁設(shè)計(jì)的話,請看本文。

在網(wǎng)絡(luò)發(fā)展初期,凝聚性(cohesiveness)是由服務(wù)器端實(shí)現(xiàn)的,但要牽涉到大量的人工文件管理工作。幸運(yùn)的是,隨著網(wǎng)絡(luò)的日益成熟,網(wǎng)絡(luò)開發(fā)工具也日臻完善。例如,在.NET框架下,你可以創(chuàng)建各種Web控件來統(tǒng)一設(shè)計(jì)。

XML和XSLT的轉(zhuǎn)換使Web設(shè)計(jì)受益無窮。借助XML和 XSLT轉(zhuǎn)換,你可以實(shí)現(xiàn)將動態(tài)用語(dynamic verbiage)和網(wǎng)站內(nèi)容存儲在數(shù)據(jù)庫中。你可以在XML中傳輸數(shù)據(jù)庫,然后再通過XSLT轉(zhuǎn)換將其轉(zhuǎn)變?yōu)镠TML腳本。本文中,我將提供一個網(wǎng)站實(shí)例,并說明XML 和XSLT如何使你的網(wǎng)站設(shè)計(jì)渾然一體。

在設(shè)計(jì)用戶/數(shù)據(jù)交互功能時,我最為關(guān)心的是數(shù)據(jù)的完整性、用戶界面的功能性和商務(wù)規(guī)則的完善實(shí)現(xiàn)。我最不關(guān)心的是按鈕的顏色。而這些細(xì)枝末節(jié)卻往往是程序員發(fā)揮技術(shù)的地方。

當(dāng)設(shè)計(jì)一個全新的頁面時,我只投入最低限度的精力用于用戶界面的設(shè)計(jì),如只安置一個文本框和一個提交按鈕。對于本例中的HTML網(wǎng)頁,我增加了兩個INPUT標(biāo)簽來完成這一任務(wù)。

以下為引用的內(nèi)容:
<html>
<head>
</head>
<body>
<form method="POST" name="thisForm" id="thisForm" action="somepage.php">
<input type="text" name="txtText" id="txtText" size="25"><br>
<input type="submit" name="btnSubmit" id="btnSubmit" value="Submit">
</form>
</body>
</html>

以上代碼段完成了主要功能,但還需用XML和XSLT來對其加以美化。

在XML中,代碼有開頭和結(jié)尾標(biāo)簽,而在HTML中沒有。INPUT 和BR標(biāo)簽是個特例,它們不需結(jié)尾標(biāo)簽。然而,在結(jié)尾標(biāo)簽標(biāo)記“>”前加一個正斜杠,可確保HTML符合XML規(guī)范。如果在編寫HTML腳本時注意遵從這些規(guī)范,你就能夠?qū)ML/HTML(aka XHTML)轉(zhuǎn)換為不錯的HTML頁面。

以下為引用的內(nèi)容:
<form method="POST" name="thisForm" id="thisForm" action="somepage.php">
<input type="text" name="txtText" id="txtText" size="25" transform="blueText"/>
<br/>
<input type="submit" name="btnSubmit" id="btnSubmit" value="Submit"
transform="bigButton"/>
</form>

運(yùn)行下列代碼,完成XSLT轉(zhuǎn)換:

以下為引用的內(nèi)容:

<?xml version="1.0"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
>
<xsl:output method="html"/>

<xsl:template match="/">
<table width="100%" cellpadding="0" cellspacing="0">
<tr><td align="center">This is the defined header</td></tr>
<tr><td><xsl:apply-templates select="//form"/></td></tr>
<tr><td align="center">This is the defined footer</td></tr>
</table>
</xsl:template>

<xsl:template match="form">
<xsl:element name="form">
<xsl:attribute name="method"><xsl:value-of
select="@method"/></xsl:attribute>
<xsl:attribute name="action"><xsl:value-of
select="@action"/></xsl:attribute>
<xsl:attribute name="name"><xsl:value-of select="@name"/></xsl:attribute>
<xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute>
<xsl:apply-templates select="*"/>
</xsl:element>
</xsl:template>
<xsl:template match="*">
<xsl:choose>
<xsl:when test="@transform='blueText'"><xsl:element name="input">
<xsl:attribute name="name"><xsl:value-of select="@name"/></xsl:attribute>
<xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute>
<xsl:attribute name="type">text</xsl:attribute>
<xsl:attribute name="style">color:blue</xsl:attribute>
<xsl:if test="@value"><xsl:attribute name="value"><xsl:value-of
select="@value"/></xsl:attribute></xsl:if>
</xsl:element>
</xsl:when>
<xsl:when test="@transform='redText'"><xsl:element name="input">
<xsl:attribute name="name"><xsl:value-of
select="@name"/></xsl:attribute>
<xsl:attribute name="id"><xsl:value-of
select="@id"/></xsl:attribute>
<xsl:attribute name="type">text</xsl:attribute>
<xsl:attribute name="style">color:red</xsl:attribute>
<xsl:if test="@value"><xsl:attribute name="value"><xsl:value-of
select="@value"/></xsl:attribute></xsl:if>

</xsl:element>
</xsl:when>
<xsl:when test="@transform='bigButton'"><xsl:element name="input">
<xsl:attribute name="name"><xsl:value-of
select="@name"/></xsl:attribute>
<xsl:attribute name="id"><xsl:value-of
select="@id"/></xsl:attribute>
<xsl:attribute name="style">height:30px;width:100px;font-
size:18pt;font-weight:700;</xsl:attribute>
<xsl:attribute name="value"><xsl:value-of
select="@value"/></xsl:attribute>
</xsl:element>
</xsl:when>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>

以上代碼無法為你實(shí)現(xiàn)創(chuàng)建命名空間、定義XML標(biāo)簽、確認(rèn)DTD或schema。它使你能夠創(chuàng)建可行的HTML腳本,并可轉(zhuǎn)化為完整的新頁面,無需擔(dān)心設(shè)計(jì)因素。

在樣式表中,我用HTML標(biāo)簽的轉(zhuǎn)換屬性驅(qū)動轉(zhuǎn)換操作。我曾考慮用一個FORM窗體作為定義轉(zhuǎn)換操作所需的用戶控件的單元,因?yàn)樗杏糜谟脩糨斎氲目丶紤?yīng)在一個FORM中。本例中,輸出為一個文本INPUT,文本顏色為藍(lán)色;一個高20像素、寬100像素的按鈕,字體為18點(diǎn)加粗。我可以通過修改轉(zhuǎn)換屬性來改變文本框中的文本顏色。

有多種方法可將靜態(tài)內(nèi)容添加到網(wǎng)頁中,但出于演示目的,我只采用最簡單的方式,即在樣式表中增加header和footer。

現(xiàn)在,當(dāng)我要創(chuàng)建一個新窗體用于用戶輸入時,我要做的只是創(chuàng)建一個一般窗體。一旦一般窗體通過測試,我就可以將這些窗體添加到轉(zhuǎn)換中生成主題的HTML輸出。你只要記住輸入控件類型,并注意把它添加為轉(zhuǎn)換屬性即可。

達(dá)到目的的方法有很多種,通過這個例子,我希望能幫助你們學(xué)會如何標(biāo)準(zhǔn)化HTML輸出。

分享:XML數(shù)據(jù)庫中幾個容易混淆的概念
一個原始的XML數(shù)據(jù)庫(NXD)可以是很簡單,也可以是很復(fù)雜。我這樣定義一個數(shù)據(jù)庫的概念:永久穩(wěn)定數(shù)據(jù)的集合。在這樣的定義下,一個NXD能在邏輯上存儲一個XML文檔。   當(dāng)開發(fā)人

來源:模板無憂//所屬分類:Xml教程/更新時間:2008-08-22
相關(guān)Xml教程