计算机专业文献翻译功能强大的ASPHTML转换工具.docx
- 文档编号:3308059
- 上传时间:2022-11-21
- 格式:DOCX
- 页数:16
- 大小:35.38KB
计算机专业文献翻译功能强大的ASPHTML转换工具.docx
《计算机专业文献翻译功能强大的ASPHTML转换工具.docx》由会员分享,可在线阅读,更多相关《计算机专业文献翻译功能强大的ASPHTML转换工具.docx(16页珍藏版)》请在冰豆网上搜索。
计算机专业文献翻译功能强大的ASPHTML转换工具
英文翻译
CuttingEdgeAClient-sideEnvironmentforASPPages
ASPisaWebtechnologythatreliesspecificallyoncapabilitiesofMicrosoft?
InternetInformation
Services(IIS).Forthisreason,veryfewcommercialproductshaveattemptedtoprovideanASP-to-HTMLconverter.TheproblemwithsuchconvertersisthatyoumustworkinconjunctionwiththeWebservertotriggertheASPparserandfindtheintrinsicobjectsavailable.Whenyoudouble-clickonanHTMLpagefromtheExplorershell,yousimplyaskthebrowsertoretrieveandrenderthesourcecodeofthefile.However,whenyoudouble-clickonanASPfilefromExplorer,youcannotaskthebrowsertotranslateitintoHTML.
PracticalReasonsforanASPConverter
OK,soanASP-to-HTMLconvertermightnotbethetoolthatthousandsofprogrammersdreamofeverynight.
However,Icanenvisionatleastacoupleofscenarioswheresuchatoolwouldbeveryhandy.Thefirst
scenariowasmentionedbyRobertHessintheApril2000WebQ&Acolumn.SupposeyouhaveseveralpagesthatrequiresomeinteractionwithadatabaseonafrequentlyvisitedWebsite.WritingthemasASPpageslooksliketheperfectsolution.However,ifthedatabaseisnotveryvolatileandthepageoutputisnothighlydependentontheuser'sinput,youcouldeasilyresorttoplainoldHTMLforbetterperformance.
Forexample,alistofsuppliersisprobablythekindofdatathatyouwouldupdateonlyafewtimesa
year.Whyrebuildthatlistontheflyeachtimeit'srequested,whenastaticHTMLpagewouldincurless
overhead?
AnASP-to-HTMLtoolcouldbeusedasakindofbatchcompilerforASPpages.Youwritethemasserver-sideresources,andthenwhenyourealizetheyarenotparticularlydependentonruntimeconditions,youcantransformthemintostaticHTMLpageswitheitherthe.aspor.htm
(1)extension.
WhileI'monthesubject,letmepointoutasignificantimprovementinthemanagementofscriptlessASPpagesthat'savailablewithIIS5.0.UntilIIS4.0,allresourceswitha.aspextensionweresubjectto
parsing,whetherornottheycontainedscriptcode.WithIIS5.0thisdrawbackhasbeeneliminatedasIIS
checksfor<%...%>blocksbeforeloadingtheASPparser.
AnASP-to-HTMLconverterwouldalsobehandywhenyouneedtoviewASPpagesoffline.Forexample,aclientrecentlyaskedmeaboutthepossibilityofusingasingledevelopmentenvironmentforbuildingbothWebsitesandCDs.IfirstconsideredusingstaticHTMLpagesthatcouldbeviewedovertheWeborinalocalbrowser,buttheideawassoondismissedgiventhecomplexityandtheamountofcontentinvolved.Also,myclientcouldnotguaranteeanyparticularsoftwareconfigurationontheuser'smachine,andtheonlyproductthatcouldbesuppliedwiththeCDswasMicrosoftInternetExploreroracustomWebbrowser.
ASPlookedlikethenaturalchoicefortheWebsideoftheproject,butwhatabouttheCD?
TomakeASPworkofflinewithoutaWebserver,youneedcodethatextractsallthe<%¡%>codeblocksfromthepageandprocessesthem.Inaddition,thismodulewouldhavetoprovideasimulatedASPobjectmodelandtakecareofcollectingtheportionsofplainHTMLtext.Thenitwouldhavetoputitalltogether,combiningthestaticHTMLcodewiththeoutputoftheprocessedscripts.
Inthiscolumn,IwilldiscussthearchitectureoftheofflineASPviewerandsomeimplementationdetails.Inparticular,I'llshowyouhowtoemulatethebehavioroftheASPResponseobject.Nextmonth,I'llfinishupthecode,coveringRequestandServerplussomeotherrelatedtopics.Thismonth'scodeshowsthepotentialofthisapproachandworkswithtypicalASPpages,thoughitisnotcomprehensive.Iwon'tcoverotherASPobjectssuchasSessionorApplicationbecausetheyarerarelyneededinlocalscenarios.
TheBrowser'sRole
ToemulateASPwhileworkingoffline,youneedalittlehelpfromthebrowser.Basically,thebrowsermustbeabletodetectwhetherthepagetowhichit'sabouttonavigateisaURLoralocalpathnameand
whetheritcontainsthe.aspextension.IftheuseriscallingaURL,thebrowserdoeswhatitwould
normallydo.Otherwise,itcallsacustommoduletolocallyparsethecontentoftheASPfile.
Furthermore,thebrowserisinvolvedwhentheASPpagethatwillbeemulatedcontainsformsand
hyperlinks.(I'lldiscussthisfurthernextmonth.)Giventheserequirements,todealwithASPpages
offlineyouneedacustomizedversionofthebrowser.WhilesubclassingInternetExplorerorNetscape
Communicatorisalwayspossible,IsuggestyouwriteabrandnewbrowserfromscratchusingexistingWebbrowsertechnologysuchastheMicrosoftWebBrowsercontrol.WhileI'lluseVisualBasic?
here,youcanalsouseC++.AsagoodstartingpointinC++,youcantrytheMFCIEorATLBrowsersamples,bothofwhichcomewiththelatestPlatformSDK.InFigure1youcanseethelayoutofthebrowser.Forillustration,I'vedividedtheclientareaintothreeblocks:
onefortheactualHTMLrendering,onefortheoriginalASPtext,andonefortheexpandedHTMLtext.Figure2showsthecodeforthebrowser.
Figure1TheCustomASPBrowser?
?
Duringtheform'sinitialization,anewCAspParserobjectiscreatedandsettoworkproperly.Onceyou've
clickedtheGobutton,thebrowserdetectswhetheryou'recallingtheASPpagelocallyoroverHTTP,and
actsaccordingly.AllthelogicishiddenintheCAspParserclass,whichexposesthreepublicfunctions:
Initialize,SetscriptControl,andParseTextToFile.Initializemakessurethescriptingenvironmentis
properlyinitializedandreadytowork.ThroughSetscriptControl,theclassreceivestheworkinginstance
ofthescriptenvironment(moreonthislater).ParseTextToFileparsesthecontentofthegivenASPfile
andcreatesanoutputstream.Basically,theparserreadsthewholecontentoftheASPfileintomemory
andthenwalksthroughit.Itlocatesanyoccurrenceof"<%",thencopiesthetextthatprecedes"<%"to
theoutputbuffer,andstartsanewsearchfortheclosingtag,"%>".Thecommandtextisextractedand
processedseparately.Anyoutputisthenappendedtotheresponsebuffer.
ThescriptcodeinthebodyofanASPpagemaycontainreferencestotheintrinsicobjectsthatformtheASPobjectmodel.Thesewell-knownobjectsarelistedinFigure3.IISisresponsibleformakingthese
objects¡ªplustwomore:
ASPErrorandObjectContext¡ªavailableinthescript'snamespacewhentheparserisabouttoprocessthecontentofthevariouscodeblocks.ToobtainanASPparserthatworksoutsidethe
Webserver,youshouldprovideareplacementfortheseobjects,whichmeansbuildingaclient-sideASP
objectmodel.
AClient-sideASPObjectModel
OneoftheproblemswithWebapplicationsistheinabilitytomaintainstatewhenworkingoverHTTP.Stateistheabilitytoassociatevariablesandobjectswithaparticularuser.Atooltostoreindividual
settingsandresourcescansolvetheproblem.ThisiswhattheSessionandApplicationobjectsprovide,
albeitatdifferentlevels.Butyoudon'talwaysneedtoimplementthisfeatureinaclient-sideASP
objectmodel.Infact,alocalASPpageisnormallyaccessedbyoneuseratatimeandstatemanagementis
afarlessimportantissue.
FromtheperspectiveofanofflineASPviewer,thekeyASPobjectsareResponseandRequestbecausetheyprovidethebasicfunctionalitythatmakeapageinteractwiththerestoftheworld.Whetheryouneedtoimplementallorapartofthestandardmethodsandpropertiesdependsonyourparticularproject.
AlthoughASPistightlyintegratedwithIISandMicrosoftTransactionServices(MTS),andCOM+
environments,thisdoesn'tmeanthatyoucannotuseaunified,yetASP-basedapproachfortheconcurrent
developmentofproductsthatdelivercontentthroughdifferentmedia(liketheWebandCDs).OfflinepagesconsumedwithouttheinterventionoftheWebserverarenormallymuchsimpleranddon'tneedallthefeaturesofanonlineWebapplication.Basedonmypersonalexperience,Isuggestyouimplementaminimalsetoffeatures(similartothoseIdiscusshere)andthenextendthesetwhenyourpagesneedtosupport
extraASPfeatures.
IdeployedthefirstversionofmyprojectwithonlyResponseandRequestobjects.Inparticular,Ionly
implementedtheWritemethodoftheResponseobject,andjustfortheHTMLcontenttype.Requestonly
exposedtheQueryStringcollection.Inasecondstep,IaddedsupportforResponse.EndandtheRequest's
FormandServerVariablescollections.Later,Ialsoaddedsomespecialfeaturessuchasnewenvironment
variablesandnewoffline-onlyobjects,includingscripting.FileSystemObject.
ThekeyquestionsconcernhowyousimulatetheResponseorRequestobjectandhowyourunallthescriptcodethatanASPfilecontains.Toexecutescriptcode,youcaneithertakeadvantageoftheMicrosoftscriptControl¡ªadownloadablecomponent(seeorusetherawWindowsscriptCOMinterfaces.Foraprimer,lookattheExtremeC++columnintheAugust1997issueofMicrosoftInternetDeveloper.SinceI'mdevelopinganapplicationinVisualBasic,usingthescriptControlisthenaturalchoice.
ThescriptControlscriptControlisanActiveX?
controlwithoutauserinterfacethatwrapsalltheWindowsscriptinterfacesneededfordialogwithascriptlanguageparser.IthasaLanguagepropertythroughwhichyouselectalanguage.VBscriptandJscript?
arethetwousualoptions,butprovidedyouhaveacompliantparser,anyscriptinglanguageisfine.FrancescoBalenacoveredthescriptControlindetailintheJuly1999issueofMIND(see"ExploringtheMicrosoftscriptControl").TobiasMartinsson'sarticle,"A
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 计算机专业 文献 翻译 功能强大 ASPHTML 转换 工具