欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

怎么使用純HTML的通用數(shù)據(jù)管理和服務(wù)-創(chuàng)新互聯(lián)

這篇文章將為大家詳細(xì)講解有關(guān)怎么使用純HTML的通用數(shù)據(jù)管理和服務(wù),小編覺得挺實用的,因此分享給大家做個參考,希望大家閱讀完這篇文章后可以有所收獲。

創(chuàng)新互聯(lián)是一家以網(wǎng)絡(luò)技術(shù)公司,為中小企業(yè)提供網(wǎng)站維護(hù)、成都做網(wǎng)站、成都網(wǎng)站設(shè)計、網(wǎng)站備案、服務(wù)器租用、域名注冊、軟件開發(fā)、微信小程序開發(fā)等企業(yè)互聯(lián)網(wǎng)相關(guān)業(yè)務(wù),是一家有著豐富的互聯(lián)網(wǎng)運(yùn)營推廣經(jīng)驗的科技公司,有著多年的網(wǎng)站建站經(jīng)驗,致力于幫助中小企業(yè)在互聯(lián)網(wǎng)讓打出自已的品牌和口碑,讓企業(yè)在互聯(lián)網(wǎng)上打開一個面向全國乃至全球的業(yè)務(wù)窗口:建站來電聯(lián)系:18980820575

使用純HTML的通用數(shù)據(jù)管理和服務(wù)。然而,為了收集數(shù)據(jù),你需要一個數(shù)據(jù)儲存庫。要避免使用數(shù)據(jù)庫服務(wù)器帶來的很多問題,你可以在xml中收集這些數(shù)據(jù)。下面是我們的項目的基本結(jié)構(gòu):

<user>
    <first_name/>
    <last_name/>
    <mi/>
</user>

我最初將數(shù)據(jù)限制為first name,last name和middle。這個頁面之后的基本思想是用戶信息在這個頁面中獲得。在用戶信息需求得到滿足以后,流程必須被轉(zhuǎn)到下一個邏輯收集步驟。為了使事情變得簡單,我將把用戶功能包裝到一個asp類中。

Function Coalesce(vVar, vAlt)
    If vVal = "" Or VarType(vVal) = 1 Or VarType(vVal) = 0 Then
        Coalesce = vAlt
    Else
        Coalesce = vVal
    End If
End Function
Class CUser
PRivate m_SQL, m_DOM
Public Property Get DOM()
    Set DOM = m_DOM
End Property
Public Sub saveUser()
    m_SQL.save "save_user", m_DOM
End Sub
Public Function validate()
    m_DOM.loadXML "<root>" & m_SQL.validateUser(m_DOM) & "</root>"
    If Not m_DOM.selectSingleNode("//error") Is Nothing Then
        validate = False
    Else
        validate = True
    End If
End Function
Private Sub collectData(dom, oCollection)
    Dim nItem, node, parent_node, n, sKey
    For nItem = 1 To oCollection.Count
        sKey = oCollection.Key(nItem)
        Set parent_node = dom.selectSingleNode("//" & sKey & "s")
        If Not parent_node Is Nothing Then
            For n = 1 To oCollection(sKey).Count
                Set node = parent_node.selectSingleNode(sKey & _
                                                        "[string(.)='" &
oCollection(sKey)(n) & "']")
                If node Is Nothing Then
                    Set node = dom.createNode(1, sKey, "")
                    Set node = parent_node.appendChild(node)
                End If
                node.text = Coalesce(oCollection(sKey)(n), "")
            Next
        Else
            Set node = dom.selectSingleNode("//" & sKey)
            If Not node Is Nothing Then _
                node.text = Coalesce(oCollection(sKey), "")
        End If
    Next
End Sub
Private Sub Class_Initialize()
    Set m_SQL = New CSQL
    Set m_DOM = Server.CreateObject("MSXML2.DOMDocument")
    m_DOM.async = False
    If VarType(Request ("txtUserXML")) = 0 Or Request ("txtUserXML") = "" Then
        m_DOM.loadXML Request("txtUserXML")
    Else
        m_DOM.load "<root>" & Server.MapPath("user.xml") & "</root>"
    End If
    collectData m_DOM, Request.Form
    collectData m_DOM, Request.QueryString
End Sub
Private Sub Class_Terminate()
    Set m_SQL = Nothing
    Set m_DOM = Nothing
End Sub
End Class
Class CSQL
Private m_DAL, m_Stream
Public Function save(sStoredProc, oDOM)
    'adVarChar = 200
    m_DAL.RunSP Array(m_DAL.mp("@xml_param", 200, 8000, oDOM.xml))
End Function
Public Function validateUser(oDOM)
    Set m_Stream = m_DAL.RunSPReturnStream("validate_user", Array(_
            m_DAL.mp("@xml_param", 200, 8000, oDOM.xml)))
    validateUser = m_Stream.ReadText(-1)
    m_Stream.Close
End Function
Private Sub Class_Initialize()
    Set m_DAL = Server.CreateObject("MyPkg.MyDAL")
    m_DAL.GetConnection "some connection string"
    Set m_Stream = Server.CreateObject("ADODB.Stream")
End Sub
Private Sub Class_Terminate()
    Set m_DAL = Nothing
    Set m_Stream = Nothing
End Sub
End Class

CSQL類是基于一個數(shù)據(jù)訪問層(m_DAL)組件MyPkg.MyDAL建立起來的。而這個組件則是基于Fitch和Mather DAL組件建立起來的,這兩個組件可以從MSDN找到。這樣我們就在SQL Server與你的代碼建立了橋梁。


當(dāng)CUser對象初始化之后,它收集Request數(shù)據(jù)并使用collectData()子函數(shù)將收集到的數(shù)據(jù)放到UserDOM的一個相應(yīng)的節(jié)點中。(代碼我不再解釋,因為它本身相當(dāng)容易理解。)在收集了數(shù)據(jù)之后(或者不收集數(shù)據(jù)),我們將使用XSL將數(shù)據(jù)內(nèi)容轉(zhuǎn)變成布局。

<?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="/">
    <xsl:if test="//error">
    <font color="red">*Information in red is required<br/></font>
    </xsl:if>
    <xsl:apply-templates select="//user"/>
</xsl:template>
<xsl:template match="user">
    <font>
        <xsl:attribute name="color">
            <xsl:choose>
                <xsl:when test="//error[.='first name']">red</xsl:when>
                <xsl:otherwise>black</xsl:otherwise>
            </xsl:choose>
        </xsl:attribute>
    First Name:
    </font>
    <input type="text" name="first_name">
        <xsl:attribute name="value"><xsl:value-of
select="first_name"/></xsl:attribute>
    </input><br/>
    <font>
        <xsl:attribute name="color">
            <xsl:choose>
                <xsl:when test="//error[.='mi']">red</xsl:when>
                <xsl:otherwise>black</xsl:otherwise>
            </xsl:choose>
        </xsl:attribute>
    MI:
    </font>
    <input type="text" name="mi">
        <xsl:attribute name="value"><xsl:value-of select="mi"/></xsl:attribute>
    </input><br/>
    <font>
        <xsl:attribute name="color">
            <xsl:choose>
                <xsl:when test="//error[.='last_name']">red</xsl:when>
                <xsl:otherwise>black</xsl:otherwise>
            </xsl:choose>
        </xsl:attribute>
    Last Name:
    </font>
    <input type="text" name="last_name">
        <xsl:attribute name="value"><xsl:value-of
 select="last_name"/></xsl:attribute>
    </input><br/>
</xsl:template>
</xsl:stylesheet>

這個樣式表將把內(nèi)容轉(zhuǎn)成布局。錯誤檢查是很重要的,存儲過程通過確定數(shù)據(jù)是否需要處理來檢查數(shù)據(jù)。對于不能為空但又沒有填充數(shù)據(jù)的每個域返回一個“errors”節(jié)點。這個XML的輸出大致如下:

    <user>. . .</user><errors><error>first_name</error>. . .</errors>

這個樣式表將把內(nèi)容轉(zhuǎn)成布局。錯誤檢查是很重要的,存儲過程通過確定數(shù)據(jù)是否需要處理來檢查數(shù)據(jù)。對于不能為空但又沒有填充數(shù)據(jù)的每個域返回一個“errors”節(jié)點。這個XML的輸出大致如下:

    <user>. . .</user><errors><error>first_name</error>. . .</errors>

注意如果有一個錯誤匹配了節(jié)點名,那么產(chǎn)生的輸出將會是紅色的。我們需要下面的一個ASP將前面的所有東西組合起來。

<%@ Language=VBScript %>
<%
Option Explicit
Dim oUser
Set oUser = New CUser
If oUser.validate() Then
    Set oUser = Nothing
    Server.Transfer "NextPage.asp"
End If
%>
<html>
<body>
<form method="POST" action="GetUser.asp" name="thisForm" id="thisForm">
<%
Response.Write xslTransform(oUser.DOM, "user.xsl")
%>
<input type="hidden" name="txtUserXML" id="txtUserXML"
 value="<%=oUser.DOM.xml%>">
<input type="submit" value="Submit">
</form>
</body>
</html>
<%
Set oUser = Nothing
Function xslTransform(vXML, XSLFileName)
    Dim m_xml, m_xsl
    If VarType(vXML) = 8 Then
        Set m_xml = m_dom
        m_xml.loadXML vXML
    ElseIf VarType(vXML) = 9 Then
        Set m_xml = vXML
    End If
    If m_xml.parseError.errorCode <> 0 Then _
        Err.Raise vbObjectError, "XMLTransform(...)", m_xml.parseError.reason
    Set m_xsl = Server.CreateObject("MSXML2.DOMDocument")
    m_xsl.async = False
    m_xsl.load Server.MapPath(XSLFileName)
    If m_xsl.parseError.errorCode <> 0 Then _
        Err.Raise vbObjectError, "XMLTransform(...)", m_xsl.parseError.reason
    xslTransform = m_xml.transformNode(m_xsl)
    Set m_xsl = Nothing
End Function
%>
<!--#include file="CUser.asp"-->

ASP代碼創(chuàng)建CUser對象,如果有數(shù)據(jù)就填充數(shù)據(jù)。然后使用CUser的DOM通過XSL轉(zhuǎn)換來創(chuàng)建結(jié)果HTML。轉(zhuǎn)換被包裝到一個叫做xslTransform的函數(shù)之中。而且,記住要將結(jié)果CUser DOM存儲到一個隱藏的<INPUT>元素中。或者你可以將CUser DOM存儲到一個session變量中并在初始化過程中將其取出。

在完成這個頁面之后,你可以基于前面的骨架代碼創(chuàng)建其它的頁面。現(xiàn)在你已經(jīng)創(chuàng)建了一個數(shù)據(jù)收集的拷貝-粘貼方案。這個方案最優(yōu)美的部分在于所有的輸出都是純HTML,沒有任何瀏覽器特有的性質(zhì)或者樣式表。而且由于功能都被包裝到類中,所以你可以使用XSLT產(chǎn)生布局,代碼運(yùn)行相當(dāng)快。

關(guān)于“怎么使用純HTML的通用數(shù)據(jù)管理和服務(wù)”這篇文章就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,使各位可以學(xué)到更多知識,如果覺得文章不錯,請把它分享出去讓更多的人看到。

另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)scvps.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務(wù)可用性高、性價比高”等特點與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場景需求。

分享標(biāo)題:怎么使用純HTML的通用數(shù)據(jù)管理和服務(wù)-創(chuàng)新互聯(lián)
本文來源:http://chinadenli.net/article32/ehjpc.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供品牌網(wǎng)站設(shè)計云服務(wù)器軟件開發(fā)品牌網(wǎng)站建設(shè)靜態(tài)網(wǎng)站服務(wù)器托管

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

成都做網(wǎng)站