Tải bản đầy đủ - 0 (trang)
Chapter 1. Microsoft Office and XML

Chapter 1. Microsoft Office and XML

Tải bản đầy đủ - 0trang

1.1WhyXML?

ExtensibleMarkupLanguage(XML)definesatext-basedformat

containinglabelsandstructures.XMLlooksalotlikeHTML,the

primarylanguageusedbywebbrowsers,butXMLletsusers

anddeveloperscreatetheirownformatsratherthanlimiting

themtoasinglevocabulary.TheXML1.0specificationappeared

in1998,andawidevarietyofapplicationshaveaddedXML

functionalityorbeenbuiltaroundXMLsincethen,from

databasestostocktickerstoeditorstowebbrowsersto

inventorysystems.WhileXMLstillrequiresreadersandwriters

ofdocumentstohavesomesharedunderstandingsaboutthe

documentstheycreateandinterpret,itprovidesabasicformat

thatiseasilyprocessedinawidevarietyofdifferent

environmentsit'sevenfrequentlyhuman-readable.



Ifyou'veneverworkedwithXMLandneedtoknowthetechnicaldetails

ofhowtoreadandcreateXMLdocuments,youshouldreadAppendixA

ofthisbook.Thischapterprovidesahigh-levelviewofwhatXML

makespossibleandwhyitmakessenseforOffice,notadetailed

explanationofwhatXMLis.



MicrosofthasbeeninvolvedwithXMLforalongtime.A

Microsoftemployee,JeanPaoli(lateraproductmanagerfor

MicrosoftOffice),wasoneoftheeditorsoftheXML1.0

specificationattheWorldWideWebConsortium(W3C).

MicrosofthasbeeninvolvedwithnearlyeveryXMLspecification

attheW3Csince,andhasparticipatedinawidevarietyofXMLrelatedprojectsatotherorganizationsaswell.Microsoftbegan

workonXMLtoolsbeforethespecificationwascomplete,

buildingtheMSXMLtoolkitintoInternetExplorerandthen

expandinginto.NETandWebServicesdevelopment.Moreand



moreMicrosoftsoftwarehasXMLatitscore,andthislatest

versionofOfficejoinsalargegroupofMicrosoftapplications

usingXML.

XMLhasbeenacrucialpartofMicrosoft'sdrivetoputits

programsinmoreandmoreenvironments.XMLmakesit

possibleforMicrosoftprogramstocommunicatewithprograms

fromIBM,Sun,Oracle,andothers,andgreatlysimplifiesthe

taskofintegratingnewtoolswithcustomcode.Developerscan

buildapplicationsaroundXML,anddon'thavetoworryabout

theinternaldetailsofcomponentswithwhichtheyshareXML.

Equallyimportant,developersusingXMLdon'thavetoworry

aboutbeinglockedintoaformatthat'sproprietarytoasingle

vendor,becauseXMLisopenbydesign.Therulesforwhatis

andwhatisnotalegitimateXMLdocumentareveryclear,and

whileit'spossibletocreateXMLthatisdifficulttoread,a

combinationofstrictgrammaticalrulesandwidely-sharedbest

practicesencouragesdeveloperstocreateformatsthatareeasy

toworkworth.XMLalsoincludesfeaturesthatsupport

internationalizationandlocalization,makingitmucheasierto

consistentlyrepresentinformationacrosslanguageboundaries

aswellasprogramboundaries.

ByaddingXMLtotheMicrosoftOfficemix,Microsoftboth

makesitmucheasiertointegrateOfficewithMicrosoft

programsthatalreadyunderstandXML(likeSQLServer,

SharePointServer,andthetoolkitsinVisualStudio)andfor

developerstocreatetheirowncombinationsofMicrosoftOffice

andothersoftware.ThisallowsMicrosofttoconnecttoamuch

widervarietyofsoftwarewithoutmakingusersworryabout

whetherthey'llbeabletousethatinformationelsewhere.XML

alsoletsusersgomuchfurtherinbuildingcustomapplications

aroundMicrosoftOffice.

XMLitselfisonlyonepieceofalargerXMLpuzzle.Extensible

StylesheetLanguageTransformations(XSLT)isanXML-based

languagefortransformingoneXMLdocumentintoanother,

usingtemplates.XSLTisattheheartofmuchoftheOfficeXML



work,akeyingredientformovingfromtheXMLyouhavetothe

XMLOfficeneedsandvice-versa.Anotherspecification,W3C

XMLSchema,providesdescriptionsofdocumentstructures

whichthevariousOfficeapplicationscanuseasafoundationfor

theirprocessing.MicrosoftreferstothisasXMLSchema

Definitionlanguage,orjustXSD,buttheW3Citselfdidn't

provideanacronym.SomesourcesrefertoitasWXS(forW3C

XMLSchema),othersasXSD,someasXSDL,andsomejustas

XMLSchema.BecauseMicrosoftgenerallyreferstoitasXSD,

thisbookwilldothesame.

OneaspectofXMLdevelopmentinparticulardeservesspecial

mention,becauseMicrosofthasintegrateditintoOffice

alongsidethemoregenericXMLeditingandanalysisfunctions.

WebServices,builtontheSOAP,WSDL,andUDDI

specifications,provideasetoftoolsforcommunicatingwith

otherprogramsusingXML.Youcanstillreadandwritefiles

fromyourlocalcomputer,afileserver,orawebserver,butWeb

Servicesexposeadditionalfunctionalityofprogramslocated

anywhereonthenetwork.



1.2DifferentFacesofXML

EachoftheOfficeapplicationsthatworkswithXMListargeted

toaparticularsetofXMLuses.WhilemanypeoplethinkofXML

asageneral-purposeformatthatcanstoreanykindof

information,therearesomeseriousdivisionsinthewayXMLis

usedandinthepracticessurroundingthatuse.Whilesomeof

thesesoundliketheusualprogrammingdivides,whereVisual

Basic,C#,Perl,andJavaprogrammersalllookatthesame

informationslightlydifferently,someofthemaremorelikethe

divisionsbetweenpeoplewhoprimarilyuseWordtocreate

documentsandpeoplewhoprimarilyuseAccesstocreateand

presentdatabases.

ThemostcommonlydiscusseddivisionintheXMLworldisthe

dividebetweendocumentsanddata.XML'spredecessor,

StandardGeneralizedMarkupLanguage(SGML)wasused

primarilyfordocumentmanagement.Whilehavingstructuresin

documentswasakeyfeaturefororganizationswithhuge

numbersofdocumentslikevariousdepartmentsofdefense,the

U.S.InternalRevenueService,airplanemanufacturers,and

publishers,thestructuresweregenerallyseenaslabelsapplied

todocuments,notasstructuresdefiningthecontentsofthe

documents.Documentshavetobeaccessibletohumansaswell

ascomputers,anddocumentstructuresneedtobeabletokeep

upwiththemanyintricatestructureshumanscreatetosolve

particularproblems.

DeveloperswhofocusondatastructurestypicallyseeXMLasa

toolforcreatinglabeledcontainersforinformation.Whilethere

maybesomevariationsinthatdataandperhapsevensome

intricatedatastructures,thecontentsaregenerallyexpectedto

conformtothestructures,nottheotherwayaround.

Programmerswhowanttoexchangedatatypicallystartby

definingstructures,andbuildcodearoundthosestructures.

Manyprogramstructures,especiallyefficientprogram



structures,areverybrittleanddon'ttakekindlytochanges

becauseofdifferentcontextsorpeopleaddingextralayersof

labelsandstructures.

Whilethesetwocampsareoftenseenasseparateandmutually

suspicious,theycananddomix.Manydocumentscontainsome

stronglystructuredinformation,liketablesorlists,and

sometimesdataneedsanescapehatchforpossibilitiesthat

can'tallbepredictedinadvance.Databaseshavelonghad

fieldsthatcansupportinformationin"rich"formats,from

simpletextwithboldanditalictocomplexmultimedia.XMLis

notacure-allthatcanmakeallofthesedifferentviewson

informationplaynicelytogether,butitdoesofferenormous

inherentflexibilityforrepresentingdifferentkindsandstylesof

information.(Sadly,noXMLfeaturesappearinMacintosh

versionsofOffice.)



1.3DifferentXMLFacesofOffice

MicrosoftOfficehasalwaysbundledasetoftoolsspecializedfor

workingwithinformationofparticularkinds.ThenewXML

functionalitycontinuesthattradition,witheachapplicationin

thebundleusingXMLinwaysthatfititsparticulartask.

Microsofthasalsoaddedanewapplication,InfoPath,tothe

EnterpriseEditionofMicrosoftOffice,fillingacommonbusiness

needforflexibleforms-basedinterfacestostructured

information.



1.3.1Word:EditingDocuments

Wordbeganasaprogramthatletpeopleexpresstheirthoughts

onpaper,andmostuserstendtothinkofitasaconveniently

editabletypewriter.AlthoughWordhasaddedmorefeatures

overtime,likemailmergecapabilitiesandwebpageediting,it

isstillsquarelyfocusedondocuments.Whileit'spossibletouse

Wordasacalculatororadatabase,itsprimarystrengthhas

alwaysbeenthecreationofdocuments.

MicrosofthastakenWord'straditionaldocument-orientationand

extendeditintotheworldofdocument-orientedXML.Word

alreadydealswithstructureddocumentsthroughfeatureslike

styles,footnotes,forms,andcomments,andisquitecapableof

supportingcomplexlayersofvariablestructure.Whenasked

whattheywantinanXMLdocumenteditor,manypeoplecite

theirexperienceusingWordandMicrosofthasprettymuchgiven

thattothem.

WordembracesXMLontwolevels.Withoutmucheffort,users

cansaveanyWorddocumentasXML,usingavocabularythat

reflectsWord'snativeunderstandingofthedocument.Styles,

formatting,comments,revisionmarks,metadata,and



everythingelsethatnormallygoesintoa.docfileare

preserved.Betterstill,allthisinformation(exceptforembedded

objects,storedasBase64-encodedstrings)isreadilyaccessible,

anddeveloperscanuseanyXMLtoolsorevenatexteditorto

exploreandprocessit.Wordcanopenthesefilesasifthey

were.docfilesaswell,makingitpossibleforotherapplications

tocreateXMLdocumentsexplicitlyforconsumptionbyMicrosoft

Word.

Wordtakesthesefeaturestothenextlevelbyallowing

developerstocreatetheirownXMLvocabulariesandeditthose

documentsusingWord,asshowninFigure1-1.Thistakesmore

effortaswellasanunderstandingofXML,XSLT,andXSD,but

thatunderstandingisonlynecessarytocreatethetemplates,

nottousethem.Oncethetemplatesarecreated,userscan

simplyeditXMLwithintheordinaryconfinesofWord.Theycan

eventellWordtoshowthemthesameinformationwitha

differentsetofpresentationchoices,makingiteasytoreuse

informationoreditdocumentsinaformconvenientforediting,

whilepresentingitmoreformallylater.



Figure1-1.EditinganXMLdocumentinMicrosoft

Word2003



AlthoughWordisanewcomertoXML,MicrosofthasdrivenXML

foundationsdeepintotheprogram.SimplyexposingWord

informationasXMLisasizablestep,butWordhasaimedhigher

withitsapproachtolettingusersedittheXMLoftheirchoicein

WordratherthantheXMLofMicrosoft'schoice.Thisshould

makeitmucheasiertouseWordasaninterfacetoamuch

widervarietyofXML-basedsystems,fromWebServicesto

contentmanagementandworkflow.



1.3.2Excel:AnalyzingInformation

ThespreadsheetwasawildnewconceptwhenVisiCalcfirst

appearedbackin1981,andspreadsheetsarestillafascinating

hybridofdatastorageanddataprocessing.Excelhasgrown

overtheyearsfromabasiccalculatingtooltoapowerfulsetof

featuresforanalyzingandpresentinglargelynumericaldata.



WhilemanyExcelspreadsheetsquietlyprocessdataontheir

creators'computers,othershaveevolvedintoprogramsby

themselves,providinganinterfacetoproblem-solvingtoolsthat

peoplebeyondtheircreatorscanuse.

ExcelhashaditsownXMLformatsinceExcelXP.Whilethis

formatdoesn'tincludequiteeverythingVisualBasicfor

Applicationscodeisn'tincluded,andchartsaren'teitherthis

formatincludesenoughinformationthatit'spossiblefor

applicationtomineExcelspreadsheetsandextracttheir

information.Acommoncomplaintaboutspreadsheets

(especiallyamongdatabasepurists)isthatinformationgoesin

butdoesn'tcomeout.Microsoft'sXMLSpreadsheetformatis

relativelyeasytointerpretandprovidesafoundationfor

exchanginginformationbetweenExcelandotherapplications.

Excel2003goesbeyondhavinganXMLformat.Whileit's

certainlypossibleforotherapplicationstocreateXML

Spreadsheetfilescontainingtheirinformation,it'sgenerally

moreconvenienttobeabletoopenwhateverXMLfilesare

alreadyavailable(evenwithoutaschema)andanalyzethem

withinExcel,asshowninFigure1-2.Thismakesitpossibleto

createaspreadsheetthatcananalyzeanygivenXML

documentsay,monthlysalesdataandkeepusingthatsame

spreadsheetonnewdatawhenitappears.



Figure1-2.WorkingwithXMLdatamappedinto

MicrosoftExcel2003.



ThemappingfeaturesincludedinExcelmakeitmucheasierto

createreusablespreadsheets,andsimplifythetaskofcreating

Excel-basedapplicationsforanalyzingdata.Theyalsomakeit

mucheasiertoseparatetherawdatafromtheExcel

spreadsheet,lettingthespreadsheetstayuptodateevenwhen

thedataitfirstanalyzedisn't.Tosomeextentthisislike

connectingExceltoadatabase,butit'sagooddealmore

flexible.Ifyourdocumentstructuresaresimpleenough,you

canalsouseExcelasasimpleXMLeditor.



1.3.3Access:SharingData

Accessremainsarelationaldatabaseforthedesktop,providing

convenientlocalstorageofstructuredinformationaswellasan

interfaceforinformationonbothlocalandremotedatabases.

OfalltheproductsintheOfficesuite,Accessisthestrictestin

demandingthatinformationconformtopredefinedrules,using

thosestructuresasafoundationforalltheotherworkit

performs.

LikeExcel,AccesshashadsomeXMLsupportinearlier

versions,supportinganXMLvocabularyforimportingand



exportinginformation.Access2003substantiallyupgradesthat

XMLsupport,however.NewfeaturesincludesupportforXML

datathatisstoredacrossmultipletables,integratedXSLT

transformationswhenimportingorexportinginformation,and

greaterstandards-complianceforbothXSLTandXSD.Youcan

seeAccess'XMLexportfunctionalityinFigure1-3.These

featuresarealsonowmoreaccessiblefromapplicationsbuilt

usingAccess.



Figure1-3.ExportingXMLinMicrosoftAccess

2003



BecauseAccessisbuiltonarelationaldatabasefoundation,it

doesn'treallymakesensetodriveXMLintoitscore.It's

possibletorecreatetablesinXML,butthatlosestherandom

accessandindexingfeaturesthatmakerelationaldatabasesso

goodatquicklyprocessingstructuredinformation.StoringXML

documentsinsideofrelationaldatabasesisalsopossible,but

again,thecostsarehigh.Communicatingwiththeoutside

worldusingXMLseemstoprovidethebestbalancebetween



Tài liệu bạn tìm kiếm đã sẵn sàng tải về

Chapter 1. Microsoft Office and XML

Tải bản đầy đủ ngay(0 tr)

×
x