ASP网页设计在JSP、ASP和PHP网站网页中利用XHTML
使用filesystemobject,可以对服务器上的文件进行操作,浏览、复制、移动、删除等。有ado的支持,asp对数据库的操作非常得心应手。你甚至可以像使用本地数据库那样,管理远程主机上的数据库,对表格、记录进行各种操作。OverviewAwiseprogrammeroncesaid,"Theoneconstantincomputingischange."Therecouldntbeatruer
statement.Thisarticleisaboutsuchchange,specificallymovingfromHTMLtothenextgeneration,XHTML
(ExtensibleHypertextMarkupLanguage).
Thisarticleincludesthefollowingsections:
AnIntroductiontoXHTML
ImplementingXHTMLToday
ChangingHTMLtoXHTML
Conclusion
AdditionalXHTMLResourcesandFacts
Theanalysisisfromaserver-sideperspective,meaningitappliesequallywelltoASP,JSP,PHPorother
server-sidedrivenprojects.
AnIntroductiontoXHTML
XHTML(nowinversion1.1)isthemergingofHTML4andXML.Itrepresentssuchanimportantadvancement
thattheWorldWideWebConsortium(W3C),theinternationalstandardsbodyfortheweb,isreplacingHTML
withXHTMLasthestandardtoolforcreatingwebpages.
XHTMLisbuilttoopendoorstootherformats.Forexample,XHTMLcanbeusedtoformatcontentfor
pagers,whereasHTMLcannot.XHTMLwillreplaceWAPandothermarkuplanguages.Itisacornerstoneinthe
revolutionarychangeinthinkingbeginningtooccurinwebsitedesign.Insteadofviewingawebsiteasa
standalonedataisland,XHTMLwillexpandwebapplications,allowingwebsitestocontrolandsend
informationwhichwilldrivecountlessdevices,presentationstylesandotherwebsites.XHTMListhe
startingpointforthistremendouschangeweareabouttoexperienceinhowweusetheweb.
UsingXHTMLhasmanyadvantagesoverusingHTML.Becauseofitsstructure,XHTMLisfaster.Itswell
formeddocumentsresultinquickerandsmallerparsers.Thesesmallerparserswastelesstimeverifying
anddoinglogicsortingthatsrequiredforhodgepodgeHTMLdocuments.Whilefasterresultsarenot
availableyet,expectimprovedperformancefromthenextgenerationofXHTML-basedbrowsers.
ThearchitectureofXHTMLallowstags,attributesanddocumenttypestobeuniquelydefinedbytheusers
ofXHTML.HTMLrestrictionsnolongerapply.Overtime,thiswillallowforthedevelopmentofindustry
andprojectspecificXHTMLdocuments.Toexplorethisideamorefully,seetheW3Cpage.
AsignificantlimitationofHTMLtodayistheformfield.TheW3Cestablishedspecialtaskgroupsto
expandthefunctionalityofXHTMLandoneoftheseisworkingtoimproveformfieldusage.The
XHTML/XFormsspecificationsarestillunderdevelopmentbutwhendonewilldramaticallychangethewaywe
useforms.AlistofsomeofthegreatfeaturesXFormswilladdincludes:
Pre-builtfunctionsremovetheneedtouseJavaScriptasheavilyasinthepast.Itwillbeagreatboon
forsupportingsmalldeviceswhereJavaScriptmaynothavebeenavailable.
Elementsaredeviceindependent,allowingflexibilitytoaddvoiceorotherinputmethods.
DataistransmittedfromtheforminXMLformat.
Datatypesarepredefined.
Formswillbeseparatedinto3distinctlayers:presentation,logicanddata.Splittingformsintothese
logicalpartitionswillmakeiteasyforformstoworkondifferentkindsofbrowsersanddeviceswhile
maintainingastandardbackend.
Whatotheradvancementsdoesthefutureholdforforms?Onlythefinalspecificationswilltellthefull
storyonallthefeatures.ThedraftspecificationsforXFormswerereleasedinApril2000.Thefinal
specificationsareexpectedbyyearend.XFormswilllikelybeoneofthedrivingforcestoupgradeto
XHTMLinthefuture.FormoreinformationonXFormsseeW3CandW3schools.
AnotheradvantageofXHTMListhatitisaXML-basedsystem.XMLisangreattechnologyanditisbeing
usedinmanyexcitingways.WhileprogrammerswouldliketouseXMLinavarietyofapplications,itstill
isntpracticaltouseformanyprojects.XHTMLchangesthisbecauseitmakesXMLeasytousewithany
project.LearningXHTMLmeansexpandingXMLknowledgeandskills.ItmeanslearningtothinkinXML.XHTML
enablessitestouseXMLconvenientlyinday-to-daywebbusiness.Itisthesteppingstonethatwill
finallygiveeveryoneeasyaccesstothepowerandconvinceofXML.
ImplementingXHTMLToday
HowsoondoesXHTMLneedtobeimplemented?Thatdependsonanumberoffactors,manyofthem
infrastructurerelated.Thecurrentgenerationoftools,suchaseditorsandbrowsers,needupdatingto
useXHTMLefficientlyandsmoothly.Thentheseupdatedtoolsneedtomaketheirwayintocommonuse.
Furthermore,someofthestandards,likeXForms,arestillunderdevelopment,andoncedevelopedwill
likelychange(muchlikeanynewsoftware)soonafterthefirstfullrelease.Addressingthese
infrastructureissueswilllikelytakefromonetofouryears.
Nothing,however,isstoppingconversionfrombeginningnow,and,infact,itsagoodideatostart
learningthebasicsofXHTML,incorporatingitintocurrentprojectsandplanningforitinnewprojects.
Itsagoodtimetobeginchangingprogramminghabitstoenableasmoothtransitioninthefuture.Thisis
possibleforafewreasons.
Forthemostpart,XHTMLcontentwhichdoesntmatchstandardHTMLwillstillusuallyworkwithHTML
parsers.Thisisbecausetheparsersignoremosterrors.Whenaparserencounterssomethingthatisnt
quiterightinthepageitusuallywontcauseafailure.Thisisntalwaystrue,suchasforscripting
(discussedbelow),butitispossibletoatleastmakemostendpagesofprojectscompletelyXHTML
compliant.
Asanotherexample,becauseXHTMLiscasesensitive,tagsarewritteninlowercase.Whilethismayseem
likearelativelyminorchange,itisone,nonetheless,whichcanbeimplementedimmediately,creatinga
goodprogramminghabit.Similarly,nestingrulesarestrictinXHTMLandcanbefollowedinHTMLto
ingraingoodprogramminghabits.Bothofthesetopicsarediscussedmorebelow.
ImplementingXHTMLinHTMLwebapplicationsnowalsohelpsensurethattheoutputwillbeXHTMLcompatible
later.Designingwithaneyetothefutureisimportantwhetherthatfuturebe6monthsor10yearsfrom
now.Changingawebpageiseasy,butupdatingthecomponentstakesmorethoughtandtime.
Howdoyouimplementamigrationplan?BegintowritecodewhichisXHTMLcompliantbutdontrequirethe
endpagestobecompletelycompliantatthisstage.Youmayfindyouneedtomakesignificantchangesin
howyourdynamicserverpagesarewritten.Ifyouusecodefromyourlibrary,makesureXHTMLratherthan
HTMLisbeingproduced.WhentheHTMLpagesaredonewiththecomponentsintegrated,runthemthrougha
conversiontooltoupdatethemandcheckforIDE-generatedHTMLthatdoesntmatchtheXHTMLstandard.
Thatsit!Justremember,thegoalisntnecessarilytobe100%XHTMLcompliant,butrathertobegin
learningandapplyingXHTMLwhereitmakessenseforyourprojectsandwebsites.Itcanbeappliedin
stages,sotakeadvantageofthisflexibilitywhereitbenefitsyou.
ChangingHTMLtoXHTML
HeressomeoftheparticularsyoushouldconsideringettingstartedwithyourconversionfromHTMLto
XHTML.Thisisntacomprehensivelistordiscussion,butcoversthemajorchangesusingthestrict
documentdefinition.
XHTMLisbasedonXMLstandards.Thismeansadocumentmustfollow"wellformed"rules,thatis,XML
syntax.Therulesofmostconcerninclude:
XMLiscasesensitive.InXHTMLthismeanseveryHTMLtagmustbewritteninlowercase.Souse<table>
not<TABLE>.CurrentHTMLeditingtoolswillfightyouhere.Dontworryaboutthecasethatisauto-
generated.Instead,whenhandtypinginHTMLtags,getusedtousinglowercase.Also,whengenerating
HTMLdynamicallymakesuretouselowercase.
IMPORTANT!Whileyourshouldgetusetowritingyourtagsinlowercase,dontworryaboutthecaseof
HTMLtagsthatareautomaticallygeneratedbythecurrentgenerationofHTMLeditors.Toolsareavailable
tocleanupHTMLpagestomakethemXHTMLcompliant.Thesetools,however,willnotcatchtagswith
impropersyntaxgeneratedbyyourcode!Getinthehabitofusingtherightsyntaxwithinyourscriptlets,
JavaBeans,ComobjectsorwhereverelseyouaregeneratingyourownHTMLcontent.
Non-emptytagsmustbeproperlynested.Thismeanstagsdonotcrossovereachother.Intheinvalid
examplebelownoticethattheformandtabletagsareimproperlynested,thatis,theycrossoverone
another.Thenseehowthisisrectifiedinthecorrectexample.InvalidExample:
<formaction="test.htm">
<table>
<tr><td>hi
</form>
</td></tr>
</table>
CorrectExample:
<formaction="test.htm">
<table>
<tr><td>hi</td></tr>
</table>
</form>
Attributevaluesmustbequoted.So<formaction=test.htm>isnotlegalbut<formaction="test.htm">is
legal.
Alltagsmustbeclosed.Fortagswhichdontnormallyhaveaclosingelement,endthetagwithinitself.
Forexample,<br>byitselfisnotlegal.Rather,use<br/>.Thesetagsmayalsoendlike</br>,but
<br/>syntaxseemstoworkbetterwithcurrentbrowsers.
Noattributemayappearmorethanonceinthesametag.Thisshouldntbeaproblem.
InadditiontothechangesdrivenbyXML,morechangesintagsaredrivenbyXHTMLsownDTD(document
typedefinition).Heresthehighlights.
ThefirsttaginaXHTMLdocumentmustbe<!DOCTYPE>.Thistaginformsthereaderwhichdefinitiontouse
indescribingtheXHTMLdocument.XHTMLusesDTDmodulestotranslatetags.Inselectingamongthethree
DTDsfollowtheserules.
WhenwritingpureXHTMLusethestrictDTD:
<!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Strict//EN""DTD/xhtml1-strict.dtd">
WhenwritingforthemostHTMLcompatibilityusethetransitionalDTD:
<!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""DTD/xhtml1-transitional.dtd">
WhenusingframesusetheframesetDTD:
<!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Frameset//EN""DTD/xhtml1-frameset.dtd">
ThetransitionalDTDwillbeusedformostpages.
ThesecondtaginaXHTMLdocumentmustbe<html>andthexmlnsattributeismandatory.
The<title>tagismandatoryinaXHTMLdocument.
Formtagsmusthaveanactionattribute.Forexample,<formaction="test.htm"></form>
Styletagssuchas<font>and<center>havebeenremoved!Usestylesheetsforformatting.
Data(whichinaHTMLpagewouldbetext)mustbeenclosedwithinasetofvalidtags.Apartiallistof
validtagstoenclosefreestandingdata(text)includes"p","h1""div","pre".
Thefirstexampleiswrongbecausethedata(text)isnotenclosedwithinadefinedtagset
<body>
HI,thisisWrong.
<br/>
<ahref="http://validator.w3.org/check/referrer">validate</a>
</body>
Thisisthecorrectwaytoincludedatausingthedivtag.
<body>
<div>
HI,thisisRight.
<br/>
<ahref="http://validator.w3.org/check/referrer">validate</a>
</div>
</body>
Every</script>
Fortheserver-sideprogrammerthisisaproblemwhenyoumodifytheJavaScriptdynamically.Usinga
separatefilesourceforyourJavaScriptpreventsyoufrombeingabletodynamicallychangeyour
JavaScript.ThisisbecausetheJavaScriptisbeingincludedontheclientsidesotheserversidewont
beabletotouchitnow.WhenmodifyingJavaScriptusingASP,JSPorPHPscripting,usethestandardHTML
methodofscriptdeclaration.ThisistheoneplacewheremakingJSPorASP100%compatiblewithXHTML
willbemostproblematic.Remember,however,thegoalisnottobe100%compatiblewithXHTML,butto
beginincorporatingXHTMLwherefeasible,allowingaquickandeasytransitionwhenthetimecomes.When
thattimearrives,newcompatiblebrowsersshouldbeavailableandyoullbesettomakethejumpto100%
compatibility.
Conclusion
InthisarticleweveexploredsomeadvantagesofXHTMLandhowtostartusingitrightnowwithvery
littlehassle.XHTMLisfarmorethanareplacementforHTML.ThinkingofitasHTML5.0unnecessarily
limitsitspowerandthepossibilitiesitwillintroduce.XHTMLismeanttobeexpandedbytheuser
community.ItcreatesXMLdocumentswhichcontain,defineandmanipulatedata,goingfarbeyondthe
capabilitiesofHTML-baseddocuments.ItmakesXMLeasytouse.TofullyrealizethepotentialXHTML
presentswillrequireanewwayofthinkingaboutfutureapplications.Itcreatesfreshpossibilities.
XHTMLreallyisanewthing(notmerelyanupgrade)andthechallengeaheadofusistoexperimentand
discoverwhereitcantakeus.
ActiveServerPage技术为应用开发商提供了基于脚本的直观、快速、高效的应用开发手段,极大地提高了开发的效果。在讨论ASP的安全性问题之前,让我们来看看ASP是怎么工作的。 代码的可重用性差:由于是面向结构的编程方式,并且混合html,所以可能页面原型修改一点,整个程序都需要修改,更别提代码重用了。 封装性使得代码逻辑清晰,易于管理,并且应用到ASP.Net上就可以使业务逻辑和Html页面分离,这样无论页面原型如何改变,业务逻辑代码都不必做任何改动;继承性和多态性使得代码的可重用性大大提高。 不是很难但是英文要有一点基础网上的教程很少有系统的详细的去买书吧,另不用专门学习vb关于vbscript脚本在asp教材都有介绍 Request:从字面上讲就是“请求”,因此这个是处理客户端提交的东东的,例如Resuest.Form,Request.QueryString,或者干脆Request("变量名") 先学习用frontpage熟悉html编辑然后学习asp和vbscript建议买书进行系统学习 最近在学asp,不要问我为什么不直接学.net,因为公司网站是asp做的所以有这个需要,卖了本书asp入门到精通,对里面的六大内置对象老是记不住,还有很多属性和方法看的头晕。 ASP(ActiveServerPages)是Microsfot公司1996年11月推出的WEB应用程序开发技术,它既不是一种程序语言,也不是一种开发工具,而是一种技术框架,不须使用微软的产品就能编写它的代码,能产生和执行动态、交互式、高效率的站占服务器的应用程序。 运用经典的例子。并且自己可以用他来实现一些简单的系统。如果可以对他进行进一步的修改,找出你觉得可以提高性能的地方,加上自己的设计,那就更上一个层次了,也就会真正地感到有所收获。
页:
[1]