|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
使用filesystemobject,可以对服务器上的文件进行操作,浏览、复制、移动、删除等。有ado的支持,asp对数据库的操作非常得心应手。你甚至可以像使用本地数据库那样,管理远程主机上的数据库,对表格、记录进行各种操作。Overview
Awiseprogrammeroncesaid,"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是怎么工作的。 |
|