计算机专业文献翻译功能强大的ASPHTML转换工具.docx

上传人:b****6 文档编号:3308059 上传时间:2022-11-21 格式:DOCX 页数:16 大小:35.38KB
下载 相关 举报
计算机专业文献翻译功能强大的ASPHTML转换工具.docx_第1页
第1页 / 共16页
计算机专业文献翻译功能强大的ASPHTML转换工具.docx_第2页
第2页 / 共16页
计算机专业文献翻译功能强大的ASPHTML转换工具.docx_第3页
第3页 / 共16页
计算机专业文献翻译功能强大的ASPHTML转换工具.docx_第4页
第4页 / 共16页
计算机专业文献翻译功能强大的ASPHTML转换工具.docx_第5页
第5页 / 共16页
点击查看更多>>
下载资源
资源描述

计算机专业文献翻译功能强大的ASPHTML转换工具.docx

《计算机专业文献翻译功能强大的ASPHTML转换工具.docx》由会员分享,可在线阅读,更多相关《计算机专业文献翻译功能强大的ASPHTML转换工具.docx(16页珍藏版)》请在冰豆网上搜索。

计算机专业文献翻译功能强大的ASPHTML转换工具.docx

计算机专业文献翻译功能强大的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

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 小学教育 > 语文

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1