Tải bản đầy đủ - 0 (trang)
3 WordprocessingML's Style of Markup

3 WordprocessingML's Style of Markup

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

inWordprocessingML.Thehierarchyisflattenedintoasequence

ofrunshavingdifferentformattingproperties:









Thissentencehas













mixed













formatting.





Asyoucansee,allofthetextoccursbyitself(nomixed

content),withinw:telements.



2.3.2PropertiesAreSetUsingEmptySubElements

Theabovesnippetillustratesanothergeneralprinciplein

WordprocessingML'sstyleofmarkup:propertiesareassigned

usingemptysub-elements(e.g.,w:bandw:iintheabove

example).Forruns,thew:rPrelementcontainsasetofempty

elements,eachofwhichsetsaparticularpropertyontherun.

Similarly,forparagraphs(w:pelements),thew:pPrelement

containstheparagraphformattingproperties.Fortables,table

rows,andtablecells,therearethew:tblPr,w:trPr,and

w:tcPrelements,respectively.Ineachcase,the*Prelement

mustcomefirst,sothatthegeneralstructureofparagraphs,

runs,tables,tablerows,andtablecellslookslikethis:

Object

Properties

Content



Thepropertiesaredefinedfirst,andthecontentfollows.Ifyou

haveanyexperiencewithRTF(RichTextFormat),thenthis

patternmaylookfamiliar.Beforetheadventof



WordprocessingML,RTFwasthemostopenformatinwhich

Wordwaswillingtosavedocuments.Alookatthesame

sentenceaftersavingitasRTFisdemonstrative:

{\b\insrsid3691043Thissentencehas}

{\b\i\insrsid3691043mixed}

{\b\insrsid3691043formatting.}



Theparallelsshouldbefairlyeasytodraw,without

understandingeverydetail.Therearethreeruns(delineatedby

curlybraces).Thefirstrunhasboldturnedonbyvirtueofthe

\bcommand.Thesecondrunhasbothboldanditalicturnedon

byvirtueofthe\band\icommands.Andthethirdrungoes

backtousingjustboldandnoitalic.Fromthisperspective,

WordprocessingMLmaylookmorelikeanXMLformatforRTFan

estimationthatisnottoofaroffthemark.



TolearnmoreaboutRTF,considertheRTFPocketGuide(O'Reilly),by

SeanM.Burke.



2.3.3NoHierarchicalDocumentStructures

Nestedmarkupdescribestheuseofelementnestingto

arbitrarydepths.Inadditiontoformattingtext,nestedmarkup

isusefulforstructuringdocuments.Forexample,aDocbook

documentmayhavesectionsandsub-sectionsnestedtoan

arbitrarydepth,likethis:







Section1

Thisisthefirstsection.



Section1A

Thisisasub-section.









Theabovedocumentisrepresentedmuchdifferentlyin

WordprocessingML.Thehierarchyisflattenedintoasequenceof

fourparagraphshavingdifferentproperties.Belowisthe

w:bodyelement,excerptedfromsuchadocument:















Section1









Thisisthefirstsection.















Section1A











Thisisasub-section.









InWord,theparagraphisthebasicblock-orientedelement,and

paragraphsmaynotcontainotherparagraphs.Worddoes,

however,provideaworkaroundforhierarchicaldocuments,

throughuseofthewx:sub-sectionelement.Infact,ifyou

weretoopentheabovedocumentandthensaveitfromwithin

Word,theresultwouldincludewx:sub-sectionelementsthat

reflectthehierarchyintendedbytheheadingparagraphs.We'll

lookathowthisworksindetaillater,inSection2.6.2.



2.3.4AllAttributesAreNamespace-Qualified

OnemorepeculiarityworthnotingaboutWordprocessingML

markupisitsuseofnamespace-qualifiedattributes.Inmost

XMLvocabularies,attributesarenotinanamespace.Theyare

generallythoughtto"belong"totheelementtowhichtheyare

attached.Aslongastheelementisinanamespace,thenno

namingambiguitiesshouldarise.Namespacequalification,

however,canbeusefulfor"globalattributes"thatcanbe

attachedtodifferentelements.Suchattributesdonotbelongto

anyparticularelement.Thexml:spaceattributeisagood

exampleofaglobalattribute.XSLTalsohassomeglobal

attributes,suchasthexsl:exclude-result-prefixes

attribute,whichcanoccuronanyliteralresultelement(inany

namespace).Theseareconsideredgoodusecasesfor



qualifyingattributeswithanamespace.

WordprocessingML,however,doesnotfollowthisconvention.

Whiletherearesome"globalattributes"inWordprocessingML

(suchasthew:typeattribute,whichappearsonthe

aml:annotationelement,whichwe'llsee),WordprocessingML

doesnotrestrictitsuseofnamespacequalificationtothose

cases.Instead,ituniversallyqualifiesallattributesacrossthe

board.Forthisreason,thekeythingtorememberwhen

workingwithattributesinWordprocessingMListhattheyalways

musthaveanamespaceprefix(becausethere'snosuchthing

asadefaultnamespaceforattributesinXML).



2.4ASimpleExampleRevisited

Example2-2showshowour"Hello,World"examplelooksafter

openingitinWord,selectingSaveAs...,andsavingthefile

withanewname,HelloSaved.xml.Forthesakeofreadability,

we'veaddedlinebreaksandindentation,neitherofwhich

affectsthemeaningofthefile.Thehighlightedlinesinthis

examplecorrespondtothelinesthatwerepresentinour

originalhand-editedWordprocessingMLdocumentinExample21.Everythingelseisnew.



Example2-2.ThesameWorddocument,after

WordsavesitasXML








xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml

xmlns:v="urn:schemas-microsoft-com:vml"

xmlns:w10="urn:schemas-microsoft-com:office:word"



xmlns:sl="http://schemas.microsoft.com/schemaLibrary/2003/cor

xmlns:aml="http://schemas.microsoft.com/aml/2001/core"



xmlns:wx="http://schemas.microsoft.com/office/word/2003/auxHi

xmlns:o="urn:schemas-microsoft-com:office:office"



xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882"



w:macrosPresent="no"w:embeddedObjPresent="no"w:ocxPresent="

xml:space="preserve">



Hello,World

EvanLenz

EvanLenz

4

15

2003-12-06T22:45:00Z

2003-12-18T07:59:00Z

1

2

12

1

1

13

11.5604












w:h-ansi="TimesNewRoman"w:cs="TimesNew



































w:styleId="DefaultParagraphFont">








































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

3 WordprocessingML's Style of Markup

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

×