parserblockquote

blockquote  时间:2021-05-19  阅读:()
CopyrightIBMCorporation2010TrademarksThinkingXML:TheXMLflavorofHTML5Page1of9ThinkingXML:TheXMLflavorofHTML56recommendationsfordevelopersusingthenextgenerationoftheweb'snativelanguageUcheOgbujiJuly08,2010(FirstpublishedJuly06,2010)Forawhile,therehasbeenastruggleforthefutureofmarkupontheweb,astrugglebetweentheW3C'sXHTML2andHTML5,developedbythemajorbrowservendorsunderaseparateorganizationalumbrella.
First,theW3CtookoverHTML5,andnowitrecentlyannouncedthesunsetoftheXHTML2effort.
ThismakesasignificantdifferencetothefutureofXMLontheweb,andfurthermore,becauseofHTML5'smomentum,itisnowatechnologythateveryXMLdeveloperalreadyhastodealwith.
ButfansofXMLneednotdespair:HTML5supportsaproperXMLserialization.
LearnabouttheXMLformofHTML5includingsomekeydifferencesfromolderXHTMLconventionsandlearnhowtopracticallyapplythisvocabularyinmodernwebbrowsers.
Viewmorecontentinthisseries08Jul2010:AddedtwoRelatedtopicsperauthorrequest:Tip:AlwaysuseanXMLdeclarationandthankstoMichaelSmith.
FrequentlyusedacronymsAPI:ApplicationProgrammingInterfaceDOM:DocumentObjectModelHTML:HypertextMarkupLanguageHTTP:HypertextTransferProtocolMIME:MultipurposeInternetMailExtensionsSGML:StandardGeneralizedMarkupLanguageURL:UniformResourceLocatorW3C:WorldWideWebConsortiumXHTML:ExtensibleHypertextMarkupLanguageExtensibleMarkupLanguageXML:ExtensibleMarkupLanguageThehistoryofHTMLhasbeencontroversialateveryturn.
Despitethebesteffortsofwebarchitects,thewebhasalwaysbeenawildfrontierofmessy,confusing,andsometimesjustdiabolicallybrokenmarkup(nicknamedtagsoup).
OneambitionofXMLhasalwaysbeentohelpdeveloperWorksibm.
com/developerWorks/ThinkingXML:TheXMLflavorofHTML5Page2of9cleanupthismess,henceXML'sdesignationas"SGMLfortheweb"(SGMListhemeta-languageofwhichHTMLisjustoneflavor).
XMLcameonthesceneandimmediatelymadealotofwaves.
TheW3Cexpected,reasonablyenough,thatXMLmightalsofindsuccessinthebrowser,andsetupXHTMLasthemostnaturalevolutionfromHTMLtosomethingmorecoherent.
Unfortunately,unexpectedproblemskeptpoppinguptosabotagethisambition.
Deceptivelysimpleconceptssuchasnamespacesandlinkingturnedintofirestormsoftechnologicalpolitics.
TheresultingcontroversiesanddelaysweremorethanenoughtoconvincebrowserdevelopersthatXMLmighthelpescapetheknownproblems,butitwasofferingupplentyofnewandpossiblyunknownonesofitsown.
EvenwithoutthemountingevidencethatXMLisnotapanacea,browserdeveloperswerealwaysgoingtohavedifficultymigratingtoastrictXML-basedpathforthewebgiventheenormouslegacyofpagesusingtagsoup,andconsideringPostel'sLaw,namedafterlegendarycomputerscientistJohnPostel.
Thislawstates:Beconservativeinwhatyoudo;beliberalinwhatyouacceptfromothers.
ThestricturesofXMLarecompatiblewiththislawontheserverordatabaseside,wheremanagerscanimposeconservatismasamatterofpolicy.
Asaresult,thisiswhereXMLhasthrived.
Awebbrowserisperhapstheultimateexampleofhavingtoacceptinformationfromothers,sothat'swheretensionisthegreatestregardingXMLandPostel'slaw.
XHTMLisdead.
LongliveXHTMLAllthistensioncametoaheadinthepastfewyears.
BrowservendorshadbeenlargelyignoringtheW3C,andhadformedtheWebHypertextApplicationTechnologyWorkingGroup(WHATWG)inordertoevolveHTML,creatingHTML5.
SupportforW3CXHTMLwasstagnant.
TheW3CfirstrecognizedthepracticalitiesbyprovidingaplacetocontinuetheHTML5work,anditaccepteddefeatbyretiringXHTMLeffortsin2009.
There'snosimplewaytoassesswhetherornotthismeanstheendofXHTMLinpractice.
HTML5certainlyisnotatalldesignedtobeXMLfriendly,butitdoesatleastgivelipserviceintheformofanXMLserializationforHTML,which,inthisarticle,I'llcallXHTML5.
Nevertheless,thematterisfarfromsettled,asoneoftheHTML5FAQentriesdemonstrates:IfI'mcarefulwiththesyntaxIuseinmyHTMLdocument,canIprocessitwithanXMLparserNo,HTMLandXMLhavemanysignificantdifferences,particularlyparsingrequirements,andyoucannotprocessoneusingtoolsdesignedfortheother.
However,sinceHTML5isdefinedintermsoftheDOM,inmostcasestherearebothHTMLandXHTMLserializationsavailablethatcanrepresentthesamedocument.
Thereare,however,afewdifferencesexplainedlaterthatmakeitimpossibletorepresentsomeHTMLdocumentsaccuratelyasXHTMLandviceversa.
ThesituationisveryconfusingforanydeveloperwhoisinterestedinthefutureofXMLontheweb.
Inthisarticle,IshallprovideapracticalguidethatillustratesthestateofplaywhenitcomestoXMLintheHTML5world.
ThearticleiswrittenforwhatIcallthedesperatewebhacker:someonewhoisnotaW3Cstandardsguru,butinterestedineithergeneratingXHTML5ontheweb,orconsumingitinasimpleway(thatis,toconsumeinformation,ratherthanworryingabouttheibm.
com/developerWorks/developerWorksThinkingXML:TheXMLflavorofHTML5Page3of9enormouscomplexityofrendering).
I'lladmitthatsomeofmyrecommendationswillbepainfulformetomake,asalong-timeadvocateforprocessingXMLtherightway.
RememberthatHTML5isstillaW3Cworkingdraft,anditmightbeawhilebeforeitbecomesafullrecommendation.
Manyofitsfeaturesarestable,though,andalreadywell-implementedontheweb.
ServingupdocumentstoberecognizedasXHTML5Unfortunately,Ihavemorebadnews.
YoumightnotbeabletouseXHTML5asofficiallydefined.
Thatisbecausesomespecificationssaythat,inordertobeinterpretedasXHTML5,itmustbeservedupusingtheapplication/xhtml+xmlorapplication/xmlMIMEtype.
Butifyoudoso,allfullyreleasedversionsofMicrosoftInternetExplorerwillfailtorenderit(you'refinewithallothermajor,modernwebbrowsers).
YouronlypragmaticsolutionistoserveupsyntacticXHTML5usingthetext/htmlMIMEtype.
ThisistechnicallyaviolationofsomeversionsoftheHTML5spec,butyoumightnothavemuchchoiceunlessyoucanexcludesupportforInternetExplorer.
Toaddtotheconfusionthisisaverycontentiouspointintherelevantworkinggroup,andinatleastsomedraftsthislanguagehasbeentoneddown.
InternetExplorer9beta(alsoknownasa"platformpreview")doeshavefullsupportforXHTMLservedwithanXMLMIMEtype,sooncethisversioniswidespreadamongyourusers,thisproblemshouldgoaway.
Meanwhile,ifyouneedtosupportInternetExplorer6orolder,eventheworkaroundsintroducedinthisarticlearenotenough.
YouprettymuchhavetosticktoHTML4.
x.
Recommendationforthedesperatewebhacker:ServeupsyntacticXHTML5usingthetext/htmlMIMEtype.
FunwithDOCTYPEOnepieceofgoodnews,fromadesperatewebhackerperspective,isthatXHTML5bringsfewerworriesaboutdocumenttypedeclaration(DTDecl).
XHTML1.
xand2requiredtheinfamousconstructsuchas:.
ThebiggestproblemwiththiswasthatanaiveprocessorislikelytoloadthatDTDURL,whichmightbeanunwantednetworkoperation.
Furthermore,thatoneURLincludesmanyothers,anditwasn'tuncommonforyoutounnecessarilyendupdownloadingdozensoffilesfromtheW3Csite.
Everynowandthen,theW3C-hostedfilesevenhadproblems,whichleadtoextraordinarilyhard-to-debugproblems.
InXHTML5,theXMLnatureofthefileisentirelydeterminedbyMIMEtype,andanyDTDecliseffectivelyignored,soyoucanomitit.
ButHTML5doesprovideaminimalDTDecl,.
IfyouusethisDTDecl,thenalmostallbrowserswillswitchto"standards"mode,which,evenifnotfullyHTML5,isgenerallymuchmorecompliantandpredictable.
NoticethattheHTML5DTDecldoesnotreferenceanyseparatefileandsoavoidssomeoftheearlierXHTMLproblems.
Recommendationforthedesperatewebhacker:UsetheHTMLminimaldocumenttypedeclaration,,inXHTML5.
SinceyouarenotusinganyexternalDTDcomponents,youcannotusecommonHTMLentitiessuchas or©.
ThesearedefinedinXHTMLDTDswhichyouarenotdeclaring.
Ifyoutrytousethem,anXMLprocessorwillfailwithanundefinedentityerror.
TheonlysafenameddeveloperWorksibm.
com/developerWorks/ThinkingXML:TheXMLflavorofHTML5Page4of9characterentitiesare:<,>,&,",and'.
Usenumericalequivalentsinstead.
Forexample,use ratherthan and©ratherthan©.
Recommendationforthedesperatewebhacker:Donotuseanynamedcharacterentitiesexceptfor:<,>,&,",and'Technicallyspeaking,ifyouserveupthedocumentastext/html,accordingtothefirstrecommendation,youwon'tgeterrorsfrommostbrowsersusingHTMLnamedcharacterentities,butrelyingonthisaccidentisverybrittle,andrememberthatbrowsersarenottheonlyconsumerofXML.
OtherXMLprocessorswillchokeonsuchdocuments.
FunwithnamespacesThelastlayerintheover-elaboratecakeofmechanismsforrecognizingtheXMLformat,afterMIMEtypeandDTDecl,isthenamespace.
You'reprobablyusedtostartingXHTMLdocumentswithalinesuchasthefollowing.
Thepartinboldtype(xmlns="http://www.
w3.
org/1999/xhtml")isthenamespace.
InXHTML5,thisnamespaceisstillrequired.
IfyouincludeotherXMLvocabularies,suchasScalableVectorGraphics(SVG),puttheseintheirrespective,requirednamespaces.
Recommendationforthedesperatewebhacker:AlwaysincludethedefaultnamespaceatthetopofXHTML5documentsandusetheappropriatenamespacesforother,embeddedXMLformats.
Ifyoudoincludeothervocabularies,theirnamespacedeclarationsmustbeintheoutermoststarttagsoftheembeddedsections.
Ifyoudeclarethemonthehtmlelement,youcommitatext/htmldocument-conformanceerror.
WorkingwithXHTML5contentXHTML5requiresthatyouspecifythemediatypeeitherinaprotocolheader,suchasHTTPContent-Typeheader,usingaspecialcharactermarkercalledaUnicodeByteOrderMark(BOM)orusingtheXMLdeclaration.
Youcanuseanycombinationoftheseaslongastheydonotconflict,butthebestwaytoavoidproblemsistobecarefulinhowyoucombinemechanisms.
Unfortunately,usinganXMLdeclarationisapotentialproblem,becauseitcausesallInternetExplorerversions8andbelowtoswitchtoquirksmode,resultingintheinfamousrenderinganomaliesforwhichthatbrowserisfamous.
Recommendationforthedesperatewebhacker:OnlyuseUnicodeencodingsforXHTML5documents.
OmittheXMLdeclaration,andusetheUTF-8encoding,oruseaUTF-16UnicodeByteOrderMark(BOM)atthebeginningofyourdocument.
UsetheContent-TypeHTTPheaderwhileservingthedocumentifyoucan.
ThefollowingisanexampleofsuchanHTTPheader:ibm.
com/developerWorks/developerWorksThinkingXML:TheXMLflavorofHTML5Page5of9Content-Type:"text/html;charset=UTF-8"ThenewsemanticmarkupelementsHTML5introducesnewelementsthatprovideclearersemanticsforcontentstructure,suchassectionandarticle.
ThesearethepartsofHTML5thatmightstillbesubjecttochange,butchangeswillnotlikelybedrastic,andtheriskisbalancedbytheimprovedexpressionprovidedbythenewelements.
OneproblemisthatInternetExplorerdoesn'tconstructtheseelementsinDOM,so,ifyouuseJavaScript,you'llneedtoemployanotherworkaround.
RemySharpmaintainsaJavaScriptfixthatyoucandeploybyincludingthefollowingsnippetinyourdocumenthead(seeRelatedtopicsforalink).
YoumightalsoneedtodefineCSSrulesfortheelementsjustincaseanybrowsersdorenderyourdocumentinHTML4stylewhichdefaultsunknownelementstoinlinerendering.
ThefollowingCSSshouldwork.
header,footer,nav,section,article,figure,aside{display:block;}Recommendationforthedesperatewebhacker:UsethenewHTML5elements,butincludetheHTML5shivJavaScriptanddefaultCSSrulestosupportthem.
BringingitalltogetherI'vemademanyseparaterecommendations,soI'llbringthemalltogetherintoacompleteexample.
Listing1isXHTML5thatmeetstheserecommendations.
WhenservingitoverHTTP,usetheheaderContent-Type:"text/html;charset=UTF-8"unlessyoucanaffordtorefusesupportforInternetExplorer,inwhichcaseusetheheaderContent-Type:"application/xhtml+xml;charset=UTF-8".
Listing1.
CompleteXHTML5exampleAmicroblog,inXHTML5header,footer,nav,section,article,figure,aside{display:block;}OtherJavaScriptgoeshere.
.
.
-->developerWorksibm.
com/developerWorks/ThinkingXML:TheXMLflavorofHTML5Page6of9AmicroblogThereissomethingimportantIwanttosay:Astitchintimesavesnine.
Bytheway,areyouasexcitedabouttheWorldCupasIamWelcometomynewXHTML5weblogArchivesApril2010May2010June2010©2010byUcheOgbujiHomeAboutHomeListing1usestheHTML5DTDeclanddeclaresthedefaultnamespaceatthetop.
Thestyleandscriptelementsinthisexamplejustprovideworkaroundsforreal-worldbrowserissues.
ThescriptelementisonlyneededifyouareusingotherJavaScript.
ThedocumentusesalotofthenewHTML5elements,whichIwon'tgointoindetailsincetheyarenotspecifictotheXMLnature.
SeeRelatedtopicsformoreinformationabouttheseelements.
Noticethe"self-closed"syntaxusedfortheimgelement(inotherwords,itendsin/>),andtheuseofnumericentityformforthecopyrightsymbol,©.
YoucanrefertoTable1forasummaryofhowtheaboveexamplewillbehavewithvariousbrowsers.
Table1.
BrowsersupportforXHTML5thatmeetstherecommendationsinthisarticleBrowserBehaviorLegacybrowser(forexampleInternetExplorer6.
xorlower,Netscape,Firefox1.
x)Renderingwillbeunpredictable.
Forexample,"self-closed"elementsmightbemistakenforendtags.
YouwillnotgetanyerrorsifyouuseHTMLnamedentities.
ibm.
com/developerWorks/developerWorksThinkingXML:TheXMLflavorofHTML5Page7of9InternetExplorer7or8Renderingwillberegular"tagsoup"HTML,becauseoftext/htmlMIMEtype,butthepresenceofanyDTDeclwilltrigger"standardsmode,"suchasInternetExploreroffersit.
NoerrorreportforHTMLnamedentities.
Modern,HTML5-awarebrowser,suchasFirefox3.
x,Safari4,orrecentOperaorGoogleChromeRenderingwillbeHTML5(notXHTML5)becauseoftheMIMEtype,butin"standardsmode.
"NoerrorreportforHTMLnamedentities.
AnystandardXML1.
xprocessorTheMIMEtypewillnotbeconsidered.
Theparserwillseeallelementsgenerically,intheXHTMLnamespace.
YouwillreceiveerrormessagesifyouuseanybogusHTMLnamedentities.
WrapupOneimportant,recentdevelopmentisthattheW3CHTMLWorkingGrouppublishedaFirstPublicWorkingDraft,"PolyglotMarkup:HTML-CompatibleXHTMLDocuments,"(seeRelatedtopicsforalink)withtheintentionofgivingXHTML5amorethorough,accurateandup-to-datebasis.
Again,ithasbeenverypainfulformetomakemanyoftherecommendationsinthisarticle.
Suchhack-aroundscomefromlong,painfulexperience,andaretheonlywaytoavoidanightmareofhard-to-reproducebugsandstrangeincompatibilitieswhenmixingXMLintotherealHTMLworld.
ThiscertainlydoesnotmeanthatIhavestoppedadvocatingcarefulXMLdesignandbestpractices.
ItisbesttosaveXHTML5fortheveryoutermostcomponentsthatconnecttobrowsers.
AllflavorsofXHTMLarebetterseenasrenderinglanguagesthaninformation-bearinglanguages.
YoushouldcarrythemaininformationthroughoutmostofyoursysteminotherXMLformats,andthenconverttoXHTML5onlyatthelastminute.
YoumightwonderwhatisthepointofcreatingXHTML5evenatthelastminute,butrememberPostel'slaw,whichrecommendsbeingstrictinwhatyouproduce.
ByproducingXHTML5forbrowsers,youmakeiteasierforotherstoextractinformationfromyourwebsitesandapplications.
Inthisageofmash-ups,webAPIs,anddataprojects,thatisavaluablecharacteristic.
ThankstoMichaelSmithforbringingmyattentiontorecentdevelopmentsinthisspace.
developerWorksibm.
com/developerWorks/ThinkingXML:TheXMLflavorofHTML5Page8of9RelatedtopicsTheHTML5syntaxissuessectionoftheWHATWGFAQ:JointhediscussionofXMLissues.
TheW3CworkingdraftstandardforXHTML5:KeepupwithsyntaxforusingHTMLwithXML,whetherinXHTMLdocumentsorembeddedinotherXMLdocuments.
"PolyglotMarkup:HTML-CompatibleXHTMLDocuments"(W3CHTMLWorkingGroup,June2010):ReadthisrecentlypublishedWorkingDraftwithamorerigorousbasisforXHTML5.
Newelements,attributesandotherlanguagefeaturesinHTML5:LearnaboutthenewelementsavailableinXHTML5.
Tip:AlwaysuseanXMLdeclaration(UcheOgbuji,developerWorks,June,2007):Unfortunately,becauseofbrowserinconsistencies,thisarticlerecommendsnotusingtheXMLdeclarationinXHTML5filesservedforbrowsers.
Readwhyitisalwaysagoodideatodosoingeneralinthistip.
ThankstoMichaelSmithforbringingmyattentiontorecentdevelopmentsinthisspace.
LearnmoreaboutHTML5indeveloperWorksarticlesandtutorials:NewelementsinHTML5Structureandsemantics(ElliotteRustyHarold,August2007):ExplorenewstructuralandinlineelementsinHTML5.
CreatemodernwebsitesusingHTML5andCSS3(JoeLennon,March2010):ImplementthecanvasandvideoelementsofHTML5inthishands-onintroductiontoHTML5andCSS3.
BuildwebapplicationswithHTML5(MichaelGalpin,March2010):Createtomorrow'swebapplicationstodaywithpowerfulHTML5featuressuchasmulti-threading,geolocation,embeddeddatabases,andembeddedvideo.
HTML5—XML'sStealthWeapon(JonnyAxelsson,July2009):ReadareasonablesummaryofthehistorythatledtoXHTML5.
Postel'slaw:Learnmoreaboutthis.
Itisalsocalledtherobustnessprinciple.
html5libproject:IfyouwanttoeasilyconsumeHTMLorXHTML5,checkoutPythonandPHPimplementationsofaHTMLparser,whichincludesbindingsforPython,C,PHPandRuby.
NewtoXML:IfyouarenewtoXML,startexploringXMLandallyoucandowithit.
Readersofthiscolumnmightbetooadvancedforthispage,butit'sagreatplacetogetyourcolleaguesstarted.
AllXMLdeveloperscanbenefitfromtheXMLzone'scoverageofmanyXMLstandards.
IBMcertification:FindouthowyoucanbecomeanIBM-CertifiedDeveloper.
ThedeveloperWorksXMLzone:FindmoreXMLresources,includingpreviousinstallmentsoftheThinkingXMLcolumn.
Ifyouhavecommentsonthisarticle,oranyothersinthiscolumnpleasepostthemontheThinkingXMLforum.
XMLtechnicallibrary:SeethedeveloperWorksXMLZoneforawiderangeoftechnicalarticlesandtips,tutorials,standards,andIBMRedbooks.
IBMproductevaluationversions:Getyourhandsonapplicationdevelopmenttoolsandmiddlewareproducts.
ibm.
com/developerWorks/developerWorksThinkingXML:TheXMLflavorofHTML5Page9of9CopyrightIBMCorporation2010(www.
ibm.
com/legal/copytrade.
shtml)Trademarks(www.
ibm.
com/developerworks/ibm/trademarks/)

PQ.hosting:香港HE/乌克兰/俄罗斯/荷兰/摩尔多瓦/德国/斯洛伐克/捷克vps,2核/2GB内存/30GB NVMe空间,€3/月

PQ.hosting怎么样?PQ.hosting是一家俄罗斯商家,正规公司,主要提供KVM VPS和独立服务器,VPS数据中心有香港HE、俄罗斯莫斯科DataPro、乌克兰VOLIA、拉脱维亚、荷兰Serverius、摩尔多瓦Alexhost、德国等。部分配置有变化,同时开通Paypal付款。香港、乌克兰、德国、斯洛伐克、捷克等为NVMe硬盘。香港为HE线路,三网绕美(不太建议香港)。免费支持wi...

创梦网络-新上雅安电信200G防护值内死扛,无视CC攻击,E5 32核高配/32G内存/1TB SSD/100Mbps独享物理机,原价1299,年未上新促销6折,仅779.4/月,续费同价

创梦网络怎么样,创梦网络公司位于四川省达州市,属于四川本地企业,资质齐全,IDC/ISP均有,从创梦网络这边租的服务器均可以****,属于一手资源,高防机柜、大带宽、高防IP业务,另外创梦网络近期还会上线四川眉山联通、广东优化线路高防机柜,CN2专线相关业务。广东电信大带宽近期可以预约机柜了,成都优化线路,机柜租用、服务器云服务器租用,适合建站做游戏,不须要在套CDN,全国访问快,直连省骨干,大网...

香港九龙湾(27元) 2核2G 20元 香港沙田

弘速云是创建于2021年的品牌,运营该品牌的公司HOSU LIMITED(中文名称弘速科技有限公司)公司成立于2021年国内公司注册于2019年。HOSU LIMITED主要从事出售香港VPS、美国VPS、香港独立服务器、香港站群服务器等,目前在售VPS线路有CN2+BGP、CN2 GIA,该公司旗下产品均采用KVM虚拟化架构。可联系商家代安装iso系统。国庆活动 优惠码:hosu10-1产品介绍...

blockquote为你推荐
设置xpAnthemmy我研制千万亿次超级电脑支持ipad勒索病毒win7补丁怎么删除 防勒索病毒 打的补丁谷歌sb在谷歌里搜SB为什么结果中第一个是百度win7关闭135端口win7系统 怎么关闭135 445 端口 修改注册表 创建IP安全策略 也试过 就是关不了 还望高手指教chromeframe谷歌浏览器(Chrome) 与(Chromium) 有什么区别?哪个更快?css选择器请给出三种Css选择器并举例说明kb4012598win7怎么查看电脑是否安装了 ms17 010
asp网站空间 绍兴服务器租用 日本动态vps 域名交易网 greengeeks softbank官网 gitcafe 阿里云代金券 京东商城0元抢购 cloudlink 德隆中文网 服务器防火墙 ssl加速 创速 葫芦机 湖南铁通 蓝队云 cc加速器 电信测速器在线测网速 shuangshiyi 更多