diff options
author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2014-07-23 15:25:44 +0200 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2014-07-23 15:25:44 +0200 |
commit | 8286ac511144e4f17d34eac9affb97e50646344a (patch) | |
tree | f1af7320d7b6be6be059216d0ad08ac7b4f73fd0 /xsd/doc/cxx/tree | |
parent | a15cf65c44d5c224169c32ef5495b68c758134b7 (diff) |
Imported Upstream version 4.0.0upstream/4.0.0
Diffstat (limited to 'xsd/doc/cxx/tree')
-rw-r--r-- | xsd/doc/cxx/tree/guide/cxx-tree-guide.pdf | bin | 0 -> 95081 bytes | |||
-rw-r--r-- | xsd/doc/cxx/tree/guide/cxx-tree-guide.ps | 3509 | ||||
-rw-r--r-- | xsd/doc/cxx/tree/guide/guide.html2ps | 65 | ||||
-rw-r--r-- | xsd/doc/cxx/tree/guide/index.xhtml | 2732 | ||||
-rw-r--r-- | xsd/doc/cxx/tree/guide/makefile | 54 | ||||
-rw-r--r-- | xsd/doc/cxx/tree/makefile | 41 | ||||
-rw-r--r-- | xsd/doc/cxx/tree/manual/cxx-tree-manual.pdf | bin | 0 -> 221921 bytes | |||
-rw-r--r-- | xsd/doc/cxx/tree/manual/cxx-tree-manual.ps | 7382 | ||||
-rw-r--r-- | xsd/doc/cxx/tree/manual/index.xhtml | 6822 | ||||
-rw-r--r-- | xsd/doc/cxx/tree/manual/makefile | 54 | ||||
-rw-r--r-- | xsd/doc/cxx/tree/manual/manual.html2ps | 66 | ||||
-rw-r--r-- | xsd/doc/cxx/tree/reference/footer.html | 6 | ||||
-rw-r--r-- | xsd/doc/cxx/tree/reference/libxsd.doxygen | 1322 | ||||
-rw-r--r-- | xsd/doc/cxx/tree/reference/makefile | 18 |
14 files changed, 22071 insertions, 0 deletions
diff --git a/xsd/doc/cxx/tree/guide/cxx-tree-guide.pdf b/xsd/doc/cxx/tree/guide/cxx-tree-guide.pdf Binary files differnew file mode 100644 index 0000000..3e19f3e --- /dev/null +++ b/xsd/doc/cxx/tree/guide/cxx-tree-guide.pdf diff --git a/xsd/doc/cxx/tree/guide/cxx-tree-guide.ps b/xsd/doc/cxx/tree/guide/cxx-tree-guide.ps new file mode 100644 index 0000000..a6c4a2b --- /dev/null +++ b/xsd/doc/cxx/tree/guide/cxx-tree-guide.ps @@ -0,0 +1,3509 @@ +%!PS +%%Title: C++/Tree Mapping Getting Started Guide +%%Creator: html2ps version 1.0 beta7 +%%EndComments +save +2000 dict begin +/d {bind def} bind def +/D {def} d +/t true D +/f false D +/FL [/Times-Roman +/Times-Italic +/Times-Bold +/Times-BoldItalic +/Courier +/Courier-Oblique +/Courier-Bold +/Courier-BoldOblique +/Helvetica +/Helvetica-Oblique +/Helvetica-Bold +/Helvetica-BoldOblique] D +/WF t D +/WI 0 D +/F 1 D +/IW 471 F div D +/IL 621 F div D +/PS 791 D +/EF [0 1 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 2 2] D +/EZ [12 10 19 17 15 13 12 11 12 12 12 12 12 12 12 12 12 12 12 12 12 12 8 8] D +/Ey [0 0 2 2 2 2 2 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0] D +/EG [-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1] D +/Tm [1 1 0.8 0.8 0.8 0.8 0.8 0.8 0 0 0 0 0 0 0.5 1 1 1 1 0 0 1.3 0 0] D +/Bm [1 1 0.5 0.5 0.5 0.5 0.5 0.5 0 0 0 0 0 0 0.5 1 1 1 1 0 0 1 0 0] D +/Lm [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 2 2 0 0 2 0 0 0] D +/Rm [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0] D +/EU [-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 0 0] D +/NO f D +/YY [[{()}{ h }][{ h }{()}][{()}{()}]] D +/ZZ [[{ (July 2014) }{ Pn }][{ Pn }{ (July 2014) }][{ Ti }{ Ti }]] D +/Ts EZ 0 get D +/TU f D +/Xp t D +/AU f D +/SN 0 D +/Cf t D +/Tp t D +/Fe f D +/TI 2 Ts mul D +/Fm 14 D +/xL 71 D +/xR 71 D +/yL 706 D +/yR 706 D +/Wl 471 F div D +/Wr 471 F div D +/hL 621 F div D +/hR 621 F div D +/FE {newpath Fm neg Fm M CP BB IW Fm add Fm L IW Fm add IL Fm add neg L CP BB + Fm neg IL Fm add neg L closepath} D +/LA {PM 0 eq{/IW Wl D /IL hL D}{/IW Wr D /IL hR D}ie /W IW D /LL W D /LS W D + TU PM 0 eq and{IW 56 F div add SA{Sf div}if 0 translate} + {PM 0 eq{xL yL}{xR yR}ie translate F SA{Sf mul}if dup scale + CS CF FS Cf{CA CL get VC}if /Bb f D}ie 0 0 M + TF not Tc or {Cf{gsave SA{1 Sf div dup scale}if Cb VC FE fill grestore}if}if}D +/Pi 0 Ts mul D +/SG [0.8 1 1] D +/Ab 15 D +/J 0 D +/Tc t D +/NH 6 D +/Nf f D +/Pa f D +/LH 1.2 D +/XR f D +/Xr {/pN E D ( [p ) WB pN WB (] )WB} D +/Db [16#FF 16#FF 16#FF] D +/Dt [16#00 16#00 16#00] D +/eA f D +/Fi f D +/bT f D +/Lc t D +/Dl [16#00 16#00 16#00] D +/LX f D +/Br 0.25 D +/IA ([IMAGE]) D +/DS {/PF f D()WB NL NP()pop RC ZF} D +/Gb f D +/Mb t D +/Hc [16#00 16#00 16#00] D +/Bl 3 D +/MI -15.6 D +/DX (DRAFT) D +/Di 0 D +/Tt 113.385826771654 D +/Th { ( +) 2 Al()BR ( + ) 0 1 -1 H()4 FZ (C++/Tree Mapping) ES()EH ( + ) 0 1 -1 H()4 FZ (Getting Started Guide) ES()EH ( + ) 0 1 -1 H ( ) EH ( + ) 0 1 -1 H ( ) EH ( + ) 0 1 -1 H ( ) EH ( + ) 0 1 -1 H ( ) EH ( + ) 0 1 -1 H ( ) EH ( + ) 0 1 -1 H ( ) EH ( +) Ea()BR ( + ) 0 P (Copyright © 2005-2014 CODE SYNTHESIS TOOLS CC) EP ( + + ) 0 P (Permission is granted to copy, distribute and/or modify this + document under the terms of the + ) R0 2 A (GNU Free + Documentation License, version 1.2) EA (; with no Invariant Sections, + no Front-Cover Texts and no Back-Cover Texts. + ) EP ( + + ) 0 P (This document is available in the following formats: + ) R1 2 A (XHTML) EA (, + ) R2 2 A (PDF) EA (, and + ) R3 2 A (PostScript) EA (.) EP()} D +/tH {()0 1 -1 H (Table of Contents) EH()} D +/FD 2 D +/Dy 2 D +/cD [16#F0 16#F0 16#F0] D +/FW 0.6 D +/FU [16#00 16#00 16#00] D +/ET {/RM f D /A0 3 D /PN SN D /OU t D /Ou t D /W IW D /LL W D D1 + Ms not TP and{Ip}if /TF f D} D + +%-- End of variable part -- +/MySymbol 10 dict dup begin + /FontType 3 D /FontMatrix [.001 0 0 .001 0 0 ] D /FontBBox [25 -10 600 600] D + /Encoding 256 array D 0 1 255{Encoding exch /.notdef put}for + Encoding (e) 0 get /euro put + /Metrics 2 dict D Metrics begin + /.notdef 0 D + /euro 651 D + end + /BBox 2 dict D BBox begin + /.notdef [0 0 0 0] D + /euro [25 -10 600 600] D + end + /CharacterDefs 2 dict D CharacterDefs begin + /.notdef {} D + /euro{newpath 114 600 moveto 631 600 lineto 464 200 lineto 573 200 lineto + 573 0 lineto -94 0 lineto 31 300 lineto -10 300 lineto closepath clip + 50 setlinewidth newpath 656 300 moveto 381 300 275 0 360 arc stroke + -19 350 moveto 600 0 rlineto -19 250 moveto 600 0 rlineto stroke}d + end + /BuildChar{0 begin + /char E D /fontdict E D /charname fontdict /Encoding get char get D + fontdict begin + Metrics charname get 0 BBox charname get aload pop setcachedevice + CharacterDefs charname get exec + end + end}D + /BuildChar load 0 3 dict put /UniqueID 1 D +end +definefont pop + +/Cd {aload length 2 idiv dup dict begin {D} repeat currentdict end} D +/EX {EC cvx exec} D +/DU {} d +/BB {pop pop}d +/ie {ifelse} d +/E {exch} d +/M {moveto} d +/R {rmoveto} d +/L {lineto} d +/RL {rlineto} d +/CP {currentpoint} d +/SW {stringwidth} d +/GI {getinterval} d +/PI {putinterval} d +/Sg {setgray} d +/LW {setlinewidth} d +/S {dup () ne OU and{0 Co R AT 3 eq LB and HF not and A1 0 ne A2 0 ne or and + {A2 0 32 A1 0 6 -1 roll awidthshow}{show}ie 0 Co neg R}{pop}ie + OU PH 3 eq or{/Ms t D}if} D +/U {OU{gsave CP currentfont /FontInfo get /UnderlinePosition get + 0 E currentfont /FontMatrix get dtransform E pop add newpath M dup SW pop + CJ 0 RL stroke grestore}if} D +/B {OU Br 0 gt and{CP Ts neg Ts .33 mul R gsave 0 Sg + CP newpath Ts Br mul 0 360 arc closepath UI 2 mod 0 eq{stroke}{fill}ie + grestore M CP E Ts Br 1 add mul sub E BB /Ms t D}if}D +/NP {Ms TP not or PA and OU and{TP{OR}if f1{mF k2 /mF E D /YC 0 D}if + TP TU not PM 0 eq or and{showpage}if DU Ip TE not{LA}if 0.6 LW + /CI 0 D /TP t D /Hs f D /hl 6 D /Hv 6 D /HI hi D /Ms f D}if Bs XO BO M} D +/Np {LE sub CP E pop gt PL 0 eq and{NP}if}D +/Ip {/PN PN 1 add D /Pn RM{1}{4}ie PN Ns D /PM PN SN sub 2 mod D} D +/GP {E dup 3 -1 roll get PN 1 add 2 mod get dup type /integertype eq + {get 0 get}{E pop}ie}d +/Fc {dup 2 GP exec SW pop /S1 E D dup 1 GP exec SW pop /S2 E D 0 GP exec SW + pop /S3 E D S1 0 gt{S2 2 mul S1 add S3 2 mul S1 add 2 copy lt{E}if pop}{0}ie + S2 S3 add 2 copy lt{E}if pop IW .9 mul div dup 1 gt{1 E div}{pop 1}ie}D +/OR {Df{Sd}if tp not{gsave SA{1 Sf div dup scale}if Fe{Cf{FU VC}if FW LW + 1 setlinejoin FE stroke}if /YO {60 F div dup 40 gt{pop 40}if}D /cs CS D + /cf CF D /CF 0 D /pf PF D /PF f D /Fn FN D /At AT D /AT 0 D /FN EF Hf 1 add + get D Fz Fs FS ZZ Fc Fz mul Fs FS EU Hf 1 add get dup type /arraytype eq + Cf and{VC}{pop 0 Sg}ie IW IL neg YO sub M ZZ 1 GP exec dup SW pop neg 0 R Sh + 0 IL neg YO sub M ZZ 0 GP exec Sh ZZ 2 GP exec dup SW pop IW E sub 2 div + IL neg YO sub M Sh Fz Fs FS NO{/AW IW Pn SW pop sub D AW 2 div IL neg YO sub + S1 0 gt S2 AW .45 mul gt or S3 AW .45 mul gt or{Fz 2 mul sub}if M Pn Sh}if + EU Hf get dup type /arraytype eq Cf and{VC}{pop 0 Sg}ie YY Fc /FN EF Hf get D + Hz mul HS FS IW YO M YY 1 GP exec dup SW pop neg 0 R Sh 0 YO M YY 0 GP exec Sh + YY 2 GP exec dup SW pop IW E sub 2 div YO M Sh /FN Fn D /AT At D t Pb XO SZ + SL get neg R /PF pf D grestore /CF 0 D cs cf FS}if}D +/Sh {dup () ne{CP Hz 4 div sub BB show CP CS add BB}{pop}ie}D +/Pb {/OU E D /Ou OU D /PB t D 0 0 M Ba{/Sa save D /BP t D /Fl t D RC /PL 0 D + /PH 0 D /W IW D /LE IL .7 mul D /EO 0 D SI ZF /YA 0 D /BO 0 D /C1 () D + BA 0 Ts neg R Bb{Xl Yl Xh Yh}if Bb CP Sa restore M + {/Yh E D /Xh E D /Yl E D /Xl E D}if /Fl t D}if + BL /OU t D /HM f D /Ou t D /PB f D} D +/Bs {/BP Ba not D}D +/reencodeISO { + dup dup findfont dup length dict begin{1 index /FID ne{D}{pop pop}ie}forall + /Encoding ISOLatin1Encoding D currentdict end definefont} D +/ISOLatin1Encoding [ +/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef +/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef +/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef +/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef +/space/exclam/quotedbl/numbersign/dollar/percent/ampersand/quoteright +/parenleft/parenright/asterisk/plus/comma/hyphen/period/slash +/zero/one/two/three/four/five/six/seven/eight/nine/colon/semicolon +/less/equal/greater/question/at/A/B/C/D/E/F/G/H/I/J/K/L/M/N +/O/P/Q/R/S/T/U/V/W/X/Y/Z/bracketleft/backslash/bracketright +/asciicircum/underscore/quoteleft/a/b/c/d/e/f/g/h/i/j/k/l/m +/n/o/p/q/r/s/t/u/v/w/x/y/z/braceleft/bar/braceright/asciitilde +/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef +/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef +/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef +/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef +/.notdef/space/exclamdown/cent/sterling/currency/yen/brokenbar +/section/dieresis/copyright/ordfeminine/guillemotleft/logicalnot +/hyphen/registered/macron/degree/plusminus/twosuperior/threesuperior +/acute/mu/paragraph/periodcentered/cedilla/onesuperior/ordmasculine +/guillemotright/onequarter/onehalf/threequarters/questiondown +/Agrave/Aacute/Acircumflex/Atilde/Adieresis/Aring/AE/Ccedilla +/Egrave/Eacute/Ecircumflex/Edieresis/Igrave/Iacute/Icircumflex +/Idieresis/Eth/Ntilde/Ograve/Oacute/Ocircumflex/Otilde/Odieresis +/multiply/Oslash/Ugrave/Uacute/Ucircumflex/Udieresis/Yacute +/Thorn/germandbls/agrave/aacute/acircumflex/atilde/adieresis +/aring/ae/ccedilla/egrave/eacute/ecircumflex/edieresis/igrave +/iacute/icircumflex/idieresis/eth/ntilde/ograve/oacute/ocircumflex +/otilde/odieresis/divide/oslash/ugrave/uacute/ucircumflex/udieresis +/yacute/thorn/ydieresis +] D +[128/backslash 129/parenleft 130/parenright 141/circumflex 142/tilde +143/perthousand 144/dagger 145/daggerdbl 146/Ydieresis 147/scaron 148/Scaron +149/oe 150/OE 151/guilsinglleft 152/guilsinglright 153/quotesinglbase +154/quotedblbase 155/quotedblleft 156/quotedblright 157/endash 158/emdash +159/trademark] +aload length 2 idiv 1 1 3 -1 roll{pop ISOLatin1Encoding 3 1 roll put}for +/colorimage where{pop}{ + /colorimage { + pop pop /Pr E D {/Cv Pr D /Gr Cv length 3 idiv string D 0 1 Gr length 1 sub + {Gr E dup /i E 3 mul D Cv i get 0.299 mul Cv i 1 add get 0.587 mul add + Cv i 2 add get 0.114 mul add cvi put}for Gr} image} D +}ie +/pdfmark where{pop}{userdict /pdfmark /cleartomark load put}ie +WF{FL{reencodeISO D}forall}{4 1 FL length 1 sub{FL E get reencodeISO D}for}ie +/Symbol dup dup findfont dup length dict begin + {1 index /FID ne{D}{pop pop}ie}forall /Encoding [Encoding aload pop] + dup 128 /therefore put D currentdict end definefont D + +/SF {/CS E D SZ SL CS put FO SL FN put /YI CS LH neg mul D dup ST cvs ( ) join + CS ST cvs join C1 E join ( NF ) join /C1 E D CS NF /Wf WF FN 0 gt or D + /BW Wf{( ) SW pop}{0}ie D}D +/NF {/cS E D /cF E D cF 0 ge{FL cF get}{cF -1 eq{/Symbol}{/MySymbol}ie}ie + findfont cS scalefont setfont} D +/FS {CF or /CF E D FR SL CF put CF CF 0 ge{FN 4 mul add}if E SF} D +/PC {SH /BP f D fin not GL not and{NL}if /HM t D /LL LS D} D +/BS {/TX E D Wf{/fin f D /CW 0 D /LK 0 D /SC 0 D + /RT TX D {RT ( ) search{/NW E D pop /RT E D /WH NW SW pop D CW WH add LL gt + {TX SC LK SC sub 1 sub NN GI GL{SH cF cS OC + 2 copy cS ne E cF ne or{NF}{pop pop}ie}{PC /CW WH BW add D}ie + /SC LK D} + {GL{JC}if + /CW CW WH add BW add D /HM t D}ie /GL f D /Ph f D + /LK LK NW length 1 add add D}{pop exit}ie}loop + /fin t D TX SC LK SC sub GI SH RT () ne{GL not{CC}if}if + /LC TX length D /WH RT SW pop D CW WH add Hy{HC SW pop add}if LL gt + {RT GL{SH cF cS OC 2 copy cS ne E cF ne or{NF}{pop pop}ie + Hy{/Ph t D}if /LL LS D}{NL /LL LS D SH}ie} + {RT PC Hy{CC}if /Ph Ph Hy or D}ie RT () ne{/GL t D /HM t D}if} + {TX SW pop LL le{TX SH}{/NW () D 0 2 TX length 1 sub + {/CW E D TX 0 CW GI dup SW pop LL gt{pop NW SH /HM t D NL/LL W XO sub MR sub D + /CW CW 2 sub NN D /TX TX CW TX length CW sub GI D TX BS exit} + {/NW E D}ie}for}ie}ie /HM t D}D +/CC {C0 length 0 gt{JC}if /C0 [C1 L1 YA YB Mf NS NB TB AF Bw] D + /C1 () D /L0 L1 D /YA 0 D /YB 0 D /Mf 0 D /NS 0 D /NB 0 D}D +/JC {C0 aload length 0 gt{pop pop pop NB add /NB E D NS add /NS E D + dup Mf gt{/Mf E D}{pop}ie dup YB gt{/YB E D}{pop}ie + dup YA gt{/YA E D}{pop}ie pop C1 join /C1 E D /C0 [] D}if}D +/OC {C0 length 0 gt{C1 L1 L0 sub YA YB Mf NS NB TB AF Bw GL C0 aload pop + /Bw E D /AF E D /TB E D /NB E D /NS E D /Mf E D /YB E D /YA E D /C0 [] D + /L1 E D /C1 E D Ph{HC SH}if NL /GL E D /Bw E D /AF E D /TB E D /NB E D /NS E D + /Mf E D /YB E D /YA E D /L1 E D /LL W L1 sub XO sub MR sub WH sub D /CW 0 D + C1 E join /C1 E D}if}D +/BT {/LB t D dup length string copy RS dup dup () ne E ( ) ne and + {/CI 0 D /LS LL D /LL W L1 sub XO sub MR sub D BS} + {dup ( ) eq{/GL f D}if dup () eq L1 0 eq or{pop}{SH /BP f D /Ph f D}ie}ie + /LB f D} D +/BL {CP E pop XO E M} D +/NL {JC /GL f D /SK W XO sub MR sub L1 sub TB{Bw add}if D + /YA LF{Mf HM Fl not and PF or{LH mul}if}{0 /LF t D}ie YA 2 copy lt{E}if pop D + C1 () ne{/FB YB Mf SA{Sf mul}if 4 div 2 copy lt{E}if pop D}if Fl{/Ya YA D}if + CP E pop YA sub YB sub LE neg lt Fl not and PB not and{NP}if NT TL BL + OU PF not and PB or{/RE L1 TB{Bw sub}if + W XO sub MR sub div YA YB add LE BO add div 2 copy lt{E}if pop D + RE 1 gt{BL 1 RE div dup scale}if}if + AT 2 le{SK AT mul 2 div YA neg R}if + AT 3 eq{0 YA neg R TB{/NB NB 1 sub D /NS NS 1 sub D}if /NB NB 1 sub NN D + /A3 NS 6 mul NB add D NS NB add 0 eq + {/A1 0 D /A2 0 D} + {NS 0 eq{/A1 SK NB div dup J gt{pop 0}if D /A2 0 D}{J A3 mul SK lt + {/A1 J D /A2 SK J NB mul sub NS div dup Ab gt{/A1 0 D pop 0}if D} + {/A1 SK A3 div D /A2 A1 6 mul D}ie}ie}ie /A1 A1 NN D /A2 A2 NN D}if + AT 4 eq{0 YA neg R PH 2 le{PD 0 lt{/PD L1 D}if PD M1 gt{/M1 PD D}if + L1 PD sub M2 gt{/M2 L1 PD sub D}if}{DV ID 1 sub get 0 ge{Lo 0 R}if}ie}if + F0 cF ne Cs cS ne or{F0 Cs NF}if + /ms Ms D /Ms f D CP FB sub + C1 cvx exec XO EO sub L1 add TB{BW sub}if dup LM gt{/LM E D}{pop}ie + PH 0 eq PH 4 eq or Ms and{HF not{/PO t D /AH t D}if + BB CP YA add E AT 3 eq LB and{A1 sub}if TB{BW sub}if E BB} + {pop pop}ie Ms HM PH 3 eq and or{/BP f D /Fl f D}if + /Lo 0 D /L1 0 D /F0 cF D /Cs cS D BP not{0 YB NN neg R}if + OU f1 and mF not and{k2 /f1 f D}if + OU PF not and PB or{RE 1 gt{RE dup scale}if}if /Ms ms Ms or D + /C1 AF{(Cp )}{()}ie D /YA 0 D /YB 0 D BL + AT 4 eq LB not and PH 3 ge and + {ID DV length lt{DV ID get dup 0 ge{DO E sub /Lo E D /L1 Lo D}{pop}ie + /ID ID 1 add D}if}if /T t D CD{/LN LN 1 add D PD}if + /PD -1 D /NS 0 D /NB 0 D /TB f D /Ph f D /Mf 0 D /HM f D} D +/RS {/TM E D /CN 0 D TM{10 eq{TM CN ( ) PI}if /CN CN 1 add D}forall + /CN 0 D /BK HM EN and{0}{1}ie D TM + {dup 32 ne{TM CN 3 2 roll put /CN CN 1 add D /BK 0 D} + {pop BK 0 eq{TM CN 32 put /CN CN 1 add D}if /BK 1 D}ie}forall + TM 0 CN GI dup dup () ne E ( ) ne and + {dup CN 1 sub get 32 eq{/EN f D}{/EN t D}ie}if} D +/join {2 copy length E length add string dup 4 2 roll 2 index 0 3 index + PI E length E PI}d +/WR {(\n) search{dup () ne BP not or + {Li 4 le CP E pop YI Li mul add LE add 0 lt and PL 0 eq and{NP}if + SH NL pop /Li Li 1 sub D WR}{pop pop WR}ie}{SH}ie /CI 0 D /BP f D} D +/SH {dup dup () ne E ( ) ne and PF or CS Mf gt and{/Mf CS D}if + T not Wf and{( ) E join /T t D}if dup BP{/MF CS D}if + AT 3 eq{2 copy length dup 0 gt{/NB E NB add D + {( ) search{/NS NS 1 add D pop pop}{pop exit}ie}loop}{pop pop}ie}if + CD PD 0 lt and{dup DC search{SW pop /PD E L1 add D pop pop}{pop}ie}if + 0 Np dup SW pop L1 add /L1 E D dup () ne + {C1 (\() join E join (\)) join AU AF and UF or Wf and{( U ) join}if + sF{( s ) join}if ( S ) join + /C1 E D dup length 1 sub get 32 eq /TB E D /Bw BW D}{pop pop}ie} D +/BG {AI LG BC add add 0 eq} D +/ON {OU{Ty AR AI NN get dup 1 add Ln Ns Ty 2 mod 0 eq{(. )}{(\) )}ie join + dup SW pop neg 0 R CP E 0 lt{0 E M}{pop}ie CP BB show /Ms t D}if} D +/Ln {AR AI 3 -1 roll put}D +/SP {dup CI lt BP not and{dup CI sub 0 E R /CI E D}{pop}ie} D +/BN {PF{WR /HM f D}{BT NL}ie} D +/NN {dup 0 lt{pop 0}if} D +/h {(h) HI ST cvs join cvx exec dup 1 get E Nf{0 get E join}{pop}ie} D +/H {/fn FN D /Hi E 1 add D 1 sub /HL E D /H2 HL 2 add D /GS EZ H2 get D + E Tm H2 get GS mul BE dup 0 gt{1 sub}{pop EG H2 get dup 0 lt{pop AT}if}ie NA + WW Np /SL SL 1 add D /FN EF H2 get D GS Ey H2 get FS + EU H2 get Sc Hs not HL Hl lt and Hs HL hl lt and or Hi 0 eq or + {/HI Hi D /Hs t D /hl HL D /Hv HL D}if HL Hl lt{/hi Hi D}if + Nf HI 0 gt and{(h) Hi ST cvs join cvx exec 0 get WB}if + /HF t D /AH f D /PO f D} D +/EH {Bm H2 get GS mul BE OA /SL SL 1 sub NN D /CF 0 D /FN fn D + SZ SL get FR SL get FS /HF f D /GS Ts D ()Ec} D +/P {E PF{WR}{PO{EP}{BN}ie Ts 4 mul Np AE not{Tm 0 get Ts mul neg SP}if + dup 0 ge AH and{Pi Pd}if}ie 1 sub dup 0 lt{pop AV AL get}if /AT E D /PO t D} D +/EP {PF{WR}{BN Ts 4 mul Np}ie AE not{Bm 0 get Ts mul neg SP}if + /AT AV AL get D /PO f D} D +/BE {E PO{EP}{BN}ie Ts 4 mul Np neg SP} D +/HR {/Aw W EO sub D /RW E dup 0 gt{Aw mul}{neg}ie dup Aw gt{pop Aw}if D /RZ E D + E BN Ts neg SP 1 sub 2 div Aw RW sub mul EO add CP E pop M PF{0 Ps neg R}if + 0 Np OU{gsave RZ LW Cf{Hc VC}{0 Sg}ie CP BB RW 0 RL CP BB stroke grestore}if + /CI 0 D /BP f D PF not{Ts neg SP}if /Ms t D} D +/AD {I NL EG 14 get dup 0 lt{pop AT}if NA /AE t D Tm 14 get Ts mul neg SP + Cf{EU 14 get dup -1 eq{pop CA CL get}if Sc}if} D +/DA {BN ()ES OA /AE f D ()Ec Bm 14 get Ts mul neg SP} D +/PR {/MW E D /Li E D Tm 1 get Ps mul BE 0 NA /FN Fp D /PF t D SI /SL SL 1 add D + /CF 0 D Ps CS mul Ts div MW WC mul CS mul Ts div dup LL gt PL 0 eq and + {LL div div}{pop}ie Ey 1 get FS CP E pop LE add YI neg div cvi dup Li lt + AH and{4 lt YI Li mul 5 mul LE add 0 gt or PL 0 eq and{NP}if}{pop}ie + EU 1 get Sc /GS Ps D}D +/RP {WR NL () /PF f D SI /FN 0 D ES Bm 1 get Ps mul neg SP OA /GS Ts D} D +/SI {/XO Lm 15 get BC NN mul Lm 16 get AI UI sub NN mul add + Lm 17 get UI NN mul add Lm 20 get LG NN mul add Ts mul + PF{Lm 1 get Ps mul add}if EO add D + /MR Rm 15 get BC NN mul Rm 16 get AI UI sub NN mul add + Rm 17 get UI NN mul add Rm 20 get LG NN mul add Ts mul + PF{Rm 1 get Ps mul add}if D /LL W XO sub MR sub D} D +/DT {/cC E D BN /LG LG 1 sub D SI /LG LG 1 add D WW 2 div Np BL} D +/DD {WB Cc 0 eq cC 0 eq and L1 0 eq or Lm 20 get Ts mul L1 sub TB{BW add}if + Ts 2 div lt or NL /LF E D SI BL /cC 0 D} D +/DL {Dc LG Cc put /Cc E D BG{Tm 18 get Ts mul BE}{BN}ie /LG LG 1 add D BL} D +/LD {BN LG 0 gt{/LG LG 1 sub D}if /Cc Dc LG get D SI + BG{()Bm 18 get Ts mul BE}if BL} D +/UL {BG{Tm 17 get Ts mul BE}{BN}ie NR AI NN 0 put /UI UI 1 add D + /AI AI 1 add D SI BL} D +/LU {BN /UI UI 1 sub D /AI AI 1 sub D SI BG{()Bm 17 get Ts mul BE}if BL} D +/OL {E BG{Tm 16 get Ts mul BE}{BN}ie TR AI NN Ty put /Ty E D NR AI NN 1 put + /AI AI 1 add D SI BL 1 Ln} D +/LO {BN /AI AI 1 sub D /Ty TR AI get D SI BG{()Bm 16 get Ts mul BE}if BL} D +/LI {E BN -1 SP /BP f D /CI 0 D 0 Np NR AI 1 sub NN get 1 eq + {dup dup 0 gt E 4 le and{/Ty E D}{pop}ie + /L1 L1 Ty AR AI NN get Ns SW pop XO sub dup 0 lt{pop 0}if add D ( ON )} + {pop ( B )}ie C1 E join /C1 E D CS Mf gt{/Mf CS D}if BL} D +/BQ {Tm 15 get Ts mul BE /BC BC 1 add D SI BL} D +/QB {Bm 15 get Ts mul BE /BC BC 1 sub D SI BL} D +/Al {E EP 1 sub dup 0 lt{pop AV AL get}if NA} D +/Ea {EP OA} D +/WB {PF{WR}{BT}ie} D +/F1 {WB /FN 0 D CS 0 FS} D +/F2 {WB /FN WI D CS 0 FS} D +/HY {/Hy t D WB /Hy f D} D +/YH {WB} D +/A {/LT E D LT 1 eq{/RN E D}if /Lh E D WB /C1 C1 ( Cp ) join D + Lc AF not and{Cl Sc}if /AF t D} D +/EA {Lc AF and{Ec}{WB}ie TL Pa AF and Lh 0 ne and + {( \() Lh join (\)) join /AF f D WB}if /AF f D} D +/TL {C1 ( Tl ) apa /C1 E D} d +/apa {AF OU and Lh 0 ne LT 1 eq or and{LT 1 eq{RN ( /) E ST cvs join} + {(\() Lh join (\)) join}ie E join join}{pop}ie} d +/Cp {/Xc CP /Yc E D D} D +/SS {Cf{dup 0 ge{EU E get dup -1 eq{pop CA CL get}if}{pop CA CL get}ie Sc} + {pop}ie SZ SL get /SL SL 1 add D} D +/I {WB 8 SS 1 FS} D +/EM {WB 8 SS /CF CF 1 xor D 0 FS} D +/BD {WB 9 SS 2 FS} D +/TT {WB 10 SS /FN Fp D 0 FS} D +/KB {WB 11 SS /FN Fp D 2 FS} D +/CT {WB 12 SS 1 FS} D +/SM {WB 13 SS /FN Fp D 0 FS} D +/Q {/QL QL 1 add D QO QL 2 mod get La get join WB} D +/EQ {QC QL 2 mod get La get join WB /QL QL 1 sub D} D +/RO {WB -1 SS /CF 0 D 0 FS} D +/SY {WB -1 SS -1 FS} D +/MY {WB -1 SS -2 FS} D +/ES {WB /SL SL 1 sub NN D /CF 0 D /FN FO SL get D SZ SL get FR SL get FS ()Ec}D +/FZ {3 sub 1.2 E exp GS mul E WB TL /C1 C1 ( Cp ) join D /SL SL 1 add D 0 FS} D +/Ef {WB TL ()ES /C1 C1 ( Cp ) join D} D +/BZ {dup /Bf E D FZ}D +/Sc {dup -1 ne Cf and{/CL CL 1 add D dup 0 eq{pop [0 0 0]}if + dup CA E CL E put VS ( VC ) join C1 E join /C1 E D}{pop}ie} D +/Ec {WB Cf{/CL CL 1 sub NN D CA CL get VS ( VC ) join C1 E join /C1 E D}if} D +/VS {dup type /arraytype eq{([) E {ST cvs join ( ) join}forall (]) join}if} D +/VC {{255 div}forall setrgbcolor} D +/Sl {dup type /integertype ne{Ds}if /La E D WB}d +/UN {WB /UF t D} D +/NU {WB /UF f D} D +/SE {WB /sF t D} D +/XE {WB /sF f D} D +/sM {/C1 C1 ( k1 ) join D}d +/eM {/C1 C1 ( k2 ) join D}d +/k1 {/YC CP E pop Ts add D /mF t D /f1 t D}d +/k2 {gsave 3 LW -9 CP E pop Ts 0.2 mul sub M -9 YC L stroke grestore /mF f D}d +/Ac {/AC E D WB}d +/Ca {eA{( \()join AC join(\) )join}if WB}d +/s {OU{gsave 0 CS .25 mul R dup SW pop CJ 0 RL stroke grestore}if}D +/CJ {AT 3 eq LB and{E dup dup length 1 sub A1 mul E + {( ) search{pop pop E A2 add E}{pop exit}ie}loop 3 -1 roll add + W CP pop sub 2 copy gt{E}if pop}if}D +/So {/Co E D} D +/SO {C1 Yo ST cvs join ( So ) join /C1 E D (j) SW pop 2 div Pd} D +/Se {E WB CS E div Pd}D +/Pd {dup type /stringtype eq{SW pop}if dup /L1 E L1 add D + ST cvs ( 0 R ) join C1 E join /C1 E D} D +/Sp {0.35 CO} D +/Sb {-0.2 CO} D +/CO {OV Io Yo put /Yo E CS mul Yo add D /Io Io 1 add D -1.5 Io mul 3 add FZ SO + CS Yo add dup YA gt{/YA E D}{pop}ie + Yo neg dup YB gt{/YB E D}{pop}ie} D +/Es {ES /Io Io 1 sub NN D /Yo OV Io get D SO} D +/SB {/N2 0 D 0 1 NI{/N E D{IX N2 get 0 lt{/N2 N2 1 add D}{exit}ie}loop + /K WS N get FC N get mul D /NY AY N2 get D /BV NY array D + 0 1 NY 1 sub{/TM K string D currentfile TM readhexstring pop pop BV E TM put} + for BM N BV put /N2 N2 1 add D}for} D +/IC [{/MA E D /MB 0 D}{2 div /MA E D /MB MA D}{/MB E CS sub D /MA CS D} + {pop /MA YS AB mul D /MB 1 AB sub YS mul D}{pop /MA 0 D /MB 0 D}] D +/IP {BV N get /N N 1 add D} D +/II {/K E D IX K get 0 lt{/EC E D}if /TY E D + TY 4 eq{/Y E D /X E D}if TY 3 eq{/AB E D}if + /XW AX K get D /YW AY K get D /IS SG IT K get get D /XS XW IS mul D + /YS YW IS mul D YS IC TY get exec /MA MA Fl not{3 add}if D} D +/IM {II /ty TY D /xs XS D /ys YS D /ya YA D /yb YB D /ma MA D /mb MB D /k K D + /ec EC D /BP f D /CI 0 D WB TL L1 xs add dup XO add MR add W gt + {pop /ma ma Fl{3 add}if D NL /YA ma D /YB mb D /YS ys D /L1 xs D} + {/L1 E D ma YA gt{/YA ma D}if mb YB gt{/YB mb D}if}ie /TB f D + OU{CP E pop YS sub LE neg lt Fl not and PB not and{NP /YA ma D /YB mb D}if + /BP f D ty ST cvs ( ) join IX k get 0 lt{(\() join ec join (\) ) join}if + k ST cvs join ty 3 eq{AB ST cvs ( ) join E join}if + ty 4 eq{X ST cvs ( ) join Y ST cvs join ( ) join E join}if C1 E join + ( DI ) join FP 2 eq FP 1 eq AF and or{( FM ) join}if + ( Il Cp ) apa /C1 E D /EN f D}if /HM t D /T f D} D +/DI {II /Xc CP /Yc E D D /YN YW neg D /HM t D /CI 0 D /K2 IX K get D gsave + TY 4 eq{OX X IS mul add OY FY add YS sub Y IS mul sub} + {/FY YS D CP MB sub 2 copy /OY E D /OX E D}ie + translate K2 0 ge{/DP AZ K2 get D /BV BM K2 get D XS YS scale /N 0 D XW YW DP + [XW 0 0 YN 0 YW] {IP} FC K2 get 1 eq{image}{f 3 colorimage}ie} + {EX}ie grestore XS 0 R /Ms t D} D +/FM {gsave 0 Sg CP MB sub translate XS neg 0 M 0 YS RL XS 0 RL 0 YS neg RL + XS neg 0 RL stroke grestore} D +/NA {/AT E D /AL AL 1 add D AV AL AT put} D +/OA {AL 0 gt{/AL AL 1 sub D /AT AV AL get D}if} D +/D1 {/BR {CP E pop E BN Mb{CP E pop eq{0 YI R}if}{pop}ie} D + /Sn {OU{C1 E ST cvs join ( Ld ) join /C1 E D}{pop}ie} D} D +/D1 {/BR {BN} D /Sn {OU {C1 E ST cvs join ( Ld ) join /C1 E D} {pop} ie} D} D +/TC {/TF t D /ML 0 D HN{SW pop dup ML gt{/ML E D}{pop}ie}forall NP /RM RM not D + RC /OU Tc D Ep /PN 0 D Ms not TP and{Ip}if /W IW ML sub Ts sub D + /A0 0 D TH{/BR {( ) join BT} D /Sn {pop} D /Au () D}if} D +/TN {0 eq{E EA PF HF or not XR and{HN E get Xr}{pop}ie} + {OU{Tn 0 ge{() BN}if /Tn E D}{pop}ie WB}ie} D +/NT {OU LB not and Tn 0 ge and{PL 0 eq{Ms not{CS CF FS}if CP dup + /y E YA sub D W 9 sub CS -1.8 mul XO L1 add 2 add{y M (.) show}for + HN Tn get dup SW pop IW E sub y M show CP BB M}if /Tn -1 D}if} D +/Ld {/DN E D HN DN Pn put [/View [/XYZ -4 Fl{PS}{CP YA add US E pop}ie null] + /Dest DN ST cvs cvn /DEST pdfmark} D +/C {ND 1 eq{1 sub}if TI mul /XO E D NL Nf not{pop()}if 0 3 -1 roll 1 A} D +/OP {BP not{NP}if PN 2 mod 0 eq{/Ms t D NP}if}D +/Ep {Xp PN 2 mod 0 eq and OU and{/Pn (-) D showpage /PM 1 D LA}if}D +/Dg [73 86 88 76 67 68 77] D +/Rd [0 [1 1 0][2 1 0][3 1 0][2 1 1][1 1 1][2 2 1][3 3 1][4 4 1][2 1 2]] D +/Ns {/m E D /c E 32 mul D /j m 1000 idiv D /p j 12 add string D + c 96 le m 0 gt and{c 32 le {/i 0 D /d 77 D /l 100 D /m m j 1000 mul sub D + j -1 1 {pop p i d c add put /i i 1 add D}for + 4 -2 0 {/j E D /n m l idiv D /m m n l mul sub D /d Dg j get D + n 0 gt {/x Rd n get D x 0 get -1 1 {pop p i d c add put /i i 1 add D}for + p i x 1 get sub Dg x 2 get j add get c add put}if /l l 10 idiv D + }for p 0 i GI} + {/i ST length 1 sub D m {1 sub dup 0 ge{dup 26 mod c add 1 add + ST i 3 -1 roll put 26 idiv dup 0 eq{pop exit}if}if /i i 1 sub D}loop + ST i ST length i sub GI}ie} + {m p cvs}ie} D +/US {matrix currentmatrix matrix defaultmatrix matrix invertmatrix + matrix concatmatrix transform} D +/GB {Gb{US}if}D +/Tl {/Rn E D Xc CP pop ne{ + [/Rect [Xc 1 sub Yc cS 0.25 mul sub GB CP E 1 add E cS 0.85 mul add GB] + /Subtype /Link /Border [0 0 Cf Lc and LX and AU or{0}{1}ie] Rn type + /nametype eq {/Dest Rn}{/Action [/Subtype /URI /URI Rn] Cd}ie + /ANN pdfmark}if} D +/Il {/Rn E D [/Rect [Xc Yc GB Xc XS add Yc YS add GB] /Subtype /Link + /Border [0 0 0] Rn type /nametype eq{/Dest Rn} + {/Action [/Subtype /URI /URI Rn] Cd}ie /ANN pdfmark} D +/XP {[{/Z Bz 2 div D Z 0 R Z Z RL Z neg Z RL Z neg Z neg RL Z Z neg RL + Fi cH 1 eq and{fill}if} {Bz 0 RL 0 Bz RL Bz neg 0 RL 0 Bz neg RL + Fi cH 1 eq and{fill}if} {0 -5 R Bz 0 RL 0 21 RL Bz neg 0 RL 0 -21 RL}]} D +/MS {/Sm E D WB}D +/O {BN()0 Sm BX} D +/BX {/Bt E D Bt 2 lt{/Ch E D CS 0.8 mul}{11 mul}ie W XO sub MR sub + 2 copy gt{E}if pop /HZ E D Bt 2 eq{Fi not{pop()}if ( )E join /Ft E D TT + /PF t D /MW 1 D /Li 1 D /Fw Ft SW pop D Fw HZ gt{/HZ Fw 8 add D}if + HZ ST cvs( )join}{WB Ch ST cvs( )join}ie L1 HZ add XO add MR add W gt{NL}if + Bt 2 eq{Ft ES Fw neg HM{CS sub}if Pd}if Bt ST cvs join( Bx )join + Bt 2 eq HM and{CS Pd}if C1 E join /C1 E D /L1 L1 HZ add D /T f D + ( ) Pd /PF f D Bt 2 lt{YA CS .8 mul lt{/YA CS .8 mul D}if} + {YB 5 lt{/YB 5 D}if YA 21 lt{/YA 21 D}if}ie /CI 0 D} D +/Bx {dup 2 eq{E /Bz E D}{E /cH E D /Bz CS .8 mul D}ie + OU {gsave 0 Sg XP E get exec stroke grestore}{pop}ie Bz 0 R /Ms t D}D +/SD {FD 4 mul Dy add DZ NF newpath 0 0 M DX t charpath pathbbox + 3 -1 roll sub /DY E D E dup /X1 E D sub WM mul WX DY mul add WM DG mul E div + /DF E D /DR WX DF mul DY mul WM div 2 div D} d +/Sd {gsave 0 IL Di mul neg translate IL IW atan Di 0 eq{neg}if rotate + FD 4 mul Dy add DZ NF DR X1 sub DY 2 div neg M cD VC DX show grestore} d +/Pt {/tp t D Tp{NP /Pn (TP) D 0 Tt neg R Th BN NP Ep ET RC ZF}if /tp f D} D +/RC {/AI 0 D /LG 0 D /BC 0 D /UI 0 D /PF f D /Cc 0 D /cC 0 D /Dc 10 array D + /NR [0 1 9{pop 0}for] D /La Ds D /AR 10 array D /TR 10 array D /AV 30 array D + SI /AL -1 D /AT A0 D AT NA /OV 9 array D /Yo 0 D /Co 0 D /Io 0 D /Hy f D + /Ph f D /CL -1 D Ct Sc}D +/ZF {/FR [0 1 30{pop 0}for] D /SZ [0 1 30{pop 0}for] D /FO [0 1 30{pop 0}for] D + /SL 0 D /CF 0 D /FN 0 D 0 Ts SF}D +/QO [[(\234)(\233)(\253\240)(\232)(\273)(\253)][(')(`)(\253\240)(\231)(\273)(\253)]] D +/QC [[(\234)(\234)(\240\273)(\233)(\253)(\273)][(')(')(\240\273)(`)(\253)(\273)]] D +/Hf EF length 2 sub D +/Hz EZ Hf get D +/HS Ey Hf get D +/Fz EZ Hf 1 add get D +/Fs Ey Hf 1 add get D +/LE IL D +/Ps EZ 1 get D +/Fp EF 1 get D +/XO 0 D +/YI 0 D +/CI 0 D +/FP 0 D +/WW Ts 7 mul D +/Mf 0 D +/YA 0 D +/YB 0 D +/Cs Ts D +/GS Ts D +/F0 0 D +/NS 0 D +/NB 0 D +/N 0 D +/C0 [] D +/C1 () D +/Lo 0 D +/L1 0 D +/LM 0 D +/PH 0 D +/EC 0 D +/Lh 0 D +/LT 0 D +/CH 1 string D +/ST 16 string D +/CA 9 array D +/HC (\255) D +/HM f D +/PF f D +/EN f D +/TB f D +/UF f D +/sF f D +/AE f D +/AF f D +/BP t D +/CD f D +/PA t D +/GL f D +/T t D +/HF f D +/AH f D +/SA f D +/PB f D +/f1 f D +/mF f D +/OX 0 D +/OY 0 D +/FY 0 D +/EO 0 D +/FB 0 D +/PL 0 D +/Bw 0 D +/PD -1 D +/TP f D +/tp f D +/TH t D +/Ty 4 D +/Tn -1 D +/Fl t D +/LB t D +/PM 1 D +/Ms f D +/Ba f D +/Bb f D +/Hl 3 D +/hl 6 D +/Hv 6 D +/Hs f D +/HI 0 D +/hi 0 D +/PO t D +/TE f D +/LF t D +/BO 0 D +/Sm 1 D +/Bf 3 D +/A1 0 D +/A2 0 D +/Ds 1 D +/QL -1 D +/Cb Db D +/Ct Dt D +/Cl Dl D +[/Creator (html2ps version 1.0 beta7) /Author () /Keywords (xsd, xml, schema, c++, mapping, data, binding, parsing, serialization, validation) /Subject () + /Title (C++/Tree Mapping Getting Started Guide) /DOCINFO pdfmark +/ND 1 D +/HN [(1) (1) (1) (1) (1) (1) (1) (1) (2) (3) (3) (5) (7) (7) (8) (11) (13) (15) +(16) (16) (16) (17) (17) (18) (20) (23) (24) (26) (29) (??) (32) (33) (35) +(36) (37) (38) (1) (1) (1) (1) (1) (2) (3) (3) (5) (7) (7) (8) (11) (13) +(15) (16) (16) (16) (17) (17) (18) (20) (23) (24) (26) (29) (32) (33) (35) +(36) (37) (38)] D +/h0 [()(Table of Contents)] D +/h1 [(1\240\240)(Preface)] D +/h2 [(1.1\240\240)(About This Document)] D +/h3 [(1.2\240\240)(More Information)] D +/h4 [(2\240\240)(1 Introduction)] D +/h5 [(2.1\240\240)(1.1 Mapping Overview)] D +/h6 [(2.2\240\240)(1.2 Benefits)] D +/h7 [(3\240\240)(2 Hello World Example)] D +/h8 [(3.1\240\240)(2.1 Writing XML Document and Schema)] D +/h9 [(3.2\240\240)(2.2 Translating Schema to C++)] D +/h10 [(3.3\240\240)(2.3 Implementing Application Logic)] D +/h11 [(3.4\240\240)(2.4 Compiling and Running)] D +/h12 [(3.5\240\240)(2.5 Adding Serialization)] D +/h13 [(3.6\240\240)(2.6 Selecting Naming Convention)] D +/h14 [(3.7\240\240)(2.7 Generating Documentation)] D +/h15 [(4\240\240)(3 Overall Mapping Configuration)] D +/h16 [(4.1\240\240)(3.1 C++ Standard)] D +/h17 [(4.2\240\240)(3.2 Character Type and Encoding)] D +/h18 [(4.3\240\240)(3.3 Support for Polymorphism)] D +/h19 [(4.4\240\240)(3.4 Namespace Mapping)] D +/h20 [(4.5\240\240)(3.5 Thread Safety)] D +/h21 [(5\240\240)(4 Working with Object Models)] D +/h22 [(5.1\240\240)(4.1 Attribute and Element Cardinalities)] D +/h23 [(5.2\240\240)(4.2 Accessing the Object Model)] D +/h24 [(5.3\240\240)(4.3 Modifying the Object Model)] D +/h25 [(5.4\240\240)(4.4 Creating the Object Model from Scratch)] D +/h26 [(5.5\240\240)(4.5 Mapping for the Built-in XML Schema Types)] D +/h27 [(6\240\240)(5 Parsing)] D +/h28 [(6.1\240\240)(5.1 XML Schema Validation and Searching)] D +/h29 [(6.2\240\240)(5.2 Error Handling)] D +/h30 [(7\240\240)(6 Serialization)] D +/h31 [(7.1\240\240)(6.1 Namespace and Schema Information)] D +/h32 [(7.2\240\240)(6.2 Error Handling)] D +/Hr [36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 +58 59 60 61 62 63 64 65 66 67]D +/HV [1 2 2 1 2 2 1 2 2 2 2 2 2 2 1 2 2 2 2 2 1 2 2 2 2 2 1 2 2 1 2 2]D +/Cn [2 0 0 2 0 0 7 0 0 0 0 0 0 0 5 0 0 0 0 0 5 0 0 0 0 0 2 0 0 2 0 0]D +Hr length 0 gt{[/PageMode /UseOutlines /DOCVIEW pdfmark}if +/Hn 1 D +0 1 Hr length 1 sub{ + /Bn E D [Cn Bn get dup 0 gt{/Count E HV Bn get Bl ge{neg}if}{pop}ie + /Dest Hr Bn get dup abs ST cvs cvn E 0 ge{(h)Hn ST cvs join cvx exec + dup 1 get E Nf{0 get E join}{pop}ie /Hn Hn 1 add D}{()}ie + /Title E dup length 255 gt{0 255 getinterval}if /OUT pdfmark}for +ZF /FN Fp D Ps 0 FS /WC Wf{( )}{<A1A1>}ie SW pop D +ET RC ZF +/Df f D +/R0 (http://www.codesynthesis.com/licenses/fdl-1.2.txt) D +/R1 (http://www.codesynthesis.com/projects/xsd/documentation/cxx/tree/guide/index.xhtml) D +/R2 (http://www.codesynthesis.com/projects/xsd/documentation/cxx/tree/guide/cxx-parser-guide.pdf) D +/R3 (http://www.codesynthesis.com/projects/xsd/documentation/cxx/tree/guide/cxx-parser-guide.ps) D +/R1 (http://www.codesynthesis.com/projects/xsd/documentation/cxx/tree/manual/) D +/R2 (http://wiki.codesynthesis.com/Tree/Customization_guide) D +/R3 (http://wiki.codesynthesis.com/Tree/FAQ) D +/R4 (http://www.codesynthesis.com/projects/xsd/documentation/xsd.xhtml) D +/R5 (http://www.codesynthesis.com/mailman/listinfo/xsd-users) D +/R6 (http://www.codesynthesis.com/pipermail/xsd-users/) D +/R7 (http://www.w3.org/TR/xmlschema-0/) D +/R8 (http://www.doxygen.org/) D +/R9 (http://www.codesynthesis.com/projects/xsd/documentation/cxx/tree/hello/html/annotated.html) D +/R10 (http://www.codesynthesis.com/projects/xsd/documentation/cxx/tree/manual/#2.11) D +/R11 (http://www.codesynthesis.com/projects/xsd/documentation/cxx/tree/manual/#2.8.4) D +/R12 (http://www.codesynthesis.com/projects/xsd/documentation/cxx/tree/manual/#2.8) D +/R13 (http://www.codesynthesis.com/projects/xsd/documentation/cxx/tree/manual/#2.5) D +/R14 (http://www.codesynthesis.com/projects/xsd/documentation/cxx/tree/manual/#2.9) D +/R15 (http://www.codesynthesis.com/projects/xsd/documentation/cxx/tree/manual/#3) D +/R16 (http://www.codesynthesis.com/projects/xsd/documentation/cxx/tree/manual/#3.3) D +/R17 (http://www.codesynthesis.com/projects/xsd/documentation/cxx/tree/manual/#4) D +/R18 (http://www.codesynthesis.com/projects/xsd/documentation/cxx/tree/manual/#4.4) D +/TS { + tables E get /table E D + table aload pop /rdesc E D /cdesc E D /tdesc E D + tdesc aload pop /capalg E D /caption E D /rules E D /frame E D /nfoot E D + /nhead E D /ncol E D /nrow E D /border E D /twid E D /units E D /talign E D + /flow E D /clear E D /tclass E D pop pop + /w W D /eps 0.1 D /OU f D /PL 1 D + /FN EF 21 get D EZ 21 get Ey 21 get FS + 0 1 1{ + /pass E D + 0 1 nrow{ + /irow E D + /cells rdesc irow get 6 get D + 0 1 ncol{ + /icol E D + /cell cells icol get D + cell 0 ne{ + cell aload pop /ang E D /CB E D pop pop pop + /DV E D /bot E D /top E D /right E D /left E D /nowrap E D /valign E D + /dp E D /align E D /rspan E D /cspan E D /cclass E D /ctype E D /cmax E D + /cmin E D /proc E D + rspan 0 eq{/rspan nrow irow sub 1 add D}if + cspan 0 eq{/cspan ncol icol sub 1 add D}if + pass 0 eq cspan 1 eq and pass 1 eq cspan 1 gt and or{ + /W 1e5 D /LL W D /PH 1 D + ctype 1 eq{() BD}if + RC align NA + AT 4 eq{/CD t D /DC dp D /LN 0 D /M1 0 D /M2 0 D}{/CD f D}ie + 0 0 M /LM 0 D proc exec BN + AT 4 eq{ + LN array astore cell 15 3 -1 roll put + cdesc icol get dup dup 5 get M1 lt{5 M1 put}{5 get /M1 E D}ie + dup 6 get M2 lt{6 M2 put}{6 get /M2 E D}ie + /LM M1 M2 add D + }if + /CD f D + ang 0 ne{/LM CP E pop neg D}if + /thiswid LM left add right add eps add D + /oldmin 0 D /oldmax 0 D + 0 1 cspan 1 sub{ + icol add cdesc E get dup 2 get /oldmax E oldmax add D + 1 get /oldmin E oldmin add D + }for + thiswid oldmax ge{ + 0 1 cspan 1 sub{ + icol add cdesc E get dup 2 E 2 get oldmax 0 eq + {pop thiswid cspan div}{thiswid mul oldmax div}ie + put + }for + }if + nowrap 1 eq{ + thiswid oldmin ge{ + 0 1 cspan 1 sub{ + icol add cdesc E get dup 1 E 1 get oldmin 0 eq + {pop thiswid cspan div}{thiswid mul oldmin div}ie + put + }for + }if + }{ + /W 0 D /LL W D /PH 2 D + ctype 1 eq{() ES () BD}if + 0 0 M /LM 0 D RC proc exec BN + /thiswid LM left add right add eps add D + thiswid oldmin ge{ + 0 1 cspan 1 sub{ + icol add cdesc E get dup 1 E 1 get oldmin 0 eq + {pop thiswid cspan div}{thiswid mul oldmin div}ie + put + }for + }if + }ie + ctype 1 eq{() ES}if + }if + }if + }for + }for + }for + /tmin 0 D /tmax 0 D + 0 1 ncol{ + cdesc E get dup 1 get E 2 get 2 copy gt{pop dup}if + tmax add /tmax E D tmin add /tmin E D + }for + twid 0 lt{twid neg IW gt{IW neg}{twid}ie /twid E D}if + tdesc 0 twid neg tmin 2 copy lt{E}if pop put + tdesc 1 twid neg tmax 2 copy lt{E}if pop put + /W w D /LL W D /OU t D /PH 0 D /PL 0 D +} D +/PT { + /PL PL 1 add D + tables E get /table E D Tm 21 get Ts mul BE + PL 2 ge{save}if + /SL SL 1 add D /FN EF 21 get D EZ 21 get Ey 21 get FS + table aload pop /rdesc E D /cdesc E D /tdesc E D + tdesc aload pop /capalg E D /caption E D /rules E D /frame E D /nfoot E D + /nhead E D /ncol E D /nrow E D /border E D /twid E D /units E D /talign E D + /flow E D /clear E D /tclass E D /tmax E D /tmin E D + /w W D /xo XO D /mr MR D /ll LL D /lg LG D /ai AI D /bc BC D /nr NR D /ar AR D + /tr TR D /ui UI D /ph PH D /a0 A0 D /pf PF D /at AT D /av AV D /al AL D + /Le LE D /la La D + talign 0 lt{/talign AL 0 gt{AV AL get}{A0 2 le{A0}{0}ie}ie D}if + ph 1 eq ph 2 eq or{ + NL ph 1 eq{tmax}{tmin}ie dup XO add LM gt{/LM E XO add D}{pop}ie LM E + }{ + /PH 3 D /LE 1e5 D RC %ZF + border 0 gt{/border 1 D}if + /twidth 0 D /avail W xo sub D + twid 0 eq{0 1 ncol{cdesc E get dup 2 get E 3 get dup 0 gt{div neg dup twid lt + {/twid E D}{pop}ie}{pop pop}ie}for}if + /twid twid dup 0 lt{neg avail 2 copy gt{E}if pop}{avail mul}ie D + /OK t D 0 1 ncol{cdesc E get dup 1 get E 3 get twid mul gt{/OK f D}if}for + 0 1 ncol{ + cdesc E get dup 1 get /colmin E D dup 3 get /cwid E twid mul D dup + tmax avail le{2 get}if + tmin avail le tmax avail gt and{ + dup 2 get E 1 get dup 3 1 roll sub avail tmin sub mul tmax tmin sub div add + }if + tmin avail gt{1 get}if + 0 E colmin cwid lt OK and{pop cwid}if dup /twidth E twidth add D put + }for + /OU f D CP + tmin twid le{ + 0 1 ncol{cdesc E get dup 0 get twidth div twid mul 0 E put}for + /twidth twid D + }if + CP printcap CP E pop sub /caphig E D pop + 0 1 1{ + /pass E D + 0 1 nrow{ + /irow E D + /cells rdesc irow get 6 get D + 0 1 ncol{ + /icol E D + /cell cells icol get D + cell 0 ne{ + cell aload pop /ang E D /CB E D pop pop pop + /DV E D /bot E D /top E D /right E D /left E D /nowrap E D /valign E D + /dp E D /align E D /rspan E D /cspan E D /cclass E D /ctype E D /cmax E D + /cmin E D /proc E D + rspan 0 eq{/rspan nrow irow sub 1 add D}if + cspan 0 eq{/cspan ncol icol sub 1 add D}if + /W 0 D + 0 1 cspan 1 sub{icol add cdesc E get 0 get /W E W add D}for + pass 0 eq rspan 1 eq and pass 1 eq rspan 1 gt and or{ + ctype 1 eq{() BD}if + /W W left sub right sub D /XO 0 D /EO 0 D SI + /A0 align D RC align NA + AT 4 eq{ + /DC dp D /DO 0 D /ID 1 D + 0 1 DV length 1 sub{DV E get dup DO gt{/DO E D}{pop}ie}for + /Lo DO DV 0 get sub D /L1 Lo D + }if + 0 0 M /BP t D /Fl t D /MF 0 D /FB 0 D + proc exec T not{/CI 0 D}if BN 0 FB neg R MF 0 eq{/MF CS D}if + CP /thishig E neg bot add top add CI add D pop + ang 0 ne{/thishig LM bot add top add D}if + cell 16 MF put cell 17 Ya put cell 18 thishig put + valign 4 eq{ + /below thishig Ya sub D + rdesc irow get dup dup 4 get Ya lt + {4 Ya put}{4 get /Ya E D}ie + dup 5 get below lt{5 below put}{5 get /below E D}ie + /thishig Ya below add D + }if + ctype 1 eq{()ES}if + /oldhig 0 D + 0 1 rspan 1 sub{ + irow add rdesc E get 0 get /oldhig E oldhig add D + }for + thishig oldhig ge{ + 0 1 rspan 1 sub{ + irow add rdesc E get dup 0 E 0 get oldhig 0 eq + {pop thishig rspan div}{thishig mul oldhig div}ie + put + }for + }if + }if + }if + }for + }for + }for M RC %ZF + /thight 0 D /racc 0 D /maxh 0 D /brk 0 D /rbeg nhead nfoot add D + 0 1 nrow{ + rdesc E get dup 0 get dup /thight E thight add D + brk 0 eq{/racc E D}{/racc E racc add D}ie + racc maxh gt{/maxh racc D}if 2 get /brk E D + }for + ph 3 ge{thight caphig add E}if + ph 0 eq ph 4 eq or{ + /PH 4 D /LE Le D /OU Ou D /yoff 0 D /headsz 0 D + 0 1 nhead 1 sub{rdesc E get 0 get headsz add /headsz E D}for + /footsz 0 D + 0 1 nfoot 1 sub{rdesc E nhead add get 0 get footsz add /footsz E D}for + /ahig LE BO add MI add D /maxh maxh headsz add footsz add D + /thight thight headsz add footsz add D + tmin avail gt maxh ahig gt or + {/Sf avail tmin div dup ahig maxh div gt{pop ahig maxh div}if D /SA t D} + {/Sf 1 D}ie + tclass 1 eq thight LE 15 sub gt and + {/SA t D LE 15 sub thight div dup Sf lt{/Sf E D}{pop}ie}if + SA{Sf Sf scale /ll ll Sf div D /xo xo Sf div D /LE LE Sf div D + /mr mr Sf div D /BO BO Sf div D /ahig ahig Sf div D}if + nhead nfoot add getwid + LE CP E pop add capalg 0 eq{caphig sub}if + bT{f}{dup thight lt thight ahig lt and}ie + E headsz sub footsz sub rwid lt or{NP}if + capalg 0 eq{printcap -8 SP}if + CP /ycur E D pop + printhead + rbeg 1 nrow{/row E D row + getwid + ycur yoff add rwid sub footsz sub LE add 0 lt + {nfoot 0 gt{printfoot}if Tf NP /rbeg irow1 D + Ba{MI /MI MI SA{Sf div}if D MI SP /MI E D}if + CP /ycur E D pop /yoff 0 D printhead}if + irow1 printrow + }for + printfoot /row row 1 add D Tf + 0 ycur yoff add M + capalg 1 eq{/EO 0 D SI -3 SP printcap}if + Sf 1 lt{1 Sf div dup scale /ll ll Sf mul D /xo xo Sf mul D /LE LE Sf mul D + /mr mr Sf mul D /BO BO Sf mul D /SA f D}if + /EO 0 D + }if + }ie + /W w D /XO xo D /MR mr D /LL ll D /LG lg D /AI ai D /BC bc D /NR nr D /AR ar D + /TR tr D /UI ui D /PH ph D /A0 a0 D /PF pf D /AT at D /AV av D /AL al D + /La la D + /SL SL 1 sub NN D /CF 0 D /FN 0 D SZ SL get FR SL get FS Wf not{()F2}if + PL 2 ge{Ms E restore Ms or /Ms E D PH 1 eq PH 2 eq or + {/LM E D}if PH 3 ge{/CI 0 D NL 0 E neg R}if + }if + /PL PL 1 sub D /CI 0 D /BP f D /PO f D () Bm 21 get Ts mul BE BL %CF CS SF +} D +/printcap{ + capalg 0 ge{ + SA{/W w Sf div D} + {talign 1 eq{/XO xo ll twidth sub 2 div add D}if + talign 2 eq{/XO xo ll twidth sub add D}if + /W XO twidth add D + }ie /XO xo D /LL W XO sub MR sub D + /PA f D /Fl capalg 0 eq D + 1 NA BL caption exec BN OA /PA t D + }if +} D +/getwid{ + /irow1 E D + /irow2 irow1 D + /rwid 0 D + {rdesc irow2 get dup 0 get rwid add /rwid E D 2 get 0 eq + {exit}{/irow2 irow2 1 add D}ie + }loop +} D +/printrow{ + /xoff ll twidth PL 2 ge{Sf div}if sub talign mul 2 div D + /xleft xoff xo add D + /irow E D + /cells rdesc irow get 6 get D + 0 1 ncol{ + /icol E D + /cell cells icol get D + cell 0 ne{ + cell aload pop /ang E D /CB E D /cvsize E D /above E D /fontsz E D + /DV E D /bot E D /top E D /right E D /left E D /nowrap E D /valign E D + /dp E D /align E D /rspan E D /cspan E D /cclass E D /ctype E D /cmax E D + /cmin E D /proc E D + rspan 0 eq{/rspan nrow irow sub 1 add D}if + cspan 0 eq{/cspan ncol icol sub 1 add D}if + /width 0 D + 0 1 cspan 1 sub{icol add cdesc E get 0 get /width E width add D}for + /rhight rdesc irow get 0 get D + /hight rhight D + 1 1 rspan 1 sub{irow add rdesc E get 0 get /hight E hight add D}for + /W xo xoff add width add right sub D + ang 0 ne{/W xo xoff add hight add right sub D}if + /EO xo xoff add left add D SI + Cf{ + gsave CB VC xo xoff add ycur yoff add M + 0 hight neg RL width 0 RL 0 hight RL width neg 0 RL fill + grestore + }if + ctype 1 eq{() BD}if + /A0 align D RC + AT 4 eq{ + /DC dp D /ID 1 D /DO cdesc icol get 5 get D /Lo DO DV 0 get sub D /L1 Lo D + }if + ang 0 ne{ + gsave ang 90 eq + {xoff ycur add hight cvsize sub 2 div sub ycur hight sub xoff sub} + {xoff ycur sub width add hight cvsize sub 2 div add ycur xoff add}ie + translate ang rotate + }if + valign 3 le{0 ycur yoff add top sub + hight cvsize sub valign 1 sub mul 2 div sub M} + {0 ycur yoff add top sub above add rdesc irow get 4 get sub M}ie + /PA f D /BP t D /Fl t D + BL proc exec BN + ang 0 ne{grestore}if + /PA t D + ctype 1 eq{() ES}if + }if + /xoff xoff cdesc icol get 0 get add D + }for + /yoff yoff rhight sub D +} D +/printhead {0 1 nhead 1 sub{printrow}for} D +/printfoot {nhead 1 nhead nfoot add 1 sub{printrow}for} D +/Tf { + OU{rules 2 ge{/yoff 0 D + gsave 0 Sg + [0 1 nhead 1 sub{}for rbeg 1 row 1 sub{}for nhead 1 nhead nfoot add 1 sub{}for]{ + /irow E D + /xoff ll twidth PL 2 ge{Sf div}if sub talign mul 2 div D + /cells rdesc irow get 6 get D + 0 1 ncol{ + /icol E D + /cell cells icol get D + cell 0 ne{ + /rspan cell 6 get D + /cspan cell 5 get D + rspan 0 eq{/rspan nrow irow sub 1 add D}if + cspan 0 eq{/cspan ncol icol sub 1 add D}if + /width 0 D + 0 1 cspan 1 sub{icol add cdesc E get 0 get /width E width add D}for + /rhight rdesc irow get 0 get D + /hight rhight D + 1 1 rspan 1 sub{irow add rdesc E get 0 get /hight E hight add D}for + xo xoff add width add ycur yoff add M + 0 hight neg icol cspan add 1 sub ncol lt + {cdesc icol 1 add get 4 get dup rules 3 le{1 eq}{pop t}ie + {1 eq{0.8}{0.3}ie + LW RL CP stroke M}{pop R}ie}{R}ie + irow nhead nfoot add 1 sub ne nfoot 0 eq or + {irow rspan add 1 sub nrow lt + {rdesc irow rspan add get 3 get}{nfoot 0 eq{0}{1}ie}ie + dup rules 2 mod 0 eq{1 eq}{pop t}ie + {1 eq irow rspan add nhead eq or irow rspan add row eq nfoot 0 gt and or + {0.8}{0.3}ie LW width neg 0 RL CP stroke M}{pop}ie}if + }if + /xoff xoff cdesc icol get 0 get add D + }for + /yoff yoff rhight sub D + }forall + grestore + /Ms t D + }if + frame 1 gt{ + gsave + 1 LW 0 Sg + xleft ycur M CP BB + 0 yoff frame 5 eq frame 7 ge or{RL}{R}ie + twidth 0 frame 3 eq frame 4 eq or frame 8 ge or{RL}{R}ie CP BB + 0 yoff neg frame 6 ge{RL}{R}ie + twidth neg 0 frame 2 eq frame 4 eq or frame 8 ge or{RL}{R}ie + closepath stroke + grestore + /Ms t D + }if + }if +} D +/tables [[[0 0 0 0 0 -1 0 0 1 55 2 0 0 9 5 {()} -1] + [[0 0 0 0 0 0 0][0 0 0 0 0 0 0][0 0 0 0 0 0 0]] + [[0 0 0 0 0 0 [[{()1 Sl()WB(XML Schema type)} 0 0 1 0 1 1 1 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB(Alias in the )SM(xml_schema)ES( names)HY(pace)YH()} 0 0 1 0 1 1 1 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB(C++ type + )} 0 0 1 0 1 1 1 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +]] +[0 0 0 0 0 0 [[{()1 Sl()WB(fixed-length inte)HY(gral)YH( types + )} 0 0 1 0 3 1 1 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +0 +0 +]] +[0 0 0 0 0 0 [[{()1 Sl()WB()SM(byte)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(byte)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(signed\240char)ES( + )} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +]] +[0 0 0 0 0 0 [[{()1 Sl()WB()SM(unsigned)HY(Byte)YH()ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(unsigned_byte)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(unsigned\240char)ES( + )} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +]] +[0 0 0 0 0 0 [[{()1 Sl()WB()SM(short)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(short_)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(short)ES( + )} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +]] +[0 0 0 0 0 0 [[{()1 Sl()WB()SM(unsigned)HY(Short)YH()ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(unsigned_short)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(unsigned\240short)ES( + )} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +]] +[0 0 0 0 0 0 [[{()1 Sl()WB()SM(int)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(int_)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(int)ES( + )} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +]] +[0 0 0 0 0 0 [[{()1 Sl()WB()SM(unsignedInt)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(unsigned_int)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(unsigned\240int)ES( + )} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +]] +[0 0 0 0 0 0 [[{()1 Sl()WB()SM(long)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(long_)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(long\240long)ES( + )} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +]] +[0 0 0 0 0 0 [[{()1 Sl()WB()SM(unsigned)HY(Long)YH()ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(unsigned_long)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(unsigned\240long\240long)ES( + )} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +]] +[0 0 0 0 0 0 [[{()1 Sl()WB(arbi)HY(trary)YH(-length inte)HY(gral)YH( types + )} 0 0 1 0 3 1 1 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +0 +0 +]] +[0 0 0 0 0 0 [[{()1 Sl()WB()SM(integer)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(integer)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(long\240long)ES( + )} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +]] +[0 0 0 0 0 0 [[{()1 Sl()WB()SM(nonPos)HY(i)HY(tiveIn)HY(te)HY(ger)YH()ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(non_posi)HY(tive)YH(_integer)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(long\240long)ES( + )} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +]] +[0 0 0 0 0 0 [[{()1 Sl()WB()SM(nonNeg)HY(a)HY(tiveIn)HY(te)HY(ger)YH()ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(non_nega)HY(tive)YH(_integer)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(unsigned long\240long)ES( + )} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +]] +[0 0 0 0 0 0 [[{()1 Sl()WB()SM(posi)HY(tiveIn)HY(te)HY(ger)YH()ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(posi)HY(tive)YH(_integer)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(unsigned long\240long)ES( + )} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +]] +[0 0 0 0 0 0 [[{()1 Sl()WB()SM(nega)HY(tiveIn)HY(te)HY(ger)YH()ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(nega)HY(tive)YH(_integer)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(long\240long)ES( + )} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +]] +[0 0 0 0 0 0 [[{()1 Sl()WB(boolean types + )} 0 0 1 0 3 1 1 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +0 +0 +]] +[0 0 0 0 0 0 [[{()1 Sl()WB()SM(boolean)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(boolean)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(bool)ES( + )} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +]] +[0 0 0 0 0 0 [[{()1 Sl()WB(fixed-preci)HY(sion)YH( float)HY(ing)YH(-point types + )} 0 0 1 0 3 1 1 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +0 +0 +]] +[0 0 0 0 0 0 [[{()1 Sl()WB()SM(float)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(float_)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(float)ES( + )} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +]] +[0 0 0 0 0 0 [[{()1 Sl()WB()SM(double)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(double_)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(double)ES( + )} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +]] +[0 0 0 0 0 0 [[{()1 Sl()WB(arbi)HY(trary)YH(-preci)HY(sion)YH( float)HY(ing)YH(-point types + )} 0 0 1 0 3 1 1 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +0 +0 +]] +[0 0 0 0 0 0 [[{()1 Sl()WB()SM(decimal)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(decimal)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(double)ES( + )} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +]] +[0 0 0 0 0 0 [[{()1 Sl()WB(string types + )} 0 0 1 0 3 1 1 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +0 +0 +]] +[0 0 0 0 0 0 [[{()1 Sl()WB()SM(string)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(string)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB(type derived from )SM(std::basic_string)ES( + )} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +]] +[0 0 0 0 0 0 [[{()1 Sl()WB()SM(normal)HY(ized)HY(String)YH()ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(normal)HY(ized)YH(_string)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB(type derived from )SM(string)ES( + )} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +]] +[0 0 0 0 0 0 [[{()1 Sl()WB()SM(token)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(token)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB(type\240derived\240from\240)SM(normal)HY(ized)YH(_string)ES( + )} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +]] +[0 0 0 0 0 0 [[{()1 Sl()WB()SM(Name)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(name)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB(type derived from )SM(token)ES( + )} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +]] +[0 0 0 0 0 0 [[{()1 Sl()WB()SM(NMTOKEN)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(nmtoken)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB(type derived from )SM(token)ES( + )} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +]] +[0 0 0 0 0 0 [[{()1 Sl()WB()SM(NMTO)HY(KENS)YH()ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(nmto)HY(kens)YH()ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB(type derived from )SM(sequence<nmtoken>)ES( + )} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +]] +[0 0 0 0 0 0 [[{()1 Sl()WB()SM(NCName)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(ncname)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB(type derived from )SM(name)ES( + )} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +]] +[0 0 0 0 0 0 [[{()1 Sl()WB()SM(language)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(language)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB(type derived from )SM(token)ES( + )} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +]] +[0 0 0 0 0 0 [[{()1 Sl()WB(qual)HY(i)HY(fied)YH( name + )} 0 0 1 0 3 1 1 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +0 +0 +]] +[0 0 0 0 0 0 [[{()1 Sl()WB()SM(QName)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(qname)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(xml_schema::qname)ES( + )} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +]] +[0 0 0 0 0 0 [[{()1 Sl()WB(ID/IDREF types + )} 0 0 1 0 3 1 1 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +0 +0 +]] +[0 0 0 0 0 0 [[{()1 Sl()WB()SM(ID)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(id)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB(type derived from )SM(ncname)ES( + )} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +]] +[0 0 0 0 0 0 [[{()1 Sl()WB()SM(IDREF)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(idref)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB(type derived from )SM(ncname)ES( + )} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +]] +[0 0 0 0 0 0 [[{()1 Sl()WB()SM(IDREFS)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(idrefs)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB(type derived from )SM(sequence<idref>)ES( + )} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +]] +[0 0 0 0 0 0 [[{()1 Sl()WB(URI types + )} 0 0 1 0 3 1 1 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +0 +0 +]] +[0 0 0 0 0 0 [[{()1 Sl()WB()SM(anyURI)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(uri)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB(type derived from )SM(std::basic_string)ES( + )} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +]] +[0 0 0 0 0 0 [[{()1 Sl()WB(binary types + )} 0 0 1 0 3 1 1 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +0 +0 +]] +[0 0 0 0 0 0 [[{()1 Sl()WB()SM(base64Binary)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(base64_binary)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(xml_schema::base64_binary)ES( + )} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +]] +[0 0 0 0 0 0 [[{()1 Sl()WB()SM(hexBi)HY(nary)YH()ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(hex_binary)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(xml_schema::hex_binary)ES( + )} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +]] +[0 0 0 0 0 0 [[{()1 Sl()WB(date/time types + )} 0 0 1 0 3 1 1 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +0 +0 +]] +[0 0 0 0 0 0 [[{()1 Sl()WB()SM(date)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(date)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(xml_schema::date)ES( + )} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +]] +[0 0 0 0 0 0 [[{()1 Sl()WB()SM(date)HY(Time)YH()ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(date_time)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(xml_schema::date_time)ES( + )} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +]] +[0 0 0 0 0 0 [[{()1 Sl()WB()SM(dura)HY(tion)YH()ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(dura)HY(tion)YH()ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(xml_schema::dura)HY(tion)YH()ES( + )} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +]] +[0 0 0 0 0 0 [[{()1 Sl()WB()SM(gDay)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(gday)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(xml_schema::gday)ES( + )} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +]] +[0 0 0 0 0 0 [[{()1 Sl()WB()SM(gMonth)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(gmonth)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(xml_schema::gmonth)ES( + )} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +]] +[0 0 0 0 0 0 [[{()1 Sl()WB()SM(gMon)HY(th)HY(Day)YH()ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(gmonth_day)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(xml_schema::gmonth_day)ES( + )} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +]] +[0 0 0 0 0 0 [[{()1 Sl()WB()SM(gYear)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(gyear)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(xml_schema::gyear)ES( + )} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +]] +[0 0 0 0 0 0 [[{()1 Sl()WB()SM(gYear)HY(Month)YH()ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(gyear_month)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(xml_schema::gyear_month)ES( + )} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +]] +[0 0 0 0 0 0 [[{()1 Sl()WB()SM(time)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(time)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(xml_schema::time)ES( + )} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +]] +[0 0 0 0 0 0 [[{()1 Sl()WB(entity types + )} 0 0 1 0 3 1 1 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +0 +0 +]] +[0 0 0 0 0 0 [[{()1 Sl()WB()SM(ENTITY)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(entity)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB(type derived from )SM(name)ES( + )} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +]] +[0 0 0 0 0 0 [[{()1 Sl()WB()SM(ENTI)HY(TIES)YH()ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(enti)HY(ties)YH()ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB(type derived from )SM(sequence<entity>)ES( + )} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +]] +]] +] D +0 1 0{TS}for RC ZF +/Ba f D /BO 0 D Bs +/UR (/home/boris/work/xsd/xsd/doc/cxx/tree/guide/index.xhtml) D +/Ti (C++/Tree Mapping Getting Started Guide) D +/Au () D +/Df f D +/ME [] D +Pt +/BO 0 D TC /Ba f D Bs /AU f D /UR () D RC ZF + tH WB +ND 1 gt{Ts 3 mul Np 0()0 C()BD(C++/Tree Mapping Getting Started Guide)ES()0 1 TN()EA()BN}if +1 NH le{36(1\240\240)1 C(Preface)WB 3 Sn()36 1 TN()EA()BN}if +2 NH le{37(1.1\240\240)2 C(About)WB 4 Sn( This Docu)HY(ment)YH()37 1 TN()EA()BN}if +2 NH le{38(1.2\240\240)2 C(More)WB 5 Sn( Infor)HY(ma)HY(tion)YH()38 1 TN()EA()BN}if +1 NH le{39(2\240\240)1 C(1)WB 6 Sn( Intro)HY(duc)HY(tion)YH()39 1 TN()EA()BN}if +2 NH le{40(2.1\240\240)2 C(1.1)WB 7 Sn( Mapping Overview)40 1 TN()EA()BN}if +2 NH le{41(2.2\240\240)2 C(1.2)WB 8 Sn( Bene)HY(fits)YH()41 1 TN()EA()BN}if +1 NH le{42(3\240\240)1 C(2)WB 9 Sn( Hello World Example)42 1 TN()EA()BN}if +2 NH le{43(3.1\240\240)2 C(2.1)WB 10 Sn( Writing XML Docu)HY(ment)YH( and Schema)43 1 TN()EA()BN}if +2 NH le{44(3.2\240\240)2 C(2.2)WB 11 Sn( Trans)HY(lat)HY(ing)YH( Schema to C++)44 1 TN()EA()BN}if +2 NH le{45(3.3\240\240)2 C(2.3)WB 12 Sn( Imple)HY(ment)HY(ing)YH( Appli)HY(ca)HY(tion)YH( Logic)45 1 TN()EA()BN}if +2 NH le{46(3.4\240\240)2 C(2.4)WB 13 Sn( Compil)HY(ing)YH( and Running)46 1 TN()EA()BN}if +2 NH le{47(3.5\240\240)2 C(2.5)WB 14 Sn( Adding Seri)HY(al)HY(iza)HY(tion)YH()47 1 TN()EA()BN}if +2 NH le{48(3.6\240\240)2 C(2.6)WB 15 Sn( Select)HY(ing)YH( Naming Conven)HY(tion)YH()48 1 TN()EA()BN}if +2 NH le{49(3.7\240\240)2 C(2.7)WB 16 Sn( Gener)HY(at)HY(ing)YH( Docu)HY(men)HY(ta)HY(tion)YH()49 1 TN()EA()BN}if +1 NH le{50(4\240\240)1 C(3)WB 17 Sn( Overall Mapping Config)HY(u)HY(ra)HY(tion)YH()50 1 TN()EA()BN}if +2 NH le{51(4.1\240\240)2 C(3.1)WB 18 Sn( C++ Stan)HY(dard)YH()51 1 TN()EA()BN}if +2 NH le{52(4.2\240\240)2 C(3.2)WB 19 Sn( Char)HY(ac)HY(ter)YH( Type and Encod)HY(ing)YH()52 1 TN()EA()BN}if +2 NH le{53(4.3\240\240)2 C(3.3)WB 20 Sn( Support for Poly)HY(mor)HY(phism)YH()53 1 TN()EA()BN}if +2 NH le{54(4.4\240\240)2 C(3.4)WB 21 Sn( Names)HY(pace)YH( Mapping)54 1 TN()EA()BN}if +2 NH le{55(4.5\240\240)2 C(3.5)WB 22 Sn( Thread Safety)55 1 TN()EA()BN}if +1 NH le{56(5\240\240)1 C(4)WB 23 Sn( Working with Object Models)56 1 TN()EA()BN}if +2 NH le{57(5.1\240\240)2 C(4.1)WB 24 Sn( Attribute and Element Cardi)HY(nal)HY(i)HY(ties)YH()57 1 TN()EA()BN}if +2 NH le{58(5.2\240\240)2 C(4.2)WB 25 Sn( Access)HY(ing)YH( the Object Model)58 1 TN()EA()BN}if +2 NH le{59(5.3\240\240)2 C(4.3)WB 26 Sn( Modi)HY(fy)HY(ing)YH( the Object Model)59 1 TN()EA()BN}if +2 NH le{60(5.4\240\240)2 C(4.4)WB 27 Sn( Creat)HY(ing)YH( the Object Model from Scratch)60 1 TN()EA()BN}if +2 NH le{61(5.5\240\240)2 C(4.5)WB 28 Sn( Mapping for the Built-in XML Schema Types)61 1 TN()EA()BN}if +1 NH le{62(6\240\240)1 C(5)WB 30 Sn( Parsing)62 1 TN()EA()BN}if +2 NH le{63(6.1\240\240)2 C(5.1)WB 31 Sn( XML Schema Vali)HY(da)HY(tion)YH( and Search)HY(ing)YH()63 1 TN()EA()BN}if +2 NH le{64(6.2\240\240)2 C(5.2)WB 32 Sn( Error Handling)64 1 TN()EA()BN}if +1 NH le{65(7\240\240)1 C(6)WB 33 Sn( Seri)HY(al)HY(iza)HY(tion)YH()65 1 TN()EA()BN}if +2 NH le{66(7.1\240\240)2 C(6.1)WB 34 Sn( Names)HY(pace)YH( and Schema Infor)HY(ma)HY(tion)YH()66 1 TN()EA()BN}if +2 NH le{67(7.2\240\240)2 C(6.2)WB 35 Sn( Error Handling)67 1 TN()EA()BN}if +/OU t D /Cb Db D NP Ep ET +/Cb Db D /Ct [16#00 16#00 16#00] D /Cl [16#00 16#00 16#00] D /CL -1 D Ct Sc + +/Ba f D /BO 0 D Bs +/UR (/home/boris/work/xsd/xsd/doc/cxx/tree/guide/index.xhtml) D +/Ti (C++/Tree Mapping Getting Started Guide) D +/Au () D +/Df f D +/ME [] D + +NP RC ZF +()1 Sl()WB 0 Sn( + +)BR()WB 1 Sn( )BR()WB 2 Sn( + + + )0 1 0 H(Preface)WB 36 Sn()WB 3 Sn()EA()EH( + + )0 2 1 H(About)WB 37 Sn()WB 4 Sn( This Docu)HY(ment)YH()EA()EH( + + )0 P(The goal of this docu)HY(ment)YH( is to provide you with an under)HY(stand)HY(ing)YH( of + the C++/Tree program)HY(ming)YH( model and allow you to effi)HY(ciently)YH( eval)HY(u)HY(ate)YH( + XSD against your project's tech)HY(ni)HY(cal)YH( require)HY(ments)YH(. As such, this + docu)HY(ment)YH( is intended for C++ devel)HY(op)HY(ers)YH( and soft)HY(ware)YH( archi)HY(tects)YH( + who are looking for an XML process)HY(ing)YH( solu)HY(tion)YH(. For a more in-depth + descrip)HY(tion)YH( of the C++/Tree mapping refer to the + )R1 2 A(C++/Tree + Mapping User Manual)EA(.)EP( + + )0 P(Prior expe)HY(ri)HY(ence)YH( with XML and C++ is required to under)HY(stand)YH( this + docu)HY(ment)YH(. Basic under)HY(stand)HY(ing)YH( of XML Schema is advan)HY(ta)HY(geous)YH( but + not expected or required. + )EP( + + + )0 2 2 H(More)WB 38 Sn()WB 5 Sn( Infor)HY(ma)HY(tion)YH()EA()EH( + + )0 P(Beyond this guide, you may also find the follow)HY(ing)YH( sources of + infor)HY(ma)HY(tion)YH( useful:)EP( + + )UL( )-1 LI()R1 2 A(C++/Tree + Mapping User Manual)EA( + + )-1 LI()R2 2 A(C++/Tree + Mapping Customiza)HY(tion)YH( Guide)EA( + + )-1 LI()R3 2 A(C++/Tree + Mapping Frequently Asked Ques)HY(tions)YH( \201FAQ\202)EA( + + )-1 LI()R4 2 A(XSD + Compiler Command Line Manual)EA( + + )-1 LI(The )SM(exam)HY(ples)YH(/cxx/tree/)ES( direc)HY(tory)YH( in the XSD + distri)HY(bu)HY(tion)YH( contains a collec)HY(tion)YH( of exam)HY(ples)YH( and a README + file with an overview of each example. + + )-1 LI(The )SM(README)ES( file in the XSD distri)HY(bu)HY(tion)YH( explains + how to compile the exam)HY(ples)YH( on various plat)HY(forms)YH(. + + )-1 LI(The )R5 2 A(xsd-users)EA( + mailing list is the place to ask tech)HY(ni)HY(cal)YH( ques)HY(tions)YH( about XSD and the C++/Parser mapping. + Further)HY(more)YH(, the )R6 2 A(archives)EA( + may already have answers to some of your ques)HY(tions)YH(. + )LU( + + + + )0 1 3 H(1)WB 39 Sn()WB 6 Sn( Intro)HY(duc)HY(tion)YH()EA()EH( + + )0 P(Welcome to CodeSyn)HY(the)HY(sis)YH( XSD and the C++/Tree mapping. XSD is a + cross-plat)HY(form)YH( W3C XML Schema to C++ data binding compiler. C++/Tree + is a W3C XML Schema to C++ mapping that repre)HY(sents)YH( the data stored + in XML as a stat)HY(i)HY(cally)YH(-typed, vocab)HY(u)HY(lary)YH(-specific object model. + )EP( + + )0 2 4 H(1.1)WB 40 Sn()WB 7 Sn( Mapping Overview)EA()EH( + + )0 P(Based on a formal descrip)HY(tion)YH( of an XML vocab)HY(u)HY(lary)YH( \201schema\202, the + C++/Tree mapping produces a tree-like data struc)HY(ture)YH( suit)HY(able)YH( for + in-memory process)HY(ing)YH(. The core of the mapping consists of C++ + classes that consti)HY(tute)YH( the object model and are derived from + types defined in XML Schema as well as XML parsing and + seri)HY(al)HY(iza)HY(tion)YH( code.)EP( + + )0 P(Besides the core features, C++/Tree provide a number of addi)HY(tional)YH( + mapping elements that can be useful in some appli)HY(ca)HY(tions)YH(. These + include seri)HY(al)HY(iza)HY(tion)YH( and extrac)HY(tion)YH( to/from formats others than + XML, such as unstruc)HY(tured)YH( text \201useful for debug)HY(ging)YH(\202 and binary + repre)HY(sen)HY(ta)HY(tions)YH( such as XDR and CDR for high-speed data process)HY(ing)YH( + as well as auto)HY(matic)YH( docu)HY(men)HY(ta)HY(tion)YH( gener)HY(a)HY(tion)YH(. The C++/Tree mapping + also provides a wide range of mech)HY(a)HY(nisms)YH( for control)HY(ling)YH( and + customiz)HY(ing)YH( the gener)HY(ated)YH( code.)EP( + + )0 P(A typical appli)HY(ca)HY(tion)YH( that uses C++/Tree for XML process)HY(ing)YH( usually + performs the follow)HY(ing)YH( three steps: it first reads \201parses\202 an XML + docu)HY(ment)YH( to an in-memory object model, it then performs some useful + compu)HY(ta)HY(tions)YH( on that object model which may involve modi)HY(fi)HY(ca)HY(tion)YH( + of the model, and finally it may write \201seri)HY(al)HY(ize)YH(\202 the modi)HY(fied)YH( + object model back to XML.)EP( + + )0 P(The next chapter presents a simple appli)HY(ca)HY(tion)YH( that performs these + three steps. The follow)HY(ing)YH( chap)HY(ters)YH( show how to use the C++/Tree + mapping in more detail.)EP( + + )0 2 5 H(1.2)WB 41 Sn()WB 8 Sn( Bene)HY(fits)YH()EA()EH( + + )0 P(Tradi)HY(tional)YH( XML access APIs such as Docu)HY(ment)YH( Object Model \201DOM\202 + or Simple API for XML \201SAX\202 have a number of draw)HY(backs)YH( that + make them less suit)HY(able)YH( for creat)HY(ing)YH( robust and main)HY(tain)HY(able)YH( + XML process)HY(ing)YH( appli)HY(ca)HY(tions)YH(. These draw)HY(backs)YH( include: + )EP( + + )UL( )-1 LI(Generic repre)HY(sen)HY(ta)HY(tion)YH( of XML in terms of elements, attributes, + and text forces an appli)HY(ca)HY(tion)YH( devel)HY(oper)YH( to write a substan)HY(tial)YH( + amount of bridg)HY(ing)YH( code that iden)HY(ti)HY(fies)YH( and trans)HY(forms)YH( pieces + of infor)HY(ma)HY(tion)YH( encoded in XML to a repre)HY(sen)HY(ta)HY(tion)YH( more suit)HY(able)YH( + for consump)HY(tion)YH( by the appli)HY(ca)HY(tion)YH( logic. + + )-1 LI(String-based flow control defers error detec)HY(tion)YH( to runtime. + It also reduces code read)HY(abil)HY(ity)YH( and main)HY(tain)HY(abil)HY(ity)YH(. + + )-1 LI(Lack of type safety because the data is repre)HY(sented)YH( as text. + + )-1 LI(Result)HY(ing)YH( appli)HY(ca)HY(tions)YH( are hard to debug, change, and + main)HY(tain)YH(. + )LU( + + )0 P(In contrast, stat)HY(i)HY(cally)YH(-typed, vocab)HY(u)HY(lary)YH(-specific object model + produced by the C++/Tree mapping allows you to operate in your + domain terms instead of the generic elements, attributes, and + text. Static typing helps catch errors at compile-time rather + than at run-time. Auto)HY(matic)YH( code gener)HY(a)HY(tion)YH( frees you for more + inter)HY(est)HY(ing)YH( tasks \201such as doing some)HY(thing)YH( useful with the + infor)HY(ma)HY(tion)YH( stored in the XML docu)HY(ments)YH(\202 and mini)HY(mizes)YH( the + effort needed to adapt your appli)HY(ca)HY(tions)YH( to changes in the + docu)HY(ment)YH( struc)HY(ture)YH(. To summa)HY(rize)YH(, the C++/Tree object model has + the follow)HY(ing)YH( key advan)HY(tages)YH( over generic XML access APIs:)EP( + + )UL( )-1 LI()BD(Ease of use.)ES( The gener)HY(ated)YH( code hides all the complex)HY(ity)YH( + asso)HY(ci)HY(ated)YH( with parsing and seri)HY(al)HY(iz)HY(ing)YH( XML. This includes navi)HY(gat)HY(ing)YH( + the struc)HY(ture)YH( and convert)HY(ing)YH( between the text repre)HY(sen)HY(ta)HY(tion)YH( and + data types suit)HY(able)YH( for manip)HY(u)HY(la)HY(tion)YH( by the appli)HY(ca)HY(tion)YH( + logic. + + )-1 LI()BD(Natural repre)HY(sen)HY(ta)HY(tion)YH(.)ES( The object repre)HY(sen)HY(ta)HY(tion)YH( allows + you to access the XML data using your domain vocab)HY(u)HY(lary)YH( instead + of generic elements, attributes, and text. + + )-1 LI()BD(Concise code.)ES( With the object repre)HY(sen)HY(ta)HY(tion)YH( the + appli)HY(ca)HY(tion)YH( imple)HY(men)HY(ta)HY(tion)YH( is simpler and thus easier + to read and under)HY(stand)YH(. + + )-1 LI()BD(Safety.)ES( The gener)HY(ated)YH( object model is stat)HY(i)HY(cally)YH( + typed and uses func)HY(tions)YH( instead of strings to access the + infor)HY(ma)HY(tion)YH(. This helps catch program)HY(ming)YH( errors at compile-time + rather than at runtime. + + )-1 LI()BD(Main)HY(tain)HY(abil)HY(ity)YH(.)ES( Auto)HY(matic)YH( code gener)HY(a)HY(tion)YH( mini)HY(mizes)YH( the + effort needed to adapt the appli)HY(ca)HY(tion)YH( to changes in the + docu)HY(ment)YH( struc)HY(ture)YH(. With static typing, the C++ compiler + can pin-point the places in the client code that need to be + changed. + + )-1 LI()BD(Compat)HY(i)HY(bil)HY(ity)YH(.)ES( Sequences of elements are repre)HY(sented)YH( in + the object model as contain)HY(ers)YH( conform)HY(ing)YH( to the stan)HY(dard)YH( C++ + sequence require)HY(ments)YH(. This makes it possi)HY(ble)YH( to use stan)HY(dard)YH( + C++ algo)HY(rithms)YH( on the object repre)HY(sen)HY(ta)HY(tion)YH( and frees you from + learn)HY(ing)YH( yet another container inter)HY(face)YH(, as is the case with + DOM. + + )-1 LI()BD(Effi)HY(ciency)YH(.)ES( If the appli)HY(ca)HY(tion)YH( makes repet)HY(i)HY(tive)YH( use + of the data extracted from XML, then the C++/Tree object model + is more effi)HY(cient)YH( because the navi)HY(ga)HY(tion)YH( is performed using + func)HY(tion)YH( calls rather than string compar)HY(isons)YH( and the XML + data is extracted only once. Further)HY(more)YH(, the runtime memory + usage is reduced due to more effi)HY(cient)YH( data storage + \201for instance, storing numeric data as inte)HY(gers)YH( instead of + strings\202 as well as the static knowl)HY(edge)YH( of cardi)HY(nal)HY(ity)YH( + constraints. + )LU( + + + + + + )0 1 6 H(2)WB 42 Sn()WB 9 Sn( Hello World Example)EA()EH( + + )0 P(In this chapter we will examine how to parse, access, modify, and + seri)HY(al)HY(ize)YH( a very simple XML docu)HY(ment)YH( using the XSD-gener)HY(ated)YH( + C++/Tree object model. The code presented in this chapter is + based on the )SM(hello)ES( example which can be found in + the )SM(exam)HY(ples)YH(/cxx/tree/)ES( direc)HY(tory)YH( of the XSD + distri)HY(bu)HY(tion)YH(.)EP( + + )0 2 7 H(2.1)WB 43 Sn()WB 10 Sn( Writing XML Docu)HY(ment)YH( and Schema)EA()EH( + + )0 P(First, we need to get an idea about the struc)HY(ture)YH( + of the XML docu)HY(ments)YH( we are going to process. Our + )SM(hello.xml)ES(, for example, could look like this:)EP( + + ) 10 28 PR(<?xml version="1.0"?> +<hello> + + <greeting>Hello</greeting> + + <name>sun</name> + <name>moon</name> + <name>world</name> + +</hello>)RP( + + )0 P(Then we can write a descrip)HY(tion)YH( of the above XML in the + XML Schema language and save it into )SM(hello.xsd)ES(:)EP( + + ) 13 70 PR(<?xml version="1.0"?> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> + + <xs:complexType name="hello_t"> + <xs:sequence> + <xs:element name="greeting" type="xs:string"/> + <xs:element name="name" type="xs:string" maxOccurs="unbounded"/> + </xs:sequence> + </xs:complexType> + + <xs:element name="hello" type="hello_t"/> + +</xs:schema>)RP( + + )0 P(Even if you are not famil)HY(iar)YH( with XML Schema, it + should be easy to connect decla)HY(ra)HY(tions)YH( in )SM(hello.xsd)ES( + to elements in )SM(hello.xml)ES(. The )SM(hello_t)ES( type + is defined as a sequence of the nested )SM(greet)HY(ing)YH()ES( and + )SM(name)ES( elements. Note that the term sequence in XML + Schema means that elements should appear in a partic)HY(u)HY(lar)YH( order + as opposed to appear)HY(ing)YH( multi)HY(ple)YH( times. The )SM(name)ES( + element has its )SM(maxOc)HY(curs)YH()ES( prop)HY(erty)YH( set to + )SM(unbounded)ES( which means it can appear multi)HY(ple)YH( times + in an XML docu)HY(ment)YH(. Finally, the glob)HY(ally)YH(-defined )SM(hello)ES( + element prescribes the root element for our vocab)HY(u)HY(lary)YH(. For an + easily-approach)HY(able)YH( intro)HY(duc)HY(tion)YH( to XML Schema refer to + )R7 2 A(XML Schema Part 0: + Primer)EA(.)EP( + + )0 P(The above schema is a spec)HY(i)HY(fi)HY(ca)HY(tion)YH( of our XML vocab)HY(u)HY(lary)YH(; it tells + every)HY(body)YH( what valid docu)HY(ments)YH( of our XML-based language should look + like. We can also update our )SM(hello.xml)ES( to include the + infor)HY(ma)HY(tion)YH( about the schema so that XML parsers can vali)HY(date)YH( + our docu)HY(ment)YH(:)EP( + + ) 11 60 PR(<?xml version="1.0"?> +<hello xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="hello.xsd"> + + <greeting>Hello</greeting> + + <name>sun</name> + <name>moon</name> + <name>world</name> + +</hello>)RP( + + + )0 P(The next step is to compile the schema to gener)HY(ate)YH( the object + model and parsing func)HY(tions)YH(.)EP( + + )0 2 8 H(2.2)WB 44 Sn()WB 11 Sn( Trans)HY(lat)HY(ing)YH( Schema to C++)EA()EH( + + )0 P(Now we are ready to trans)HY(late)YH( our )SM(hello.xsd)ES( to C++. + To do this we invoke the XSD compiler from a termi)HY(nal)YH( \201UNIX\202 or + a command prompt \201Windows\202: + )EP( + + ) 1 24 PR($ xsd cxx-tree hello.xsd)RP( + + )0 P(The XSD compiler produces two C++ files: )SM(hello.hxx)ES( and + )SM(hello.cxx)ES(. The follow)HY(ing)YH( code frag)HY(ment)YH( is taken from + )SM(hello.hxx)ES(; it should give you an idea about what gets + gener)HY(ated)YH(: + )EP( + + ) 45 60 PR(class hello_t +{ +public: + // greeting + // + typedef xml_schema::string greeting_type; + + const greeting_type& + greeting \201\202 const; + + greeting_type& + greeting \201\202; + + void + greeting \201const greeting_type& x\202; + + // name + // + typedef xml_schema::string name_type; + typedef xsd::sequence<name_type> name_sequence; + typedef name_sequence::iterator name_iterator; + typedef name_sequence::const_iterator name_const_iterator; + + const name_sequence& + name \201\202 const; + + name_sequence& + name \201\202; + + void + name \201const name_sequence& s\202;)WR( + + // Constructor. + // + hello_t \201const greeting_type&\202; + + ... + +}; + +std::auto_ptr<hello_t> +hello \201const std::string& uri\202; + +std::auto_ptr<hello_t> +hello \201std::istream&\202;)RP( + + )0 P(The )SM(hello_t)ES( C++ class corre)HY(sponds)YH( to the + )SM(hello_t)ES( XML Schema type. For each element + in this type a set of C++ type defi)HY(ni)HY(tions)YH( as well as + acces)HY(sor)YH( and modi)HY(fier)YH( func)HY(tions)YH( are gener)HY(ated)YH( inside the + )SM(hello_t)ES( class. Note that the type defi)HY(ni)HY(tions)YH( + and member func)HY(tions)YH( for the )SM(greet)HY(ing)YH()ES( and + )SM(name)ES( elements are differ)HY(ent)YH( because of the + cardi)HY(nal)HY(ity)YH( differ)HY(ences)YH( between these two elements + \201)SM(greet)HY(ing)YH()ES( is a required single element and + )SM(name)ES( is a sequence of elements\202.)EP( + + )0 P(The )SM(xml_schema::string)ES( type used in the type + defi)HY(ni)HY(tions)YH( is a C++ class provided by the XSD runtime + that corre)HY(sponds)YH( to built-in XML Schema type + )SM(string)ES(. The )SM(xml_schema::string)ES( + is based on )SM(std::string)ES( and can be used as + such. Simi)HY(larly)YH(, the )SM(sequence)ES( class template + that is used in the )SM(name_sequence)ES( type + defi)HY(ni)HY(tion)YH( is based on and has the same inter)HY(face)YH( as + )SM(std::vector)ES(. The mapping between the built-in + XML Schema types and C++ types is described in more detail in + )0 28 1 A(Section 4.5, "Mapping for the Built-in XML Schema + Types")28 0 TN TL()Ec /AF f D(. The )SM(hello_t)ES( class also includes a + construc)HY(tor)YH( with an initial)HY(izer)YH( for the required + )SM(greet)HY(ing)YH()ES( element as its argu)HY(ment)YH(.)EP( + + )0 P(The )SM(hello)ES( over)HY(loaded)YH( global func)HY(tions)YH( corre)HY(spond)YH( + to the )SM(hello)ES( global element in XML Schema. A + global element in XML Schema is a valid docu)HY(ment)YH( root. + By default XSD gener)HY(ated)YH( a set of parsing func)HY(tions)YH( for each + global element defined in XML Schema \201this can be over)HY(rid)HY(den)YH( + with the )SM(--root-element-*)ES( options\202. Parsing + func)HY(tions)YH( return a dynam)HY(i)HY(cally)YH( allo)HY(cated)YH( object model as an + auto)HY(matic)YH( pointer. The actual pointer used depends on the + C++ stan)HY(dard)YH( selected. For C++98 it is )SM(std::auto_ptr)ES( + as shown above. For C++11 it is )SM(std::unique_ptr)ES(. + For example, if we modify our XSD compiler invo)HY(ca)HY(tion)YH( to + select C++11:)EP( + + ) 1 36 PR($ xsd cxx-tree --std c++11 hello.xsd)RP( + + )0 P(Then the parsing func)HY(tion)YH( signa)HY(tures)YH( will become:)EP( + + ) 5 31 PR(std::unique_ptr<hello_t> +hello \201const std::string& uri\202; + +std::unique_ptr<hello_t> +hello \201std::istream&\202;)RP( + + )0 P(For more infor)HY(ma)HY(tion)YH( on parsing func)HY(tions)YH( see )0 30 1 A(Chapter 5, + "Parsing")30 0 TN TL()Ec /AF f D(.)EP( + + )0 2 9 H(2.3)WB 45 Sn()WB 12 Sn( Imple)HY(ment)HY(ing)YH( Appli)HY(ca)HY(tion)YH( Logic)EA()EH( + + )0 P(At this point we have all the parts we need to do some)HY(thing)YH( useful + with the infor)HY(ma)HY(tion)YH( stored in our XML docu)HY(ment)YH(: + )EP( + + ) 25 62 PR(#include <iostream> +#include "hello.hxx" + +using namespace std; + +int +main \201int argc, char* argv[]\202 +{ + try + { + auto_ptr<hello_t> h \201hello \201argv[1]\202\202; + + for \201hello_t::name_const_iterator i \201h->name \201\202.begin \201\202\202; + i != h->name \201\202.end \201\202; + ++i\202 + { + cerr << h->greeting \201\202 << ", " << *i << "!" << endl; + } + } + catch \201const xml_schema::exception& e\202 + { + cerr << e << endl; + return 1; + } +})RP( + + )0 P(The first part of our appli)HY(ca)HY(tion)YH( calls one of the parsing + func)HY(tions)YH( to parser an XML file spec)HY(i)HY(fied)YH( in the command line. + We then use the returned object model to iterate over names + and print a greet)HY(ing)YH( line for each of them. Finally, we + catch and print the )SM(xml_schema::excep)HY(tion)YH()ES( + excep)HY(tion)YH( in case some)HY(thing)YH( goes wrong. This excep)HY(tion)YH( + is the root of the excep)HY(tion)YH( hier)HY(ar)HY(chy)YH( used by the + XSD-gener)HY(ated)YH( code. + )EP( + + + )0 2 10 H(2.4)WB 46 Sn()WB 13 Sn( Compil)HY(ing)YH( and Running)EA()EH( + + )0 P(After saving our appli)HY(ca)HY(tion)YH( from the previ)HY(ous)YH( section in + )SM(driver.cxx)ES(, we are ready to compile our first + program and run it on the test XML docu)HY(ment)YH(. On a UNIX + system this can be done with the follow)HY(ing)YH( commands: + )EP( + + ) 6 43 PR($ c++ -I.../libxsd -c driver.cxx hello.cxx +$ c++ -o driver driver.o hello.o -lxerces-c +$ ./driver hello.xml +Hello, sun! +Hello, moon! +Hello, world!)RP( + + )0 P(Here )SM(.../libxsd)ES( repre)HY(sents)YH( the path to the + )SM(libxsd)ES( direc)HY(tory)YH( in the XSD distri)HY(bu)HY(tion)YH(. + Note also that we are required to link our appli)HY(ca)HY(tion)YH( + with the Xerces-C++ library because the gener)HY(ated)YH( code + uses it as the under)HY(ly)HY(ing)YH( XML parser.)EP( + + )0 2 11 H(2.5)WB 47 Sn()WB 14 Sn( Adding Seri)HY(al)HY(iza)HY(tion)YH()EA()EH( + + )0 P(While parsing and access)HY(ing)YH( the XML data may be every)HY(thing)YH( + you need, there are appli)HY(ca)HY(tions)YH( that require creat)HY(ing)YH( new + or modi)HY(fy)HY(ing)YH( exist)HY(ing)YH( XML docu)HY(ments)YH(. By default XSD does + not produce seri)HY(al)HY(iza)HY(tion)YH( code. We will need to request + it with the )SM(--gener)HY(ate)YH(-seri)HY(al)HY(iza)HY(tion)YH()ES( options:)EP( + + ) 1 49 PR($ xsd cxx-tree --generate-serialization hello.xsd)RP( + + )0 P(If we now examine the gener)HY(ated)YH( )SM(hello.hxx)ES( file, + we will find a set of over)HY(loaded)YH( seri)HY(al)HY(iza)HY(tion)YH( func)HY(tions)YH(, + includ)HY(ing)YH( the follow)HY(ing)YH( version:)EP( + + ) 5 45 PR(void +hello \201std::ostream&, + const hello_t&, + const xml_schema::namespace_infomap& = + xml_schema::namespace_infomap \201\202\202; +)RP( + + )0 P(Just like with parsing func)HY(tions)YH(, XSD gener)HY(ates)YH( seri)HY(al)HY(iza)HY(tion)YH( + func)HY(tions)YH( for each global element unless instructed other)HY(wise)YH( + with one of the )SM(--root-element-*)ES( options. For more + infor)HY(ma)HY(tion)YH( on seri)HY(al)HY(iza)HY(tion)YH( func)HY(tions)YH( see )0 33 1 A(Chapter 6, + "Seri)HY(al)HY(iza)HY(tion)YH(")33 0 TN TL()Ec /AF f D(.)EP( + + )0 P(We first examine an appli)HY(ca)HY(tion)YH( that modi)HY(fies)YH( an exist)HY(ing)YH( + object model and seri)HY(al)HY(izes)YH( it back to XML:)EP( + + ) 34 50 PR(#include <iostream> +#include "hello.hxx" + +using namespace std; + +int +main \201int argc, char* argv[]\202 +{ + try + { + auto_ptr<hello_t> h \201hello \201argv[1]\202\202; + + // Change the greeting phrase. + // + h->greeting \201"Hi"\202; + + // Add another entry to the name sequence. + // + h->name \201\202.push_back \201"mars"\202; + + // Serialize the modified object model to XML. + // + xml_schema::namespace_infomap map; + map[""].name = ""; + map[""].schema = "hello.xsd"; + + hello \201cout, *h, map\202; + } + catch \201const xml_schema::exception& e\202 + { + cerr << e << endl;)WR( + return 1; + } +})RP( + + )0 P(First, our appli)HY(ca)HY(tion)YH( parses an XML docu)HY(ment)YH( and obtains its + object model as in the previ)HY(ous)YH( example. Then it changes the + greet)HY(ing)YH( string and adds another entry to the list of names. + Finally, it seri)HY(al)HY(izes)YH( the object model back to XML by calling + the seri)HY(al)HY(iza)HY(tion)YH( func)HY(tion)YH(.)EP( + + )0 P(The first argu)HY(ment)YH( we pass to the seri)HY(al)HY(iza)HY(tion)YH( func)HY(tion)YH( is + )SM(cout)ES( which results in the XML being written to + the stan)HY(dard)YH( output for us to inspect. We could have also + written the result to a file or memory buffer by creat)HY(ing)YH( an + instance of )SM(std::ofstream)ES( or )SM(std::ostringstream)ES( + and passing it instead of )SM(cout)ES(. The second argu)HY(ment)YH( is the + object model we want to seri)HY(al)HY(ize)YH(. The final argu)HY(ment)YH( is an optional + names)HY(pace)YH( infor)HY(ma)HY(tion)YH( map for our vocab)HY(u)HY(lary)YH(. It captures infor)HY(ma)HY(tion)YH( + such as names)HY(paces)YH(, names)HY(pace)YH( prefixes to which they should be mapped, + and schemas asso)HY(ci)HY(ated)YH( with these names)HY(paces)YH(. If we don't provide + this argu)HY(ment)YH( then generic names)HY(pace)YH( prefixes \201)SM(p1)ES(, + )SM(p2)ES(, etc.\202 will be auto)HY(mat)HY(i)HY(cally)YH( assigned to XML names)HY(paces)YH( + and no schema infor)HY(ma)HY(tion)YH( will be added to the result)HY(ing)YH( docu)HY(ment)YH( + \201see )0 33 1 A(Chapter 6, "Seri)HY(al)HY(iza)HY(tion)YH(")33 0 TN TL()Ec /AF f D( for details\202. + In our case, the prefix \201map key\202 and names)HY(pace)YH( name are empty + because our vocab)HY(u)HY(lary)YH( does not use XML names)HY(paces)YH(.)EP( + + )0 P(If we now compile and run this appli)HY(ca)HY(tion)YH( we will see the + output as shown in the follow)HY(ing)YH( listing:)EP( + + ) 12 60 PR(<?xml version="1.0"?> +<hello xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="hello.xsd"> + + <greeting>Hi</greeting> + + <name>sun</name> + <name>moon</name> + <name>world</name> + <name>mars</name> + +</hello>)RP( + + )0 P(We can also create and seri)HY(al)HY(ize)YH( an object model from scratch + as shown in the follow)HY(ing)YH( example:)EP( + + ) 33 43 PR(#include <iostream> +#include <fstream> +#include "hello.hxx" + +using namespace std; + +int +main \201int argc, char* argv[]\202 +{ + try + { + hello_t h \201"Hi"\202; + + hello_t::name_sequence& ns \201h.name \201\202\202; + + ns.push_back \201"Jane"\202; + ns.push_back \201"John"\202; + + // Serialize the object model to XML. + // + xml_schema::namespace_infomap map; + map[""].name = ""; + map[""].schema = "hello.xsd"; + + std::ofstream ofs \201argv[1]\202; + hello \201ofs, h, map\202; + } + catch \201const xml_schema::exception& e\202 + { + cerr << e << endl; + return 1;)WR( + } +})RP( + + )0 P(In this example we used the gener)HY(ated)YH( construc)HY(tor)YH( to create + an instance of type )SM(hello_t)ES(. To reduce typing, + we obtained a refer)HY(ence)YH( to the name sequence which we then + used to add a few names. The seri)HY(al)HY(iza)HY(tion)YH( part is iden)HY(ti)HY(cal)YH( + to the previ)HY(ous)YH( example except this time we are writing to + a file. If we compile and run this program, it produces the + follow)HY(ing)YH( XML file:)EP( + + ) 10 60 PR(<?xml version="1.0"?> +<hello xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="hello.xsd"> + + <greeting>Hi</greeting> + + <name>Jane</name> + <name>John</name> + +</hello>)RP( + + )0 2 12 H(2.6)WB 48 Sn()WB 15 Sn( Select)HY(ing)YH( Naming Conven)HY(tion)YH()EA()EH( + + )0 P(By default XSD uses the so-called K&R \201Kernighan and Ritchie\202 + iden)HY(ti)HY(fier)YH( naming conven)HY(tion)YH( in the gener)HY(ated)YH( code. In this + conven)HY(tion)YH( both type and func)HY(tion)YH( names are in lower case and + words are sepa)HY(rated)YH( by under)HY(scores)YH(. If your appli)HY(ca)HY(tion)YH( code or + schemas use a differ)HY(ent)YH( nota)HY(tion)YH(, you may want to change the + naming conven)HY(tion)YH( used in the gener)HY(ated)YH( code for consis)HY(tency)YH(. + XSD supports a set of widely-used naming conven)HY(tions)YH( + that you can select with the )SM(--type-naming)ES( and + )SM(--func)HY(tion)YH(-naming)ES( options. You can also further + refine one of the prede)HY(fined)YH( conven)HY(tions)YH( or create a completely + custom naming scheme by using the )SM(--*-regex)ES( options.)EP( + + )0 P(As an example, let's assume that our "Hello World" appli)HY(ca)HY(tion)YH( + uses the so-called upper-camel-case naming conven)HY(tion)YH( for types + \201that is, each word in a type name is capi)HY(tal)HY(ized)YH(\202 and the K&R + conven)HY(tion)YH( for func)HY(tion)YH( names. Since K&R is the default + conven)HY(tion)YH( for both type and func)HY(tion)YH( names, we only need to + change the type naming scheme:)EP( + + ) 1 42 PR($ xsd cxx-tree --type-naming ucc hello.xsd)RP( + + )0 P(The )SM(ucc)ES( argu)HY(ment)YH( to the )SM(--type-naming)ES( + options stands for upper-camel-case. If we now examine the + gener)HY(ated)YH( )SM(hello.hxx)ES(, we will see the follow)HY(ing)YH( + changes compared to the decla)HY(ra)HY(tions)YH( shown in the previ)HY(ous)YH( + sections:)EP( + + ) 45 57 PR(class Hello_t +{ +public: + // greeting + // + typedef xml_schema::String GreetingType; + + const GreetingType& + greeting \201\202 const; + + GreetingType& + greeting \201\202; + + void + greeting \201const GreetingType& x\202; + + // name + // + typedef xml_schema::String NameType; + typedef xsd::sequence<NameType> NameSequence; + typedef NameSequence::iterator NameIterator; + typedef NameSequence::const_iterator NameConstIterator; + + const NameSequence& + name \201\202 const; + + NameSequence& + name \201\202; + + void + name \201const NameSequence& s\202;)WR( + + // Constructor. + // + Hello_t \201const GreetingType&\202; + + ... + +}; + +std::auto_ptr<Hello_t> +hello \201const std::string& uri\202; + +std::auto_ptr<Hello_t> +hello \201std::istream&\202;)RP( + + )0 P(Notice that the type names in the )SM(xml_schema)ES( names)HY(pace)YH(, + for example )SM(xml_schema::String)ES(, now also use the + upper-camel-case naming conven)HY(tion)YH(. The only thing that we may + be unhappy about in the above code is the )SM(_t)ES( + suffix in )SM(Hello_t)ES(. If we are not in a posi)HY(tion)YH( + to change the schema, we can )EM(touch-up)ES( the )SM(ucc)ES( + conven)HY(tion)YH( with a custom trans)HY(la)HY(tion)YH( rule using the + )SM(--type-regex)ES( option:)EP( + + ) 1 72 PR($ xsd cxx-tree --type-naming ucc --type-regex '/ \201.+\202_t/\200u$1/' hello.xsd)RP( + + )0 P(This results in the follow)HY(ing)YH( changes to the gener)HY(ated)YH( code:)EP( + + ) 45 57 PR(class Hello +{ +public: + // greeting + // + typedef xml_schema::String GreetingType; + + const GreetingType& + greeting \201\202 const; + + GreetingType& + greeting \201\202; + + void + greeting \201const GreetingType& x\202; + + // name + // + typedef xml_schema::String NameType; + typedef xsd::sequence<NameType> NameSequence; + typedef NameSequence::iterator NameIterator; + typedef NameSequence::const_iterator NameConstIterator; + + const NameSequence& + name \201\202 const; + + NameSequence& + name \201\202; + + void + name \201const NameSequence& s\202;)WR( + + // Constructor. + // + Hello \201const GreetingType&\202; + + ... + +}; + +std::auto_ptr<Hello> +hello \201const std::string& uri\202; + +std::auto_ptr<Hello> +hello \201std::istream&\202;)RP( + + )0 P(For more detailed infor)HY(ma)HY(tion)YH( on the )SM(--type-naming)ES(, + )SM(--func)HY(tion)YH(-naming)ES(, )SM(--type-regex)ES(, and + other )SM(--*-regex)ES( options refer to the NAMING + CONVEN)HY(TION)YH( section in the )R4 2 A(XSD + Compiler Command Line Manual)EA(.)EP( + + )0 2 13 H(2.7)WB 49 Sn()WB 16 Sn( Gener)HY(at)HY(ing)YH( Docu)HY(men)HY(ta)HY(tion)YH()EA()EH( + + )0 P(While our object model is quite simple, real-world vocab)HY(u)HY(lar)HY(ies)YH( + can be quite complex with hundreds of types, elements, and + attributes. For such vocab)HY(u)HY(lar)HY(ies)YH( figur)HY(ing)YH( out which types + provide which member func)HY(tions)YH( by study)HY(ing)YH( the gener)HY(ated)YH( + source code or schemas can be a daunt)HY(ing)YH( task. To provide + appli)HY(ca)HY(tion)YH( devel)HY(op)HY(ers)YH( with a more acces)HY(si)HY(ble)YH( way of + under)HY(stand)HY(ing)YH( the gener)HY(ated)YH( object models, the XSD compiler + can be instructed to produce source code with docu)HY(men)HY(ta)HY(tion)YH( + comments in the Doxygen format. Then the source code can be + processed with the )R8 2 A(Doxygen)EA( + docu)HY(men)HY(ta)HY(tion)YH( system to extract this infor)HY(ma)HY(tion)YH( and produce + docu)HY(men)HY(ta)HY(tion)YH( in various formats. + )EP( + + )0 P(In this section we will see how to gener)HY(ate)YH( docu)HY(men)HY(ta)HY(tion)YH( + for our "Hello World" vocab)HY(u)HY(lary)YH(. To show)HY(case)YH( the full power + of the XSD docu)HY(men)HY(ta)HY(tion)YH( facil)HY(i)HY(ties)YH(, we will first docu)HY(ment)YH( + our schema. The XSD compiler will then trans)HY(fer)YH( + this infor)HY(ma)HY(tion)YH( from the schema to the gener)HY(ated)YH( code and + then to the object model docu)HY(men)HY(ta)HY(tion)YH(. Note that the + docu)HY(men)HY(ta)HY(tion)YH( in the schema is not required for XSD to + gener)HY(ate)YH( useful docu)HY(men)HY(ta)HY(tion)YH(. Below you will find + our )SM(hello.xsd)ES( with added docu)HY(men)HY(ta)HY(tion)YH(:)EP( + + ) 43 69 PR(<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> + + <xs:complexType name="hello_t"> + + <xs:annotation> + <xs:documentation> + The hello_t type consists of a greeting phrase and a + collection of names to which this greeting applies. + </xs:documentation> + </xs:annotation> + + <xs:sequence> + + <xs:element name="greeting" type="xs:string"> + <xs:annotation> + <xs:documentation> + The greeting element contains the greeting phrase + for this hello object. + </xs:documentation> + </xs:annotation> + </xs:element> + + <xs:element name="name" type="xs:string" maxOccurs="unbounded"> + <xs:annotation> + <xs:documentation> + The name elements contains names to be greeted. + </xs:documentation> + </xs:annotation> + </xs:element> + + </xs:sequence>)WR( + </xs:complexType> + + <xs:element name="hello" type="hello_t"> + <xs:annotation> + <xs:documentation> + The hello element is a root of the Hello XML vocabulary. + Every conforming document should start with this element. + </xs:documentation> + </xs:annotation> + </xs:element> + +</xs:schema>)RP( + + )0 P(The first step in obtain)HY(ing)YH( the docu)HY(men)HY(ta)HY(tion)YH( is to recom)HY(pile)YH( + our schema with the )SM(--gener)HY(ate)YH(-doxygen)ES( option:)EP( + + ) 1 68 PR($ xsd cxx-tree --generate-serialization --generate-doxygen hello.xsd)RP( + + )0 P(Now the gener)HY(ated)YH( )SM(hello.hxx)ES( file contains comments + in the Doxygen format. The next step is to process this file + with the Doxygen docu)HY(men)HY(ta)HY(tion)YH( system. If your project does + not use Doxygen then you first need to create a config)HY(u)HY(ra)HY(tion)YH( + file for your project:)EP( + + ) 1 26 PR($ doxygen -g hello.doxygen)RP( + + )0 P(You only need to perform this step once. Now we can gener)HY(ate)YH( + the docu)HY(men)HY(ta)HY(tion)YH( by execut)HY(ing)YH( the follow)HY(ing)YH( command in the + direc)HY(tory)YH( with the gener)HY(ated)YH( source code:)EP( + + ) 1 23 PR($ doxygen hello.doxygen)RP( + + )0 P(While the gener)HY(ated)YH( docu)HY(men)HY(ta)HY(tion)YH( can be useful as is, we can + go one step further and link \201using the Doxygen tags mech)HY(a)HY(nism)YH(\202 + the docu)HY(men)HY(ta)HY(tion)YH( for our object model with the docu)HY(men)HY(ta)HY(tion)YH( + for the XSD runtime library which defines C++ classes for the + built-in XML Schema types. This way we can seam)HY(lessly)YH( browse + between docu)HY(men)HY(ta)HY(tion)YH( for the )SM(hello_t)ES( class which + is gener)HY(ated)YH( by the XSD compiler and the )SM(xml_schema::string)ES( + class which is defined in the XSD runtime library. The Doxygen + config)HY(u)HY(ra)HY(tion)YH( file for the XSD runtime is provided with the XSD + distri)HY(bu)HY(tion)YH(.)EP( + + )0 P(You can view the result of the steps described in this section + on the )R9 2 A(Hello + Example Docu)HY(men)HY(ta)HY(tion)YH()EA( page.)EP( + + + + + )0 1 14 H(3)WB 50 Sn()WB 17 Sn( Overall Mapping Config)HY(u)HY(ra)HY(tion)YH()EA()EH( + + )0 P(The C++/Tree mapping has a number of config)HY(u)HY(ra)HY(tion)YH( param)HY(e)HY(ters)YH( that + deter)HY(mine)YH( the overall prop)HY(er)HY(ties)YH( and behav)HY(ior)YH( of the gener)HY(ated)YH( code. + Config)HY(u)HY(ra)HY(tion)YH( param)HY(e)HY(ters)YH( are spec)HY(i)HY(fied)YH( with the XSD command line + options. This chapter describes config)HY(u)HY(ra)HY(tion)YH( aspects that are most + commonly encoun)HY(tered)YH( by appli)HY(ca)HY(tion)YH( devel)HY(op)HY(ers)YH(. These include: the + C++ stan)HY(dard)YH(, the char)HY(ac)HY(ter)YH( type that is used by the gener)HY(ated)YH( code, + handling of vocab)HY(u)HY(lar)HY(ies)YH( that use XML Schema poly)HY(mor)HY(phism)YH(, XML Schema + to C++ names)HY(pace)YH( mapping, and thread safety. For more ways to config)HY(ure)YH( + the gener)HY(ated)YH( code refer to the + )R4 2 A(XSD + Compiler Command Line Manual)EA(. + )EP( + + )0 2 15 H(3.1)WB 51 Sn()WB 18 Sn( C++ Stan)HY(dard)YH()EA()EH( + + )0 P(The C++/Tree mapping provides support for ISO/IEC C++ 1998/2003 \201C++98\202 + and ISO/IEC C++ 2011 \201C++11\202. To select the C++ stan)HY(dard)YH( for the + gener)HY(ated)YH( code we use the )SM(--std)ES( XSD compiler command + line option. While the major)HY(ity)YH( of the exam)HY(ples)YH( in this guide use + C++98, support for the new func)HY(tion)HY(al)HY(ity)YH( and library compo)HY(nents)YH( + intro)HY(duced)YH( in C++11 are discussed through)HY(out)YH( the docu)HY(ment)YH(.)EP( + + )0 2 16 H(3.2)WB 52 Sn()WB 19 Sn( Char)HY(ac)HY(ter)YH( Type and Encod)HY(ing)YH()EA()EH( + + )0 P(The C++/Tree mapping has built-in support for two char)HY(ac)HY(ter)YH( types: + )SM(char)ES( and )SM(wchar_t)ES(. You can select the + char)HY(ac)HY(ter)YH( type with the )SM(--char-type)ES( command line + option. The default char)HY(ac)HY(ter)YH( type is )SM(char)ES(. The + char)HY(ac)HY(ter)YH( type affects all string and string-based types that + are used in the mapping. These include the string-based built-in + XML Schema types, excep)HY(tion)YH( types, stream types, etc.)EP( + + )0 P(Another aspect of the mapping that depends on the char)HY(ac)HY(ter)YH( type + is char)HY(ac)HY(ter)YH( encod)HY(ing)YH(. For the )SM(char)ES( char)HY(ac)HY(ter)YH( type + the default encod)HY(ing)YH( is UTF-8. Other supported encod)HY(ings)YH( are + ISO-8859-1, Xerces-C++ Local Code Page \201LPC\202, as well as + custom encod)HY(ings)YH(. You can select which encod)HY(ing)YH( should be used + in the object model with the )SM(--char-encod)HY(ing)YH()ES( command + line option.)EP( + + )0 P(For the )SM(wchar_t)ES( char)HY(ac)HY(ter)YH( type the encod)HY(ing)YH( is + auto)HY(mat)HY(i)HY(cally)YH( selected between UTF-16 and UTF-32/UCS-4 depend)HY(ing)YH( + on the size of the )SM(wchar_t)ES( type. On some plat)HY(forms)YH( + \201for example, Windows with Visual C++ and AIX with IBM XL C++\202 + )SM(wchar_t)ES( is 2 bytes long. For these plat)HY(forms)YH( the + encod)HY(ing)YH( is UTF-16. On other plat)HY(forms)YH( )SM(wchar_t)ES( is 4 bytes + long and UTF-32/UCS-4 is used.)EP( + + )0 P(Note also that the char)HY(ac)HY(ter)YH( encod)HY(ing)YH( that is used in the object model + is inde)HY(pen)HY(dent)YH( of the encod)HY(ings)YH( used in input and output XML. In fact, + all three \201object mode, input XML, and output XML\202 can have differ)HY(ent)YH( + encod)HY(ings)YH(.)EP( + + )0 2 17 H(3.3)WB 53 Sn()WB 20 Sn( Support for Poly)HY(mor)HY(phism)YH()EA()EH( + + )0 P(By default XSD gener)HY(ates)YH( non-poly)HY(mor)HY(phic)YH( code. If your vocab)HY(u)HY(lary)YH( + uses XML Schema poly)HY(mor)HY(phism)YH( in the form of )SM(xsi:type)ES( + and/or substi)HY(tu)HY(tion)YH( groups, then you will need to compile + your schemas with the )SM(--gener)HY(ate)YH(-poly)HY(mor)HY(phic)YH()ES( option + to produce poly)HY(mor)HY(phism)YH(-aware code. For more infor)HY(ma)HY(tion)YH( on + working with poly)HY(mor)HY(phic)YH( object models, refer to + )R10 2 A(Section 2.11, + "Mapping for )SM(xsi:type)ES( and Substi)HY(tu)HY(tion)YH( Groups")EA( in + the C++/Tree Mapping User Manual.)EP( + + )0 2 18 H(3.4)WB 54 Sn()WB 21 Sn( Names)HY(pace)YH( Mapping)EA()EH( + + )0 P(XSD maps XML names)HY(paces)YH( spec)HY(i)HY(fied)YH( in the )SM(target)HY(Names)HY(pace)YH()ES( + attribute in XML Schema to one or more nested C++ names)HY(paces)YH(. By + default, a names)HY(pace)YH( URI is mapped to a sequence of C++ names)HY(pace)YH( + names by remov)HY(ing)YH( the proto)HY(col)YH( and host parts and split)HY(ting)YH( the + rest into a sequence of names with )SM('/')ES( as the name + sepa)HY(ra)HY(tor)YH(.)EP( + + )0 P(The default mapping of names)HY(pace)YH( URIs to C++ names)HY(paces)YH( + can be altered using the )SM(--names)HY(pace)YH(-map)ES( and + )SM(--names)HY(pace)YH(-regex)ES( compiler options. For example, + to map names)HY(pace)YH( URI )SM(http://www.codesyn)HY(the)HY(sis)YH(.com/my)ES( to + C++ names)HY(pace)YH( )SM(cs::my)ES(, we can use the follow)HY(ing)YH( option:)EP( + + ) 1 54 PR(--namespace-map http://www.codesynthesis.com/my=cs::my)RP( + + )0 P(A vocab)HY(u)HY(lary)YH( without a names)HY(pace)YH( is mapped to the global scope. This + also can be altered with the above options by using an empty name + for the XML names)HY(pace)YH(:)EP( + + ) 1 19 PR(--namespace-map =cs)RP( + + )0 2 19 H(3.5)WB 55 Sn()WB 22 Sn( Thread Safety)EA()EH( + + )0 P(XSD-gener)HY(ated)YH( code is thread-safe in the sense that you can + use differ)HY(ent)YH( instan)HY(ti)HY(a)HY(tions)YH( of the object model in several + threads concur)HY(rently)YH(. This is possi)HY(ble)YH( due to the gener)HY(ated)YH( + code not relying on any writable global vari)HY(ables)YH(. If you need + to share the same object between several threads then you will + need to provide some form of synchro)HY(niza)HY(tion)YH(. One approach would + be to use the gener)HY(ated)YH( code customiza)HY(tion)YH( mech)HY(a)HY(nisms)YH( to embed + synchro)HY(niza)HY(tion)YH( prim)HY(i)HY(tives)YH( into the gener)HY(ated)YH( C++ classes. For more + infor)HY(ma)HY(tion)YH( on gener)HY(ated)YH( code customiza)HY(tion)YH( refer to the + )R2 2 A(C++/Tree + Mapping Customiza)HY(tion)YH( Guide)EA(.)EP( + + )0 P(If you also would like to call parsing and/or seri)HY(al)HY(iza)HY(tion)YH( + func)HY(tions)YH( from several threads poten)HY(tially)YH( concur)HY(rently)YH(, then + you will need to make sure the Xerces-C++ runtime is initial)HY(ized)YH( + and termi)HY(nated)YH( only once. The easiest way to do this is to + initial)HY(ize)YH(/termi)HY(nate)YH( Xerces-C++ from )SM(main\201\202)ES( when + there are no threads yet/anymore:)EP( + + ) 13 56 PR(#include <xercesc/util/PlatformUtils.hpp> + +int +main \201\202 +{ + xercesc::XMLPlatformUtils::Initialize \201\202; + + { + // Start/terminate threads and parse/serialize here. + } + + xercesc::XMLPlatformUtils::Terminate \201\202; +})RP( + + )0 P(Because you initial)HY(ize)YH( the Xerces-C++ runtime your)HY(self)YH( you should + also pass the )SM(xml_schema::flags::dont_initial)HY(ize)YH()ES( flag + to parsing and seri)HY(al)HY(iza)HY(tion)YH( func)HY(tions)YH(. See )0 30 1 A(Chapter 5, + "Parsing")30 0 TN TL()Ec /AF f D( and )0 33 1 A(Chapter 6, "Seri)HY(al)HY(iza)HY(tion)YH(")33 0 TN TL()Ec /AF f D( for + more infor)HY(ma)HY(tion)YH(.)EP( + + + + + + )0 1 20 H(4)WB 56 Sn()WB 23 Sn( Working with Object Models)EA()EH( + + )0 P(As we have seen in the previ)HY(ous)YH( chap)HY(ters)YH(, the XSD compiler gener)HY(ates)YH( + a C++ class for each type defined in XML Schema. Together these classes + consti)HY(tute)YH( an object model for an XML vocab)HY(u)HY(lary)YH(. In this chapter we + will take a closer look at differ)HY(ent)YH( elements that comprise an + object model class as well as how to create, access, and modify + object models.)EP( + + )0 P(In this and subse)HY(quent)YH( chap)HY(ters)YH( we will use the follow)HY(ing)YH( schema + that describes a collec)HY(tion)YH( of person records. We save it in + )SM(people.xsd)ES(:)EP( + + ) 30 71 PR(<?xml version="1.0"?> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> + + <xs:simpleType name="gender_t"> + <xs:restriction base="xs:string"> + <xs:enumeration value="male"/> + <xs:enumeration value="female"/> + </xs:restriction> + </xs:simpleType> + + <xs:complexType name="person_t"> + <xs:sequence> + <xs:element name="first-name" type="xs:string"/> + <xs:element name="middle-name" type="xs:string" minOccurs="0"/> + <xs:element name="last-name" type="xs:string"/> + <xs:element name="gender" type="gender_t"/> + <xs:element name="age" type="xs:short"/> + </xs:sequence> + <xs:attribute name="id" type="xs:unsignedInt" use="required"/> + </xs:complexType> + + <xs:complexType name="people_t"> + <xs:sequence> + <xs:element name="person" type="person_t" maxOccurs="unbounded"/> + </xs:sequence> + </xs:complexType> + + <xs:element name="people" type="people_t"/> + +</xs:schema>)RP( + + )0 P(A sample XML instance to go along with this schema is saved + in )SM(people.xml)ES(:)EP( + + ) 20 61 PR(<?xml version="1.0"?> +<people xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="people.xsd"> + + <person id="1"> + <first-name>John</first-name> + <last-name>Doe</last-name> + <gender>male</gender> + <age>32</age> + </person> + + <person id="2"> + <first-name>Jane</first-name> + <middle-name>Mary</middle-name> + <last-name>Doe</last-name> + <gender>female</gender> + <age>28</age> + </person> + +</people>)RP( + + )0 P(Compil)HY(ing)YH( )SM(people.xsd)ES( with the XSD compiler results + in three gener)HY(ated)YH( C++ classes: )SM(gender_t)ES(, + )SM(person_t)ES(, and )SM(people_t)ES(. + The )SM(gender_t)ES( class is modelled after the C++ + )SM(enum)ES( type. Its defi)HY(ni)HY(tion)YH( is presented below:)EP( + + ) 17 41 PR(class gender_t: public xml_schema::string +{ +public: + enum value + { + male, + female + }; + + gender_t \201value\202; + gender_t \201const xml_schema::string&\202; + + gender_t& + operator= \201value\202; + + operator value \201\202 const; +};)RP( + + )0 P(The follow)HY(ing)YH( listing shows how we can use this type:)EP( + + ) 19 41 PR(gender_t m \201gender_t::male\202; +gender_t f \201"female"\202; + +if \201m == "female" || f == gender_t::male\202 +{ + ... +} + +switch \201m\202 +{ +case gender_t::male: + { + ... + } +case gender_t::female: + { + ... + } +})RP( + + )0 P(The other two classes will be exam)HY(ined)YH( in detail in the subse)HY(quent)YH( + sections.)EP( + + )0 2 21 H(4.1)WB 57 Sn()WB 24 Sn( Attribute and Element Cardi)HY(nal)HY(i)HY(ties)YH()EA()EH( + + )0 P(As we have seen in the previ)HY(ous)YH( chap)HY(ters)YH(, XSD gener)HY(ates)YH( a differ)HY(ent)YH( + set of type defi)HY(ni)HY(tions)YH( and member func)HY(tions)YH( for elements with + differ)HY(ent)YH( cardi)HY(nal)HY(i)HY(ties)YH(. The C++/Tree mapping divides all the possi)HY(ble)YH( + element and attribute cardi)HY(nal)HY(i)HY(ties)YH( into three cardi)HY(nal)HY(ity)YH( classes: + )EM(one)ES(, )EM(optional)ES(, and )EM(sequence)ES(.)EP( + + )0 P(The )EM(one)ES( cardi)HY(nal)HY(ity)YH( class covers all elements that should + occur exactly once as well as required attributes. In our + example, the )SM(first-name)ES(, )SM(last-name)ES(, + )SM(gender)ES(, and )SM(age)ES( elements as well as + the )SM(id)ES( attribute belong to this cardi)HY(nal)HY(ity)YH( class. + The follow)HY(ing)YH( code frag)HY(ment)YH( shows type defi)HY(ni)HY(tions)YH( as well as the + acces)HY(sor)YH( and modi)HY(fier)YH( func)HY(tions)YH( that are gener)HY(ated)YH( for the + )SM(gender)ES( element in the )SM(person_t)ES( class:)EP( + + ) 15 31 PR(class person_t +{ + // gender + // + typedef gender_t gender_type; + + const gender_type& + gender \201\202 const; + + gender_type& + gender \201\202; + + void + gender \201const gender_type&\202; +};)RP( + + )0 P(The )SM(gender_type)ES( type is an alias for the element's type. + The first two acces)HY(sor)YH( func)HY(tions)YH( return read-only \201constant\202 and + read-write refer)HY(ences)YH( to the element's value, respec)HY(tively)YH(. The + modi)HY(fier)YH( func)HY(tion)YH( sets the new value for the element.)EP( + + )0 P(The )EM(optional)ES( cardi)HY(nal)HY(ity)YH( class covers all elements that + can occur zero or one time as well as optional attributes. In our + example, the )SM(middle-name)ES( element belongs to this + cardi)HY(nal)HY(ity)YH( class. The follow)HY(ing)YH( code frag)HY(ment)YH( shows the type + defi)HY(ni)HY(tions)YH( as well as the acces)HY(sor)YH( and modi)HY(fier)YH( func)HY(tions)YH( that + are gener)HY(ated)YH( for this element in the )SM(person_t)ES( class:)EP( + + ) 19 63 PR(class person_t +{ + // middle-name + // + typedef xml_schema::string middle_name_type; + typedef xsd::optional<middle_name_type> middle_name_optional; + + const middle_name_optional& + middle_name \201\202 const; + + middle_name_optional& + middle_name \201\202; + + void + middle_name \201const middle_name_type&\202; + + void + middle_name \201const middle_name_optional&\202; +};)RP( + + )0 P(As with the )SM(gender)ES( element, )SM(middle_name_type)ES( + is an alias for the element's type. The )SM(middle_name_optional)ES( + type is a container for the element's optional value. It can be queried + for the pres)HY(ence)YH( of the value using the )SM(present\201\202)ES( func)HY(tion)YH(. + The value itself can be retrieved using the )SM(get\201\202)ES( + acces)HY(sor)YH( and set using the )SM(set\201\202)ES( modi)HY(fier)YH(. The container + can be reverted to the value not present state with the call to the + )SM(reset\201\202)ES( func)HY(tion)YH(. The follow)HY(ing)YH( example shows how we + can use this container:)EP( + + ) 9 42 PR(person_t::middle_name_optional n \201"John"\202; + +if \201n.present \201\202\202 +{ + cout << n.get \201\202 << endl; +} + +n.set \201"Jane"\202; +n.reset \201\202;)RP( + + + )0 P(Unlike the )EM(one)ES( cardi)HY(nal)HY(ity)YH( class, the acces)HY(sor)YH( func)HY(tions)YH( + for the )EM(optional)ES( class return read-only \201constant\202 and + read-write refer)HY(ences)YH( to the container instead of the element's + value directly. The modi)HY(fier)YH( func)HY(tions)YH( set the new value for the + element.)EP( + + )0 P(Finally, the )EM(sequence)ES( cardi)HY(nal)HY(ity)YH( class covers all elements + that can occur more than once. In our example, the + )SM(person)ES( element in the )SM(people_t)ES( type + belongs to this cardi)HY(nal)HY(ity)YH( class. The follow)HY(ing)YH( code frag)HY(ment)YH( shows + the type defi)HY(ni)HY(tions)YH( as well as the acces)HY(sor)YH( and modi)HY(fier)YH( func)HY(tions)YH( + that are gener)HY(ated)YH( for this element in the )SM(people_t)ES( + class:)EP( + + ) 18 64 PR(class people_t +{ + // person + // + typedef person_t person_type; + typedef xsd::sequence<person_type> person_sequence; + typedef person_sequence::iterator person_iterator; + typedef person_sequence::const_iterator person_const_iterator; + + const person_sequence& + person \201\202 const; + + person_sequence& + person \201\202; + + void + person \201const person_sequence&\202; +};)RP( + + )0 P(Iden)HY(ti)HY(cal)YH( to the other cardi)HY(nal)HY(ity)YH( classes, )SM(person_type)ES( + is an alias for the element's type. The )SM(person_sequence)ES( + type is a sequence container for the element's values. It is based + on and has the same inter)HY(face)YH( as )SM(std::vector)ES( and + there)HY(fore)YH( can be used in similar ways. The )SM(person_iter)HY(a)HY(tor)YH()ES( + and )SM(person_const_iter)HY(a)HY(tor)YH()ES( types are read-only + \201constant\202 and read-write iter)HY(a)HY(tors)YH( for the )SM(person_sequence)ES( + container.)EP( + + )0 P(Similar to the )EM(optional)ES( cardi)HY(nal)HY(ity)YH( class, the + acces)HY(sor)YH( func)HY(tions)YH( for the )EM(sequence)ES( class return + read-only \201constant\202 and read-write refer)HY(ences)YH( to the sequence + container. The modi)HY(fier)YH( func)HY(tions)YH( copies the entries from + the passed sequence.)EP( + + )0 P(C++/Tree is a "flat)HY(ten)HY(ing)YH(" mapping in a sense that many levels of + nested compos)HY(i)HY(tors)YH( \201)SM(choice)ES( and )SM(sequence)ES(\202, + all poten)HY(tially)YH( with their own cardi)HY(nal)HY(i)HY(ties)YH(, are in the end mapped + to a flat set of elements with one of the three cardi)HY(nal)HY(ity)YH( classes + discussed above. While this results in a simple and easy to use API + for most types, in certain cases, the order of elements in the actual + XML docu)HY(ments)YH( is not preserved once parsed into the object model. To + over)HY(come)YH( this limi)HY(ta)HY(tion)YH( we can mark certain schema types, for which + content order is not suffi)HY(ciently)YH( preserved, as ordered. For more + infor)HY(ma)HY(tion)YH( on this func)HY(tion)HY(al)HY(ity)YH( refer to + )R11 2 A(Section + 2.8.4, "Element Order")EA( in the C++/Tree Mapping User Manual.)EP( + + )0 P(For complex schemas with many levels of nested compos)HY(i)HY(tors)YH( + \201)SM(choice)ES( and )SM(sequence)ES(\202 it can also + be hard to deduce the cardi)HY(nal)HY(ity)YH( class of a partic)HY(u)HY(lar)YH( element. + The gener)HY(ated)YH( Doxygen docu)HY(men)HY(ta)HY(tion)YH( can greatly help with + this task. For each element and attribute the docu)HY(men)HY(ta)HY(tion)YH( + clearly iden)HY(ti)HY(fies)YH( its cardi)HY(nal)HY(ity)YH( class. Alter)HY(na)HY(tively)YH(, you + can study the gener)HY(ated)YH( header files to find out the cardi)HY(nal)HY(ity)YH( + class of a partic)HY(u)HY(lar)YH( attribute or element.)EP( + + )0 P(In the next sections we will examine how to access and modify + infor)HY(ma)HY(tion)YH( stored in an object model using acces)HY(sor)YH( and modi)HY(fier)YH( + func)HY(tions)YH( described in this section.)EP( + + )0 2 22 H(4.2)WB 58 Sn()WB 25 Sn( Access)HY(ing)YH( the Object Model)EA()EH( + + )0 P(In this section we will learn how to get to the infor)HY(ma)HY(tion)YH( + stored in the object model for our person records vocab)HY(u)HY(lary)YH(. + The follow)HY(ing)YH( appli)HY(ca)HY(tion)YH( accesses and prints the contents + of the )SM(people.xml)ES( file:)EP( + + ) 36 70 PR(#include <iostream> +#include "people.hxx" + +using namespace std; + +int +main \201\202 +{ + auto_ptr<people_t> ppl \201people \201"people.xml"\202\202; + + // Iterate over individual person records. + // + people_t::person_sequence& ps \201ppl->person \201\202\202; + + for \201people_t::person_iterator i \201ps.begin \201\202\202; i != ps.end \201\202; ++i\202 + { + person_t& p \201*i\202; + + // Print names: first-name and last-name are required elements, + // middle-name is optional. + // + cout << "name: " << p.first_name \201\202 << " "; + + if \201p.middle_name \201\202.present \201\202\202 + cout << p.middle_name \201\202.get \201\202 << " "; + + cout << p.last_name \201\202 << endl; + + // Print gender, age, and id which are all required. + // + cout << "gender: " << p.gender \201\202 << endl)WR( + << "age: " << p.age \201\202 << endl + << "id: " << p.id \201\202 << endl + << endl; + } +})RP( + + )0 P(This code shows common patterns of access)HY(ing)YH( elements and attributes + with differ)HY(ent)YH( cardi)HY(nal)HY(ity)YH( classes. For the sequence element + \201)SM(person)ES( in )SM(people_t)ES(\202 we first obtain a + refer)HY(ence)YH( to the container and then iterate over indi)HY(vid)HY(ual)YH( + records. The values of elements and attributes with the + )EM(one)ES( cardi)HY(nal)HY(ity)YH( class \201)SM(first-name)ES(, + )SM(last-name)ES(, )SM(gender)ES(, )SM(age)ES(, + and )SM(id)ES(\202 can be obtained directly by calling the + corre)HY(spond)HY(ing)YH( acces)HY(sor)YH( func)HY(tions)YH(. For the optional element + )SM(middle-name)ES( we first check if the value is present + and only then call )SM(get\201\202)ES( to retrieve it.)EP( + + )0 P(Note that when we want to reduce typing by creat)HY(ing)YH( a vari)HY(able)YH( + repre)HY(sent)HY(ing)YH( a frag)HY(ment)YH( of the object model that we are currently + working with \201)SM(ps)ES( and )SM(p)ES( above\202, we obtain + a refer)HY(ence)YH( to that frag)HY(ment)YH( instead of making a poten)HY(tially)YH( + expen)HY(sive)YH( copy. This is gener)HY(ally)YH( a good rule to follow when + creat)HY(ing)YH( high-perfor)HY(mance)YH( appli)HY(ca)HY(tions)YH(.)EP( + + )0 P(If we run the above appli)HY(ca)HY(tion)YH( on our sample + )SM(people.xml)ES(, the output looks as follows:)EP( + + ) 9 21 PR(name: John Doe +gender: male +age: 32 +id: 1 + +name: Jane Mary Doe +gender: female +age: 28 +id: 2)RP( + + + )0 2 23 H(4.3)WB 59 Sn()WB 26 Sn( Modi)HY(fy)HY(ing)YH( the Object Model)EA()EH( + + )0 P(In this section we will learn how to modify the infor)HY(ma)HY(tion)YH( + stored in the object model for our person records vocab)HY(u)HY(lary)YH(. + The follow)HY(ing)YH( appli)HY(ca)HY(tion)YH( changes the contents of the + )SM(people.xml)ES( file:)EP( + + ) 43 70 PR(#include <iostream> +#include "people.hxx" + +using namespace std; + +int +main \201\202 +{ + auto_ptr<people_t> ppl \201people \201"people.xml"\202\202; + + // Iterate over individual person records and increment + // the age. + // + people_t::person_sequence& ps \201ppl->person \201\202\202; + + for \201people_t::person_iterator i \201ps.begin \201\202\202; i != ps.end \201\202; ++i\202 + { + // Alternative way: i->age \201\202++; + // + i->age \201i->age \201\202 + 1\202; + } + + // Add middle-name to the first record and remove it from + // the second. + // + person_t& john \201ps[0]\202; + person_t& jane \201ps[1]\202; + + john.middle_name \201"Mary"\202; + jane.middle_name \201\202.reset \201\202; +)WR( + // Add another John record. + // + ps.push_back \201john\202; + + // Serialize the modified object model to XML. + // + xml_schema::namespace_infomap map; + map[""].name = ""; + map[""].schema = "people.xsd"; + + people \201cout, *ppl, map\202; +})RP( + + )0 P(The first modi)HY(fi)HY(ca)HY(tion)YH( the above appli)HY(ca)HY(tion)YH( performs is iter)HY(at)HY(ing)YH( + over person records and incre)HY(ment)HY(ing)YH( the age value. This code + frag)HY(ment)YH( shows how to modify the value of a required attribute + or element. The next modi)HY(fi)HY(ca)HY(tion)YH( shows how to set a new value + for the optional )SM(middle-name)ES( element as well + as clear its value. Finally the example adds a copy of the + John Doe record to the )SM(person)ES( element sequence.)EP( + + )0 P(Note that in this case using refer)HY(ences)YH( for the )SM(ps)ES(, + )SM(john)ES(, and )SM(jane)ES( vari)HY(ables)YH( is no longer + a perfor)HY(mance)YH( improve)HY(ment)YH( but a require)HY(ment)YH( for the appli)HY(ca)HY(tion)YH( + to func)HY(tion)YH( correctly. If we hadn't used refer)HY(ences)YH(, all our changes + would have been made on copies without affect)HY(ing)YH( the object model.)EP( + + )0 P(If we run the above appli)HY(ca)HY(tion)YH( on our sample )SM(people.xml)ES(, + the output looks as follows:)EP( + + ) 28 61 PR(<?xml version="1.0"?> +<people xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="people.xsd"> + + <person id="1"> + <first-name>John</first-name> + <middle-name>Mary</middle-name> + <last-name>Doe</last-name> + <gender>male</gender> + <age>33</age> + </person> + + <person id="2"> + <first-name>Jane</first-name> + <last-name>Doe</last-name> + <gender>female</gender> + <age>29</age> + </person> + + <person id="1"> + <first-name>John</first-name> + <middle-name>Mary</middle-name> + <last-name>Doe</last-name> + <gender>male</gender> + <age>33</age> + </person> + +</people>)RP( + + + )0 2 24 H(4.4)WB 60 Sn()WB 27 Sn( Creat)HY(ing)YH( the Object Model from Scratch)EA()EH( + + )0 P(In this section we will learn how to create a new object model + for our person records vocab)HY(u)HY(lary)YH(. The follow)HY(ing)YH( appli)HY(ca)HY(tion)YH( + recre)HY(ates)YH( the content of the orig)HY(i)HY(nal)YH( )SM(people.xml)ES( + file:)EP( + + ) 42 48 PR(#include <iostream> +#include "people.hxx" + +using namespace std; + +int +main \201\202 +{ + people_t ppl; + people_t::person_sequence& ps \201ppl.person \201\202\202; + + // Add the John Doe record. + // + ps.push_back \201 + person_t \201"John", // first-name + "Doe", // last-name + gender_t::male, // gender + 32, // age + 1\202\202; + + // Add the Jane Doe record. + // + ps.push_back \201 + person_t \201"Jane", // first-name + "Doe", // last-name + gender_t::female, // gender + 28, // age + 2\202\202; // id + + // Add middle name to the Jane Doe record. + //)WR( + person_t& jane \201ps.back \201\202\202; + jane.middle_name \201"Mary"\202; + + // Serialize the object model to XML. + // + xml_schema::namespace_infomap map; + map[""].name = ""; + map[""].schema = "people.xsd"; + + people \201cout, ppl, map\202; +})RP( + + )0 P(The only new part in the above appli)HY(ca)HY(tion)YH( is the calls + to the )SM(people_t)ES( and )SM(person_t)ES( + construc)HY(tors)YH(. As a general rule, for each C++ class + XSD gener)HY(ates)YH( a construc)HY(tor)YH( with initial)HY(iz)HY(ers)YH( + for each element and attribute belong)HY(ing)YH( to the )EM(one)ES( + cardi)HY(nal)HY(ity)YH( class. For our vocab)HY(u)HY(lary)YH(, the follow)HY(ing)YH( + construc)HY(tors)YH( are gener)HY(ated)YH(:)EP( + + ) 13 35 PR(class person_t +{ + person_t \201const first_name_type&, + const last_name_type&, + const gender_type&, + const age_type&, + const id_type&\202; +}; + +class people_t +{ + people_t \201\202; +};)RP( + + )0 P(Note also that we set the )SM(middle-name)ES( element + on the Jane Doe record by obtain)HY(ing)YH( a refer)HY(ence)YH( to that record + in the object model and setting the )SM(middle-name)ES( + value on it. This is a general rule that should be followed + in order to obtain the best perfor)HY(mance)YH(: if possi)HY(ble)YH(, + direct modi)HY(fi)HY(ca)HY(tions)YH( to the object model should be preferred + to modi)HY(fi)HY(ca)HY(tions)YH( on tempo)HY(raries)YH( with subse)HY(quent)YH( copying. The + follow)HY(ing)YH( code frag)HY(ment)YH( shows a seman)HY(ti)HY(cally)YH( equiv)HY(a)HY(lent)YH( but + slightly slower version:)EP( + + ) 11 46 PR(// Add the Jane Doe record. +// +person_t jane \201"Jane", // first-name + "Doe", // last-name + gender_t::female, // gender + 28, // age + 2\202; // id + +jane.middle_name \201"Mary"\202; + +ps.push_back \201jane\202;)RP( + + )0 P(We can also go one step further to reduce copying and improve + the perfor)HY(mance)YH( of our appli)HY(ca)HY(tion)YH( by using the non-copying + )SM(push_back\201\202)ES( func)HY(tion)YH( which assumes owner)HY(ship)YH( + of the passed objects:)EP( + + ) 19 55 PR(// Add the John Doe record. C++98 version. +// +auto_ptr<person_t> john_p \201 + new person_t \201"John", // first-name + "Doe", // last-name + gender_t::male, // gender + 32, // age + 1\202\202; +ps.push_back \201john_p\202; // assumes ownership + +// Add the Jane Doe record. C++11 version +// +unique_ptr<person_t> jane_p \201 + new person_t \201"Jane", // first-name + "Doe", // last-name + gender_t::female, // gender + 28, // age + 2\202\202; // id +ps.push_back \201std::move \201jane_p\202\202; // assumes ownership)RP( + + )0 P(For more infor)HY(ma)HY(tion)YH( on the non-copying modi)HY(fier)YH( func)HY(tions)YH( refer to + )R12 2 A(Section + 2.8, "Mapping for Local Elements and Attributes")EA( in the C++/Tree Mapping + User Manual. The above appli)HY(ca)HY(tion)YH( produces the follow)HY(ing)YH( output:)EP( + + ) 20 61 PR(<?xml version="1.0" ?> +<people xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="people.xsd"> + + <person id="1"> + <first-name>John</first-name> + <last-name>Doe</last-name> + <gender>male</gender> + <age>32</age> + </person> + + <person id="2"> + <first-name>Jane</first-name> + <middle-name>Mary</middle-name> + <last-name>Doe</last-name> + <gender>female</gender> + <age>28</age> + </person> + +</people>)RP( + + )0 2 25 H(4.5)WB 61 Sn()WB 28 Sn( Mapping for the Built-in XML Schema Types)EA()EH( + + )0 P(Our person record vocab)HY(u)HY(lary)YH( uses several built-in XML Schema + types: )SM(string)ES(, )SM(short)ES(, and + )SM(unsignedInt)ES(. Until now we haven't talked about + the mapping of built-in XML Schema types to C++ types and how + to work with them. This section provides an overview + of the built-in types. For more detailed infor)HY(ma)HY(tion)YH( refer + to )R13 2 A(Section + 2.5, "Mapping for Built-in Data Types")EA( in the C++/Tree Mapping + User Manual.)EP( + + )0 P(In XML Schema, built-in types are defined in the XML Schema names)HY(pace)YH(. + By default, the C++/Tree mapping maps this names)HY(pace)YH( to C++ + names)HY(pace)YH( )SM(xml_schema)ES( \201this mapping can be altered + with the )SM(--names)HY(pace)YH(-map)ES( option\202. The follow)HY(ing)YH( table + summa)HY(rizes)YH( the mapping of XML Schema built-in types to C++ types:)EP( + + + )0 PT( + + )0 P(As you can see from the table above a number of built-in + XML Schema types are mapped to funda)HY(men)HY(tal)YH( C++ types such + as )SM(int)ES( or )SM(bool)ES(. All string-based + XML Schema types are mapped to C++ types that are derived + from either )SM(std::string)ES( or + )SM(std::wstring)ES(, depend)HY(ing)YH( on the char)HY(ac)HY(ter)YH( + type selected. For access and modi)HY(fi)HY(ca)HY(tion)YH( purposes these + types can be treated as )SM(std::string)ES(. A number + of built-in types, such as )SM(qname)ES(, the binary + types, and the date/time types do not have suit)HY(able)YH( + funda)HY(men)HY(tal)YH( or stan)HY(dard)YH( C++ types to map to. As a result, + these types are imple)HY(mented)YH( from scratch in the XSD runtime. + For more infor)HY(ma)HY(tion)YH( on their inter)HY(faces)YH( refer to + )R13 2 A(Section + 2.5, "Mapping for Built-in Data Types")EA( in the C++/Tree Mapping + User Manual.)EP( + + + + + + )0 1 26 H(5)WB 62 Sn()WB 30 Sn( Parsing)EA()EH( + + )0 P(We have already seen how to parse XML to an object model in this guide + before. In this chapter we will discuss the parsing topic in more + detail.)EP( + + )0 P(By default, the C++/Tree mapping provides a total of 14 over)HY(loaded)YH( + parsing func)HY(tions)YH(. They differ in the input methods used to + read XML as well as the error report)HY(ing)YH( mech)HY(a)HY(nisms)YH(. It is also possi)HY(ble)YH( + to gener)HY(ate)YH( types for root elements instead of parsing and seri)HY(al)HY(iza)HY(tion)YH( + func)HY(tions)YH(. This may be useful if your XML vocab)HY(u)HY(lary)YH( has multi)HY(ple)YH( + root elements. For more infor)HY(ma)HY(tion)YH( on element types refer to + )R14 2 A(Section + 2.9, "Mapping for Global Elements")EA( in the C++/Tree Mapping User + Manual.)EP( + + + )0 P(In this section we will discuss the most commonly used versions of + the parsing func)HY(tions)YH(. For a compre)HY(hen)HY(sive)YH( descrip)HY(tion)YH( of parsing + refer to )R15 2 A(Chapter + 3, "Parsing")EA( in the C++/Tree Mapping User Manual. For the )SM(people)ES( + global element from our person record vocab)HY(u)HY(lary)YH(, we will concen)HY(trate)YH( + on the follow)HY(ing)YH( three parsing func)HY(tions)YH(:)EP( + + ) 15 71 PR(std::[auto|unique]_ptr<people_t> +people \201const std::string& uri, + xml_schema::flags f = 0, + const xml_schema::properties& p = xml_schema::properties \201\202\202; + +std::[auto|unique]_ptr<people_t> +people \201std::istream& is, + xml_schema::flags f = 0, + const xml_schema::properties& p = xml_schema::properties \201\202\202; + +std::[auto|unique]_ptr<people_t> +people \201std::istream& is, + const std::string& resource_id, + xml_schema::flags f = 0, + const xml_schema::properties& p = ::xml_schema::properties \201\202\202;)RP( + + )0 P(The first func)HY(tion)YH( parses a local file or a URI. We have already + used this parsing func)HY(tion)YH( in the previ)HY(ous)YH( chap)HY(ters)YH(. The second + and third func)HY(tions)YH( read XML from a stan)HY(dard)YH( input stream. The + last func)HY(tion)YH( also requires a resource id. This id is used to + iden)HY(tify)YH( the XML docu)HY(ment)YH( being parser in diag)HY(nos)HY(tics)YH( messages + as well as to resolve rela)HY(tive)YH( paths to other docu)HY(ments)YH( \201for example, + schemas\202 that might be refer)HY(enced)YH( from the XML docu)HY(ment)YH(.)EP( + + )0 P(The last two argu)HY(ments)YH( to all three parsing func)HY(tions)YH( are parsing + flags and prop)HY(er)HY(ties)YH(. The flags argu)HY(ment)YH( provides a number of ways + to fine-tune the parsing process. The prop)HY(er)HY(ties)YH( argu)HY(ment)YH( allows + to pass addi)HY(tional)YH( infor)HY(ma)HY(tion)YH( to the parsing func)HY(tions)YH(. We will + use these two argu)HY(ments)YH( in )0 31 1 A(Section 5.1, "XML Schema + Vali)HY(da)HY(tion)YH( and Search)HY(ing)YH(")31 0 TN TL()Ec /AF f D( below. All three func)HY(tions)YH( return + the object model as either )SM(std::auto_ptr)ES( \201C++98\202 or + )SM(std::unique_ptr)ES( \201C++11\202, depend)HY(ing)YH( on the C++ stan)HY(dard)YH( + selected \201)SM(--std)ES( XSD compiler option\202. The follow)HY(ing)YH( + example shows how we can use the above parsing func)HY(tions)YH(:)EP( + + ) 17 65 PR(using std::auto_ptr; + +// Parse a local file or URI. +// +auto_ptr<people_t> p1 \201people \201"people.xml"\202\202; +auto_ptr<people_t> p2 \201people \201"http://example.com/people.xml"\202\202; + +// Parse a local file via ifstream. +// +std::ifstream ifs \201"people.xml"\202; +auto_ptr<people_t> p3 \201people \201ifs, "people.xml"\202\202; + +// Parse an XML string. +// +std::string str \201"..."\202; // XML in a string. +std::istringstream iss \201str\202; +auto_ptr<people_t> p4 \201people \201iss\202\202;)RP( + + + )0 2 27 H(5.1)WB 63 Sn()WB 31 Sn( XML Schema Vali)HY(da)HY(tion)YH( and Search)HY(ing)YH()EA()EH( + + )0 P(The C++/Tree mapping relies on the under)HY(ly)HY(ing)YH( Xerces-C++ XML + parser for full XML docu)HY(ment)YH( vali)HY(da)HY(tion)YH(. The XML Schema + vali)HY(da)HY(tion)YH( is enabled by default and can be disabled by + passing the )SM(xml_schema::flags::dont_vali)HY(date)YH()ES( + flag to the parsing func)HY(tions)YH(, for example:)EP( + + ) 2 59 PR(auto_ptr<people_t> p \201 + people \201"people.xml", xml_schema::flags::dont_validate\202\202;)RP( + + )0 P(Even when XML Schema vali)HY(da)HY(tion)YH( is disabled, the gener)HY(ated)YH( + code still performs a number of checks to prevent + construc)HY(tion)YH( of an incon)HY(sis)HY(tent)YH( object model \201for example, an + object model with missing required attributes or elements\202.)EP( + + )0 P(When XML Schema vali)HY(da)HY(tion)YH( is enabled, the XML parser needs + to locate a schema to vali)HY(date)YH( against. There are several + methods to provide the schema loca)HY(tion)YH( infor)HY(ma)HY(tion)YH( to the + parser. The easiest and most commonly used method is to + specify schema loca)HY(tions)YH( in the XML docu)HY(ment)YH( itself + with the )SM(schemaLo)HY(ca)HY(tion)YH()ES( or + )SM(noNames)HY(paceSchemaLo)HY(ca)HY(tion)YH()ES( attributes, for example:)EP( + + ) 4 74 PR(<?xml version="1.0" ?> +<people xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="people.xsd" + xsi:schemaLocation="http://www.w3.org/XML/1998/namespace xml.xsd">)RP( + + )0 P(As you might have noticed, we used this method in all the sample XML + docu)HY(ments)YH( presented in this guide up until now. Note that the + schema loca)HY(tions)YH( spec)HY(i)HY(fied)YH( with these two attributes are rela)HY(tive)YH( + to the docu)HY(ment)YH('s path unless they are abso)HY(lute)YH( URIs \201that is + start with )SM(http://)ES(, )SM(file://)ES(, etc.\202. + In partic)HY(u)HY(lar)YH(, if you specify just file names as your schema + loca)HY(tions)YH(, as we did above, then the schemas should reside in + the same direc)HY(tory)YH( as the XML docu)HY(ment)YH( itself.)EP( + + )0 P(Another method of provid)HY(ing)YH( the schema loca)HY(tion)YH( infor)HY(ma)HY(tion)YH( + is via the )SM(xml_schema::prop)HY(er)HY(ties)YH()ES( argu)HY(ment)YH(, as + shown in the follow)HY(ing)YH( example:)EP( + + ) 5 74 PR(xml_schema::properties props; +props.no_namespace_schema_location \201"people.xsd"\202; +props.schema_location \201"http://www.w3.org/XML/1998/namespace", "xml.xsd"\202; + +auto_ptr<people_t> p \201people \201"people.xml", 0, props\202\202;)RP( + + )0 P(The schema loca)HY(tions)YH( provided with this method over)HY(rides)YH( + those spec)HY(i)HY(fied)YH( in the XML docu)HY(ment)YH(. As with the previ)HY(ous)YH( + method, the schema loca)HY(tions)YH( spec)HY(i)HY(fied)YH( this way are + rela)HY(tive)YH( to the docu)HY(ment)YH('s path unless they are abso)HY(lute)YH( URIs. + In partic)HY(u)HY(lar)YH(, if you want to use local schemas that are + not related to the docu)HY(ment)YH( being parsed, then you will + need to use the )SM(file://)ES( URI. The follow)HY(ing)YH( + example shows how to use schemas that reside in the current + working direc)HY(tory)YH(:)EP( + + ) 19 55 PR(#include <unistd.h> // getcwd +#include <limits.h> // PATH_MAX + +char cwd[PATH_MAX]; +if \201getcwd \201cwd, PATH_MAX\202 == 0\202 +{ + // Buffer too small? +} + +xml_schema::properties props; + +props.no_namespace_schema_location \201 + "file:///" + std::string \201cwd\202 + "/people.xsd"\202; + +props.schema_location \201 + "http://www.w3.org/XML/1998/namespace", + "file:///" + std::string \201cwd\202 + "/xml.xsd"\202; + +auto_ptr<people_t> p \201people \201"people.xml", 0, props\202\202;)RP( + + )0 P(A third method is the most useful if you are plan)HY(ning)YH( to parse + several XML docu)HY(ments)YH( of the same vocab)HY(u)HY(lary)YH(. In that case + it may be bene)HY(fi)HY(cial)YH( to pre-parse and cache the schemas in + the XML parser which can then be used to parse all docu)HY(ments)YH( + without re-parsing the schemas. For more infor)HY(ma)HY(tion)YH( on + this method refer to the )SM(caching)ES( example in the + )SM(exam)HY(ples)YH(/cxx/tree/)ES( direc)HY(tory)YH( of the XSD + distri)HY(bu)HY(tion)YH(. It is also possi)HY(ble)YH( to convert the schemas into + a pre-compiled binary repre)HY(sen)HY(ta)HY(tion)YH( and embed this repre)HY(sen)HY(ta)HY(tion)YH( + directly into the appli)HY(ca)HY(tion)YH( executable. With this approach your + appli)HY(ca)HY(tion)YH( can perform XML Schema vali)HY(da)HY(tion)YH( without depend)HY(ing)YH( on + any exter)HY(nal)YH( schema files. For more infor)HY(ma)HY(tion)YH( on how to achieve + this refer to the )SM(embed)HY(ded)YH()ES( example in the + )SM(exam)HY(ples)YH(/cxx/tree/)ES( direc)HY(tory)YH( of the XSD distri)HY(bu)HY(tion)YH(.)EP( + + )0 P(When the XML parser cannot locate a schema for the + XML docu)HY(ment)YH(, the vali)HY(da)HY(tion)YH( fails and XML docu)HY(ment)YH( + elements and attributes for which schema defi)HY(ni)HY(tions)YH( could + not be located are reported in the diag)HY(nos)HY(tics)YH(. For + example, if we remove the )SM(noNames)HY(paceSchemaLo)HY(ca)HY(tion)YH()ES( + attribute in )SM(people.xml)ES( from the previ)HY(ous)YH( chapter, + then we will get the follow)HY(ing)YH( diag)HY(nos)HY(tics)YH( if we try to parse + this file with vali)HY(da)HY(tion)YH( enabled:)EP( + + ) 8 74 PR(people.xml:2:63 error: no declaration found for element 'people' +people.xml:4:18 error: no declaration found for element 'person' +people.xml:4:18 error: attribute 'id' is not declared for element 'person' +people.xml:5:17 error: no declaration found for element 'first-name' +people.xml:6:18 error: no declaration found for element 'middle-name' +people.xml:7:16 error: no declaration found for element 'last-name' +people.xml:8:13 error: no declaration found for element 'gender' +people.xml:9:10 error: no declaration found for element 'age')RP( + + )0 2 28 H(5.2)WB 64 Sn()WB 32 Sn( Error Handling)EA()EH( + + )0 P(The parsing func)HY(tions)YH( offer a number of ways to handle error condi)HY(tions)YH( + with the C++ excep)HY(tions)YH( being the most commonly used mech)HY(a)HY(nism)YH(. All + C++/Tree excep)HY(tions)YH( derive from common base )SM(xml_schema::excep)HY(tion)YH()ES( + which in turn derives from )SM(std::excep)HY(tion)YH()ES(. The easiest + way to uniformly handle all possi)HY(ble)YH( C++/Tree excep)HY(tions)YH( and print + detailed infor)HY(ma)HY(tion)YH( about the error is to catch and print + )SM(xml_schema::excep)HY(tion)YH()ES(, as shown in the follow)HY(ing)YH( + example:)EP( + + ) 8 47 PR(try +{ + auto_ptr<people_t> p \201people \201"people.xml"\202\202; +} +catch \201const xml_schema::exception& e\202 +{ + cerr << e << endl; +})RP( + + )0 P(Each indi)HY(vid)HY(ual)YH( C++/Tree excep)HY(tion)YH( also allows you to obtain + error details program)HY(mat)HY(i)HY(cally)YH(. For example, the + )SM(xml_schema::parsing)ES( excep)HY(tion)YH( is thrown when + the XML parsing and vali)HY(da)HY(tion)YH( in the under)HY(ly)HY(ing)YH( XML parser + fails. It encap)HY(su)HY(lates)YH( various diag)HY(nos)HY(tics)YH( infor)HY(ma)HY(tion)YH( + such as the file name, line and column numbers, as well as the + error or warning message for each entry. For more infor)HY(ma)HY(tion)YH( + about this and other excep)HY(tions)YH( that can be thrown during + parsing, refer to + )R16 2 A(Section + 3.3, "Error Handling")EA( in the C++/Tree Mapping + User Manual.)EP( + + )0 P(Note that if you are parsing )SM(std::istream)ES( on which + excep)HY(tions)YH( are not enabled, then you will need to check the + stream state after the call to the parsing func)HY(tion)YH( in order + to detect any possi)HY(ble)YH( stream fail)HY(ures)YH(, for example:)EP( + + ) 15 50 PR(std::ifstream ifs \201"people.xml"\202; + +if \201ifs.fail \201\202\202 +{ + cerr << "people.xml: unable to open" << endl; + return 1; +} + +auto_ptr<people_t> p \201people \201ifs, "people.xml"\202\202; + +if \201ifs.fail \201\202\202 +{ + cerr << "people.xml: read error" << endl; + return 1; +})RP( + + )0 P(The above example can be rewrit)HY(ten)YH( to use excep)HY(tions)YH( as + shown below:)EP( + + ) 13 66 PR(try +{ + std::ifstream ifs; + ifs.exceptions \201std::ifstream::badbit | std::ifstream::failbit\202; + ifs.open \201"people.xml"\202; + + auto_ptr<people_t> p \201people \201ifs, "people.xml"\202\202; +} +catch \201const std::ifstream::failure&\202 +{ + cerr << "people.xml: unable to open or read error" << endl; + return 1; +})RP( + + + + + + )0 1 29 H(6)WB 65 Sn()WB 33 Sn( Seri)HY(al)HY(iza)HY(tion)YH()EA()EH( + + )0 P(We have already seen how to seri)HY(al)HY(ize)YH( an object model back to XML + in this guide before. In this chapter we will discuss the + seri)HY(al)HY(iza)HY(tion)YH( topic in more detail.)EP( + + )0 P(By default, the C++/Tree mapping provides a total of 8 over)HY(loaded)YH( + seri)HY(al)HY(iza)HY(tion)YH( func)HY(tions)YH(. They differ in the output methods used to write + XML as well as the error report)HY(ing)YH( mech)HY(a)HY(nisms)YH(. It is also possi)HY(ble)YH( to + gener)HY(ate)YH( types for root elements instead of parsing and seri)HY(al)HY(iza)HY(tion)YH( + func)HY(tions)YH(. This may be useful if your XML vocab)HY(u)HY(lary)YH( has multi)HY(ple)YH( + root elements. For more infor)HY(ma)HY(tion)YH( on element types refer to + )R14 2 A(Section + 2.9, "Mapping for Global Elements")EA( in the C++/Tree Mapping User + Manual.)EP( + + + )0 P(In this section we will discuss the most commonly + used version of seri)HY(al)HY(iza)HY(tion)YH( func)HY(tions)YH(. For a compre)HY(hen)HY(sive)YH( descrip)HY(tion)YH( + of seri)HY(al)HY(iza)HY(tion)YH( refer to + )R17 2 A(Chapter + 4, "Seri)HY(al)HY(iza)HY(tion)YH(")EA( in the C++/Tree Mapping User Manual. For the + )SM(people)ES( global element from our person record vocab)HY(u)HY(lary)YH(, + we will concen)HY(trate)YH( on the follow)HY(ing)YH( seri)HY(al)HY(iza)HY(tion)YH( func)HY(tion)YH(:)EP( + + ) 7 50 PR(void +people \201std::ostream& os, + const people_t& x, + const xml_schema::namespace_infomap& map = + xml_schema::namespace_infomap \201\202, + const std::string& encoding = "UTF-8", + xml_schema::flags f = 0\202;)RP( + + )0 P(This func)HY(tion)YH( seri)HY(al)HY(izes)YH( the object model passed as the second + argu)HY(ment)YH( to the stan)HY(dard)YH( output stream passed as the first + argu)HY(ment)YH(. The third argu)HY(ment)YH( is a names)HY(pace)YH( infor)HY(ma)HY(tion)YH( map + which we will discuss in more detail in the next section. + The fourth argu)HY(ment)YH( is a char)HY(ac)HY(ter)YH( encod)HY(ing)YH( that the result)HY(ing)YH( + XML docu)HY(ment)YH( should be in. Possi)HY(ble)YH( valid values for this + argu)HY(ment)YH( are "US-ASCII", "ISO8859-1", "UTF-8", "UTF-16BE", + "UTF-16LE", "UCS-4BE", and "UCS-4LE". Finally, the flags + argu)HY(ment)YH( allows fine-tuning of the seri)HY(al)HY(iza)HY(tion)YH( process. + The follow)HY(ing)YH( example shows how we can use the above seri)HY(al)HY(iza)HY(tion)YH( + func)HY(tion)YH(:)EP( + + ) 19 34 PR(people_t& p = ... + +xml_schema::namespace_infomap map; +map[""].schema = "people.xsd"; + +// Serialize to stdout. +// +people \201std::cout, p, map\202; + +// Serialize to a file. +// +std::ofstream ofs \201"people.xml"\202; +people \201ofs, p, map\202; + +// Serialize to a string. +// +std::ostringstream oss; +people \201oss, p, map\202; +std::string xml \201oss.str \201\202\202;)RP( + + + )0 2 30 H(6.1)WB 66 Sn()WB 34 Sn( Names)HY(pace)YH( and Schema Infor)HY(ma)HY(tion)YH()EA()EH( + + )0 P(While XML seri)HY(al)HY(iza)HY(tion)YH( can be done just from the object + model alone, it is often desir)HY(able)YH( to assign mean)HY(ing)HY(ful)YH( + prefixes to XML names)HY(paces)YH( used in the vocab)HY(u)HY(lary)YH( as + well as to provide the schema loca)HY(tion)YH( infor)HY(ma)HY(tion)YH(. + This is accom)HY(plished)YH( by passing the names)HY(pace)YH( infor)HY(ma)HY(tion)YH( + map to the seri)HY(al)HY(iza)HY(tion)YH( func)HY(tion)YH(. The key in this map is + a names)HY(pace)YH( prefix that should be assigned to an XML names)HY(pace)YH( + spec)HY(i)HY(fied)YH( in the )SM(name)ES( vari)HY(able)YH( of the + map value. You can also assign an optional schema loca)HY(tion)YH( for + this names)HY(pace)YH( in the )SM(schema)ES( vari)HY(able)YH(. Based + on each key-value entry in this map, the seri)HY(al)HY(iza)HY(tion)YH( + func)HY(tion)YH( adds two attributes to the result)HY(ing)YH( XML docu)HY(ment)YH(: + the names)HY(pace)YH(-prefix mapping attribute and schema loca)HY(tion)YH( + attribute. The empty prefix indi)HY(cates)YH( that the names)HY(pace)YH( + should be mapped without a prefix. For example, the follow)HY(ing)YH( + map:)EP( + + ) 7 55 PR(xml_schema::namespace_infomap map; + +map[""].name = "http://www.example.com/example"; +map[""].schema = "example.xsd"; + +map["x"].name = "http://www.w3.org/XML/1998/namespace"; +map["x"].schema = "xml.xsd";)RP( + + )0 P(Results in the follow)HY(ing)YH( XML docu)HY(ment)YH(:)EP( + + ) 7 68 PR(<?xml version="1.0" ?> +<example + xmlns="http://www.example.com/example" + xmlns:x="http://www.w3.org/XML/1998/namespace" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://www.example.com/example example.xsd + http://www.w3.org/XML/1998/namespace xml.xsd">)RP( + + )0 P(The empty names)HY(pace)YH( indi)HY(cates)YH( that the vocab)HY(u)HY(lary)YH( has no target + names)HY(pace)YH(. For example, the follow)HY(ing)YH( map results in only the + )SM(noNames)HY(paceSchemaLo)HY(ca)HY(tion)YH()ES( attribute being added:)EP( + + ) 4 34 PR(xml_schema::namespace_infomap map; + +map[""].name = ""; +map[""].schema = "example.xsd";)RP( + + )0 2 31 H(6.2)WB 67 Sn()WB 35 Sn( Error Handling)EA()EH( + + )0 P(Similar to the parsing func)HY(tions)YH(, the seri)HY(al)HY(iza)HY(tion)YH( func)HY(tions)YH( offer a + number of ways to handle error condi)HY(tions)YH( with the C++ excep)HY(tions)YH( being + the most commonly used mech)HY(a)HY(nisms)YH(. As with parsing, the easiest way to + uniformly handle all possi)HY(ble)YH( seri)HY(al)HY(iza)HY(tion)YH( excep)HY(tions)YH( and print + detailed infor)HY(ma)HY(tion)YH( about the error is to catch and print + )SM(xml_schema::excep)HY(tion)YH()ES(:)EP( + + ) 13 38 PR(try +{ + people_t& p = ... + + xml_schema::namespace_infomap map; + map[""].schema = "people.xsd"; + + people \201std::cout, p, map\202\202; +} +catch \201const xml_schema::exception& e\202 +{ + cerr << e << endl; +})RP( + + )0 P(The most commonly encoun)HY(tered)YH( seri)HY(al)HY(iza)HY(tion)YH( excep)HY(tion)YH( is + )SM(xml_schema::seri)HY(al)HY(iza)HY(tion)YH()ES(. It is thrown + when the XML seri)HY(al)HY(iza)HY(tion)YH( in the under)HY(ly)HY(ing)YH( XML writer + fails. It encap)HY(su)HY(lates)YH( various diag)HY(nos)HY(tics)YH( infor)HY(ma)HY(tion)YH( + such as the file name, line and column numbers, as well as the + error or warning message for each entry. For more infor)HY(ma)HY(tion)YH( + about this and other excep)HY(tions)YH( that can be thrown during + seri)HY(al)HY(iza)HY(tion)YH(, refer to + )R18 2 A(Section + 4.4, "Error Handling")EA( in the C++/Tree Mapping + User Manual.)EP( + + )0 P(Note that if you are seri)HY(al)HY(iz)HY(ing)YH( to )SM(std::ostream)ES( on + which excep)HY(tions)YH( are not enabled, then you will need to check the + stream state after the call to the seri)HY(al)HY(iza)HY(tion)YH( func)HY(tion)YH( in order + to detect any possi)HY(ble)YH( stream fail)HY(ures)YH(, for example:)EP( + + ) 15 47 PR(std::ofstream ofs \201"people.xml"\202; + +if \201ofs.fail \201\202\202 +{ + cerr << "people.xml: unable to open" << endl; + return 1; +} + +people \201ofs, p, map\202\202; + +if \201ofs.fail \201\202\202 +{ + cerr << "people.xml: write error" << endl; + return 1; +})RP( + + )0 P(The above example can be rewrit)HY(ten)YH( to use excep)HY(tions)YH( as + shown below:)EP( + + ) 13 66 PR(try +{ + std::ofstream ofs; + ofs.exceptions \201std::ofstream::badbit | std::ofstream::failbit\202; + ofs.open \201"people.xml"\202; + + people \201ofs, p, map\202\202; +} +catch \201const std::ofstream::failure&\202 +{ + cerr << "people.xml: unable to open or write error" << endl; + return 1; +})RP( + + )BR( +)BR( + +)WB NL +/TE t D NP /OU t D TU PM 1 eq and{/Pn () D showpage}if end restore diff --git a/xsd/doc/cxx/tree/guide/guide.html2ps b/xsd/doc/cxx/tree/guide/guide.html2ps new file mode 100644 index 0000000..fbdaaf5 --- /dev/null +++ b/xsd/doc/cxx/tree/guide/guide.html2ps @@ -0,0 +1,65 @@ +@html2ps { + option { + toc: hb; + colour: 1; + hyphenate: 1; + titlepage: 1; + } + + datefmt: "%B %Y"; + + titlepage { + content: " +<div align=center> + <h1><big>C++/Tree Mapping</big></h1> + <h1><big>Getting Started Guide</big></h1> + <h1> </h1> + <h1> </h1> + <h1> </h1> + <h1> </h1> + <h1> </h1> + <h1> </h1> +</div> + <p>Copyright © 2005-2014 CODE SYNTHESIS TOOLS CC</p> + + <p>Permission is granted to copy, distribute and/or modify this + document under the terms of the + <a href='http://www.codesynthesis.com/licenses/fdl-1.2.txt'>GNU Free + Documentation License, version 1.2</a>; with no Invariant Sections, + no Front-Cover Texts and no Back-Cover Texts. + </p> + + <p>This document is available in the following formats: + <a href='http://www.codesynthesis.com/projects/xsd/documentation/cxx/tree/guide/index.xhtml'>XHTML</a>, + <a href='http://www.codesynthesis.com/projects/xsd/documentation/cxx/tree/guide/cxx-parser-guide.pdf'>PDF</a>, and + <a href='http://www.codesynthesis.com/projects/xsd/documentation/cxx/tree/guide/cxx-parser-guide.ps'>PostScript</a>.</p>"; + } + + toc { + indent: 2em; + } + + header { + odd-right: $H; + even-left: $H; + } + + footer { + odd-left: $D; + odd-center: $T; + odd-right: $N; + + even-left: $N; + even-center: $T; + even-right: $D; + } +} + +body { + font-size: 12pt; + text-align: justify; +} + +pre { + font-size: 10pt; +} diff --git a/xsd/doc/cxx/tree/guide/index.xhtml b/xsd/doc/cxx/tree/guide/index.xhtml new file mode 100644 index 0000000..49ad3a6 --- /dev/null +++ b/xsd/doc/cxx/tree/guide/index.xhtml @@ -0,0 +1,2732 @@ +<?xml version="1.0" encoding="iso-8859-1"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> + +<head> + <title>C++/Tree Mapping Getting Started Guide</title> + + <meta name="copyright" content="© 2005-2014 Code Synthesis Tools CC"/> + <meta name="keywords" content="xsd,xml,schema,c++,mapping,data,binding,parsing,serialization,validation"/> + <meta name="description" content="C++/Tree Mapping Getting Started Guide"/> + + <link rel="stylesheet" type="text/css" href="../../../default.css" /> + +<style type="text/css"> + pre { + padding : 0 0 0 0em; + margin : 0em 0em 0em 0; + + font-size : 102% + } + + body { + min-width: 48em; + } + + h1 { + font-weight: bold; + font-size: 200%; + line-height: 1.2em; + } + + h2 { + font-weight : bold; + font-size : 150%; + + padding-top : 0.8em; + } + + h3 { + font-size : 140%; + padding-top : 0.8em; + } + + /* Adjust indentation for three levels. */ + #container { + max-width: 48em; + } + + #content { + padding: 0 0.1em 0 4em; + /*background-color: red;*/ + } + + #content h1 { + margin-left: -2.06em; + } + + #content h2 { + margin-left: -1.33em; + } + + /* Title page */ + + #titlepage { + padding: 2em 0 1em 0; + border-bottom: 1px solid black; + } + + #titlepage .title { + font-weight: bold; + font-size: 200%; + text-align: center; + } + + #titlepage #first-title { + padding: 1em 0 0.4em 0; + } + + #titlepage #second-title { + padding: 0.4em 0 2em 0; + } + + /* Lists */ + ul.list li { + padding-top : 0.3em; + padding-bottom : 0.3em; + } + + div.img { + text-align: center; + padding: 2em 0 2em 0; + } + + /* */ + dl dt { + padding : 0.8em 0 0 0; + } + + /* Built-in table */ + #builtin { + margin: 2em 0 2em 0; + + border-collapse : collapse; + border : 1px solid; + border-color : #000000; + + font-size : 11px; + line-height : 14px; + } + + #builtin th, #builtin td { + border: 1px solid; + padding : 0.9em 0.9em 0.7em 0.9em; + } + + #builtin th { + background : #cde8f6; + } + + #builtin td { + text-align: left; + } + + /* TOC */ + table.toc { + border-style : none; + border-collapse : separate; + border-spacing : 0; + + margin : 0.2em 0 0.2em 0; + padding : 0 0 0 0; + } + + table.toc tr { + padding : 0 0 0 0; + margin : 0 0 0 0; + } + + table.toc * td, table.toc * th { + border-style : none; + margin : 0 0 0 0; + vertical-align : top; + } + + table.toc * th { + font-weight : normal; + padding : 0em 0.1em 0em 0; + text-align : left; + white-space : nowrap; + } + + table.toc * table.toc th { + padding-left : 1em; + } + + table.toc * td { + padding : 0em 0 0em 0.7em; + text-align : left; + } +</style> + + +</head> + +<body> +<div id="container"> + <div id="content"> + + <div class="noprint"> + + <div id="titlepage"> + <div class="title" id="first-title">C++/Tree Mapping</div> + <div class="title" id="second-title">Getting Started Guide</div> + + <p>Copyright © 2005-2014 CODE SYNTHESIS TOOLS CC</p> + + <p>Permission is granted to copy, distribute and/or modify this + document under the terms of the + <a href="http://www.codesynthesis.com/licenses/fdl-1.2.txt">GNU Free + Documentation License, version 1.2</a>; with no Invariant Sections, + no Front-Cover Texts and no Back-Cover Texts. + </p> + + <p>This document is available in the following formats: + <a href="http://www.codesynthesis.com/projects/xsd/documentation/cxx/tree/guide/index.xhtml">XHTML</a>, + <a href="http://www.codesynthesis.com/projects/xsd/documentation/cxx/tree/guide/cxx-tree-guide.pdf">PDF</a>, and + <a href="http://www.codesynthesis.com/projects/xsd/documentation/cxx/tree/guide/cxx-tree-guide.ps">PostScript</a>.</p> + + </div> + + <h1>Table of Contents</h1> + + <table class="toc"> + <tr> + <th></th><td><a href="#0">Preface</a> + <table class="toc"> + <tr><th></th><td><a href="#0.1">About This Document</a></td></tr> + <tr><th></th><td><a href="#0.2">More Information</a></td></tr> + </table> + </td> + </tr> + + <tr> + <th>1</th><td><a href="#1">Introduction</a> + <table class="toc"> + <tr><th>1.1</th><td><a href="#1.1">Mapping Overview</a></td></tr> + <tr><th>1.2</th><td><a href="#1.2">Benefits</a></td></tr> + </table> + </td> + </tr> + + <tr> + <th>2</th><td><a href="#2">Hello World Example</a> + <table class="toc"> + <tr><th>2.1</th><td><a href="#2.1">Writing XML Document and Schema</a></td></tr> + <tr><th>2.2</th><td><a href="#2.2">Translating Schema to C++</a></td></tr> + <tr><th>2.3</th><td><a href="#2.3">Implementing Application Logic</a></td></tr> + <tr><th>2.4</th><td><a href="#2.4">Compiling and Running</a></td></tr> + <tr><th>2.5</th><td><a href="#2.5">Adding Serialization</a></td></tr> + <tr><th>2.6</th><td><a href="#2.6">Selecting Naming Convention</a></td></tr> + <tr><th>2.7</th><td><a href="#2.7">Generating Documentation</a></td></tr> + </table> + </td> + </tr> + + <tr> + <th>3</th><td><a href="#3">Overall Mapping Configuration</a> + <table class="toc"> + <tr><th>3.1</th><td><a href="#3.1">C++ Standard</a></td></tr> + <tr><th>3.2</th><td><a href="#3.2">Character Type and Encoding</a></td></tr> + <tr><th>3.3</th><td><a href="#3.3">Support for Polymorphism </a></td></tr> + <tr><th>3.4</th><td><a href="#3.4">Namespace Mapping</a></td></tr> + <tr><th>3.5</th><td><a href="#3.5">Thread Safety</a></td></tr> + </table> + </td> + </tr> + + <tr> + <th>4</th><td><a href="#4">Working with Object Models</a> + <table class="toc"> + <tr><th>4.1</th><td><a href="#4.1">Attribute and Element Cardinalities</a></td></tr> + <tr><th>4.2</th><td><a href="#4.2">Accessing the Object Model</a></td></tr> + <tr><th>4.3</th><td><a href="#4.3">Modifying the Object Model</a></td></tr> + <tr><th>4.4</th><td><a href="#4.4">Creating the Object Model from Scratch</a></td></tr> + <tr><th>4.5</th><td><a href="#4.5">Mapping for the Built-in XML Schema Types</a></td></tr> + </table> + </td> + </tr> + + <tr> + <th>5</th><td><a href="#5">Parsing</a> + <table class="toc"> + <tr><th>5.1</th><td><a href="#5.1">XML Schema Validation and Searching</a></td></tr> + <tr><th>5.2</th><td><a href="#5.2">Error Handling</a></td></tr> + </table> + </td> + </tr> + + <tr> + <th>6</th><td><a href="#6">Serialization</a> + <table class="toc"> + <tr><th>6.1</th><td><a href="#6.1">Namespace and Schema Information</a></td></tr> + <tr><th>6.2</th><td><a href="#6.2">Error Handling</a></td></tr> + </table> + </td> + </tr> + + </table> + </div> + + <h1><a name="0">Preface</a></h1> + + <h2><a name="0.1">About This Document</a></h2> + + <p>The goal of this document is to provide you with an understanding of + the C++/Tree programming model and allow you to efficiently evaluate + XSD against your project's technical requirements. As such, this + document is intended for C++ developers and software architects + who are looking for an XML processing solution. For a more in-depth + description of the C++/Tree mapping refer to the + <a href="http://www.codesynthesis.com/projects/xsd/documentation/cxx/tree/manual/">C++/Tree + Mapping User Manual</a>.</p> + + <p>Prior experience with XML and C++ is required to understand this + document. Basic understanding of XML Schema is advantageous but + not expected or required. + </p> + + + <h2><a name="0.2">More Information</a></h2> + + <p>Beyond this guide, you may also find the following sources of + information useful:</p> + + <ul class="list"> + <li><a href="http://www.codesynthesis.com/projects/xsd/documentation/cxx/tree/manual/">C++/Tree + Mapping User Manual</a></li> + + <li><a href="http://wiki.codesynthesis.com/Tree/Customization_guide">C++/Tree + Mapping Customization Guide</a></li> + + <li><a href="http://wiki.codesynthesis.com/Tree/FAQ">C++/Tree + Mapping Frequently Asked Questions (FAQ)</a></li> + + <li><a href="http://www.codesynthesis.com/projects/xsd/documentation/xsd.xhtml">XSD + Compiler Command Line Manual</a></li> + + <li>The <code>examples/cxx/tree/</code> directory in the XSD + distribution contains a collection of examples and a README + file with an overview of each example.</li> + + <li>The <code>README</code> file in the XSD distribution explains + how to compile the examples on various platforms.</li> + + <li>The <a href="http://www.codesynthesis.com/mailman/listinfo/xsd-users">xsd-users</a> + mailing list is the place to ask technical questions about XSD and the C++/Parser mapping. + Furthermore, the <a href="http://www.codesynthesis.com/pipermail/xsd-users/">archives</a> + may already have answers to some of your questions.</li> + </ul> + + <!-- Introduction --> + + <h1><a name="1">1 Introduction</a></h1> + + <p>Welcome to CodeSynthesis XSD and the C++/Tree mapping. XSD is a + cross-platform W3C XML Schema to C++ data binding compiler. C++/Tree + is a W3C XML Schema to C++ mapping that represents the data stored + in XML as a statically-typed, vocabulary-specific object model. + </p> + + <h2><a name="1.1">1.1 Mapping Overview</a></h2> + + <p>Based on a formal description of an XML vocabulary (schema), the + C++/Tree mapping produces a tree-like data structure suitable for + in-memory processing. The core of the mapping consists of C++ + classes that constitute the object model and are derived from + types defined in XML Schema as well as XML parsing and + serialization code.</p> + + <p>Besides the core features, C++/Tree provide a number of additional + mapping elements that can be useful in some applications. These + include serialization and extraction to/from formats others than + XML, such as unstructured text (useful for debugging) and binary + representations such as XDR and CDR for high-speed data processing + as well as automatic documentation generation. The C++/Tree mapping + also provides a wide range of mechanisms for controlling and + customizing the generated code.</p> + + <p>A typical application that uses C++/Tree for XML processing usually + performs the following three steps: it first reads (parses) an XML + document to an in-memory object model, it then performs some useful + computations on that object model which may involve modification + of the model, and finally it may write (serialize) the modified + object model back to XML.</p> + + <p>The next chapter presents a simple application that performs these + three steps. The following chapters show how to use the C++/Tree + mapping in more detail.</p> + + <h2><a name="1.2">1.2 Benefits</a></h2> + + <p>Traditional XML access APIs such as Document Object Model (DOM) + or Simple API for XML (SAX) have a number of drawbacks that + make them less suitable for creating robust and maintainable + XML processing applications. These drawbacks include: + </p> + + <ul class="list"> + <li>Generic representation of XML in terms of elements, attributes, + and text forces an application developer to write a substantial + amount of bridging code that identifies and transforms pieces + of information encoded in XML to a representation more suitable + for consumption by the application logic.</li> + + <li>String-based flow control defers error detection to runtime. + It also reduces code readability and maintainability.</li> + + <li>Lack of type safety because the data is represented as text.</li> + + <li>Resulting applications are hard to debug, change, and + maintain.</li> + </ul> + + <p>In contrast, statically-typed, vocabulary-specific object model + produced by the C++/Tree mapping allows you to operate in your + domain terms instead of the generic elements, attributes, and + text. Static typing helps catch errors at compile-time rather + than at run-time. Automatic code generation frees you for more + interesting tasks (such as doing something useful with the + information stored in the XML documents) and minimizes the + effort needed to adapt your applications to changes in the + document structure. To summarize, the C++/Tree object model has + the following key advantages over generic XML access APIs:</p> + + <ul class="list"> + <li><b>Ease of use.</b> The generated code hides all the complexity + associated with parsing and serializing XML. This includes navigating + the structure and converting between the text representation and + data types suitable for manipulation by the application + logic.</li> + + <li><b>Natural representation.</b> The object representation allows + you to access the XML data using your domain vocabulary instead + of generic elements, attributes, and text.</li> + + <li><b>Concise code.</b> With the object representation the + application implementation is simpler and thus easier + to read and understand.</li> + + <li><b>Safety.</b> The generated object model is statically + typed and uses functions instead of strings to access the + information. This helps catch programming errors at compile-time + rather than at runtime.</li> + + <li><b>Maintainability.</b> Automatic code generation minimizes the + effort needed to adapt the application to changes in the + document structure. With static typing, the C++ compiler + can pin-point the places in the client code that need to be + changed.</li> + + <li><b>Compatibility.</b> Sequences of elements are represented in + the object model as containers conforming to the standard C++ + sequence requirements. This makes it possible to use standard + C++ algorithms on the object representation and frees you from + learning yet another container interface, as is the case with + DOM.</li> + + <li><b>Efficiency.</b> If the application makes repetitive use + of the data extracted from XML, then the C++/Tree object model + is more efficient because the navigation is performed using + function calls rather than string comparisons and the XML + data is extracted only once. Furthermore, the runtime memory + usage is reduced due to more efficient data storage + (for instance, storing numeric data as integers instead of + strings) as well as the static knowledge of cardinality + constraints.</li> + </ul> + + + <!-- Hello World Parser --> + + + <h1><a name="2">2 Hello World Example</a></h1> + + <p>In this chapter we will examine how to parse, access, modify, and + serialize a very simple XML document using the XSD-generated + C++/Tree object model. The code presented in this chapter is + based on the <code>hello</code> example which can be found in + the <code>examples/cxx/tree/</code> directory of the XSD + distribution.</p> + + <h2><a name="2.1">2.1 Writing XML Document and Schema</a></h2> + + <p>First, we need to get an idea about the structure + of the XML documents we are going to process. Our + <code>hello.xml</code>, for example, could look like this:</p> + + <pre class="xml"> +<?xml version="1.0"?> +<hello> + + <greeting>Hello</greeting> + + <name>sun</name> + <name>moon</name> + <name>world</name> + +</hello> + </pre> + + <p>Then we can write a description of the above XML in the + XML Schema language and save it into <code>hello.xsd</code>:</p> + + <pre class="xml"> +<?xml version="1.0"?> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> + + <xs:complexType name="hello_t"> + <xs:sequence> + <xs:element name="greeting" type="xs:string"/> + <xs:element name="name" type="xs:string" maxOccurs="unbounded"/> + </xs:sequence> + </xs:complexType> + + <xs:element name="hello" type="hello_t"/> + +</xs:schema> + </pre> + + <p>Even if you are not familiar with XML Schema, it + should be easy to connect declarations in <code>hello.xsd</code> + to elements in <code>hello.xml</code>. The <code>hello_t</code> type + is defined as a sequence of the nested <code>greeting</code> and + <code>name</code> elements. Note that the term sequence in XML + Schema means that elements should appear in a particular order + as opposed to appearing multiple times. The <code>name</code> + element has its <code>maxOccurs</code> property set to + <code>unbounded</code> which means it can appear multiple times + in an XML document. Finally, the globally-defined <code>hello</code> + element prescribes the root element for our vocabulary. For an + easily-approachable introduction to XML Schema refer to + <a href="http://www.w3.org/TR/xmlschema-0/">XML Schema Part 0: + Primer</a>.</p> + + <p>The above schema is a specification of our XML vocabulary; it tells + everybody what valid documents of our XML-based language should look + like. We can also update our <code>hello.xml</code> to include the + information about the schema so that XML parsers can validate + our document:</p> + + <pre class="xml"> +<?xml version="1.0"?> +<hello xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="hello.xsd"> + + <greeting>Hello</greeting> + + <name>sun</name> + <name>moon</name> + <name>world</name> + +</hello> + </pre> + + + <p>The next step is to compile the schema to generate the object + model and parsing functions.</p> + + <h2><a name="2.2">2.2 Translating Schema to C++</a></h2> + + <p>Now we are ready to translate our <code>hello.xsd</code> to C++. + To do this we invoke the XSD compiler from a terminal (UNIX) or + a command prompt (Windows): + </p> + + <pre class="terminal"> +$ xsd cxx-tree hello.xsd + </pre> + + <p>The XSD compiler produces two C++ files: <code>hello.hxx</code> and + <code>hello.cxx</code>. The following code fragment is taken from + <code>hello.hxx</code>; it should give you an idea about what gets + generated: + </p> + + <pre class="c++"> +class hello_t +{ +public: + // greeting + // + typedef xml_schema::string greeting_type; + + const greeting_type& + greeting () const; + + greeting_type& + greeting (); + + void + greeting (const greeting_type& x); + + // name + // + typedef xml_schema::string name_type; + typedef xsd::sequence<name_type> name_sequence; + typedef name_sequence::iterator name_iterator; + typedef name_sequence::const_iterator name_const_iterator; + + const name_sequence& + name () const; + + name_sequence& + name (); + + void + name (const name_sequence& s); + + // Constructor. + // + hello_t (const greeting_type&); + + ... + +}; + +std::auto_ptr<hello_t> +hello (const std::string& uri); + +std::auto_ptr<hello_t> +hello (std::istream&); + </pre> + + <p>The <code>hello_t</code> C++ class corresponds to the + <code>hello_t</code> XML Schema type. For each element + in this type a set of C++ type definitions as well as + accessor and modifier functions are generated inside the + <code>hello_t</code> class. Note that the type definitions + and member functions for the <code>greeting</code> and + <code>name</code> elements are different because of the + cardinality differences between these two elements + (<code>greeting</code> is a required single element and + <code>name</code> is a sequence of elements).</p> + + <p>The <code>xml_schema::string</code> type used in the type + definitions is a C++ class provided by the XSD runtime + that corresponds to built-in XML Schema type + <code>string</code>. The <code>xml_schema::string</code> + is based on <code>std::string</code> and can be used as + such. Similarly, the <code>sequence</code> class template + that is used in the <code>name_sequence</code> type + definition is based on and has the same interface as + <code>std::vector</code>. The mapping between the built-in + XML Schema types and C++ types is described in more detail in + <a href="#4.5">Section 4.5, "Mapping for the Built-in XML Schema + Types"</a>. The <code>hello_t</code> class also includes a + constructor with an initializer for the required + <code>greeting</code> element as its argument.</p> + + <p>The <code>hello</code> overloaded global functions correspond + to the <code>hello</code> global element in XML Schema. A + global element in XML Schema is a valid document root. + By default XSD generated a set of parsing functions for each + global element defined in XML Schema (this can be overridden + with the <code>--root-element-*</code> options). Parsing + functions return a dynamically allocated object model as an + automatic pointer. The actual pointer used depends on the + C++ standard selected. For C++98 it is <code>std::auto_ptr</code> + as shown above. For C++11 it is <code>std::unique_ptr</code>. + For example, if we modify our XSD compiler invocation to + select C++11:</p> + + <pre class="terminal"> +$ xsd cxx-tree --std c++11 hello.xsd + </pre> + + <p>Then the parsing function signatures will become:</p> + + <pre class="c++"> +std::unique_ptr<hello_t> +hello (const std::string& uri); + +std::unique_ptr<hello_t> +hello (std::istream&); + </pre> + + <p>For more information on parsing functions see <a href="#5">Chapter 5, + "Parsing"</a>.</p> + + <h2><a name="2.3">2.3 Implementing Application Logic</a></h2> + + <p>At this point we have all the parts we need to do something useful + with the information stored in our XML document: + </p> + + <pre class="c++"> +#include <iostream> +#include "hello.hxx" + +using namespace std; + +int +main (int argc, char* argv[]) +{ + try + { + auto_ptr<hello_t> h (hello (argv[1])); + + for (hello_t::name_const_iterator i (h->name ().begin ()); + i != h->name ().end (); + ++i) + { + cerr << h->greeting () << ", " << *i << "!" << endl; + } + } + catch (const xml_schema::exception& e) + { + cerr << e << endl; + return 1; + } +} + </pre> + + <p>The first part of our application calls one of the parsing + functions to parser an XML file specified in the command line. + We then use the returned object model to iterate over names + and print a greeting line for each of them. Finally, we + catch and print the <code>xml_schema::exception</code> + exception in case something goes wrong. This exception + is the root of the exception hierarchy used by the + XSD-generated code. + </p> + + + <h2><a name="2.4">2.4 Compiling and Running</a></h2> + + <p>After saving our application from the previous section in + <code>driver.cxx</code>, we are ready to compile our first + program and run it on the test XML document. On a UNIX + system this can be done with the following commands: + </p> + + <pre class="terminal"> +$ c++ -I.../libxsd -c driver.cxx hello.cxx +$ c++ -o driver driver.o hello.o -lxerces-c +$ ./driver hello.xml +Hello, sun! +Hello, moon! +Hello, world! + </pre> + + <p>Here <code>.../libxsd</code> represents the path to the + <code>libxsd</code> directory in the XSD distribution. + Note also that we are required to link our application + with the Xerces-C++ library because the generated code + uses it as the underlying XML parser.</p> + + <h2><a name="2.5">2.5 Adding Serialization</a></h2> + + <p>While parsing and accessing the XML data may be everything + you need, there are applications that require creating new + or modifying existing XML documents. By default XSD does + not produce serialization code. We will need to request + it with the <code>--generate-serialization</code> options:</p> + + <pre class="terminal"> +$ xsd cxx-tree --generate-serialization hello.xsd + </pre> + + <p>If we now examine the generated <code>hello.hxx</code> file, + we will find a set of overloaded serialization functions, + including the following version:</p> + + <pre class="c++"> +void +hello (std::ostream&, + const hello_t&, + const xml_schema::namespace_infomap& = + xml_schema::namespace_infomap ()); + + </pre> + + <p>Just like with parsing functions, XSD generates serialization + functions for each global element unless instructed otherwise + with one of the <code>--root-element-*</code> options. For more + information on serialization functions see <a href="#6">Chapter 6, + "Serialization"</a>.</p> + + <p>We first examine an application that modifies an existing + object model and serializes it back to XML:</p> + + <pre class="c++"> +#include <iostream> +#include "hello.hxx" + +using namespace std; + +int +main (int argc, char* argv[]) +{ + try + { + auto_ptr<hello_t> h (hello (argv[1])); + + // Change the greeting phrase. + // + h->greeting ("Hi"); + + // Add another entry to the name sequence. + // + h->name ().push_back ("mars"); + + // Serialize the modified object model to XML. + // + xml_schema::namespace_infomap map; + map[""].name = ""; + map[""].schema = "hello.xsd"; + + hello (cout, *h, map); + } + catch (const xml_schema::exception& e) + { + cerr << e << endl; + return 1; + } +} + </pre> + + <p>First, our application parses an XML document and obtains its + object model as in the previous example. Then it changes the + greeting string and adds another entry to the list of names. + Finally, it serializes the object model back to XML by calling + the serialization function.</p> + + <p>The first argument we pass to the serialization function is + <code>cout</code> which results in the XML being written to + the standard output for us to inspect. We could have also + written the result to a file or memory buffer by creating an + instance of <code>std::ofstream</code> or <code>std::ostringstream</code> + and passing it instead of <code>cout</code>. The second argument is the + object model we want to serialize. The final argument is an optional + namespace information map for our vocabulary. It captures information + such as namespaces, namespace prefixes to which they should be mapped, + and schemas associated with these namespaces. If we don't provide + this argument then generic namespace prefixes (<code>p1</code>, + <code>p2</code>, etc.) will be automatically assigned to XML namespaces + and no schema information will be added to the resulting document + (see <a href="#6">Chapter 6, "Serialization"</a> for details). + In our case, the prefix (map key) and namespace name are empty + because our vocabulary does not use XML namespaces.</p> + + <p>If we now compile and run this application we will see the + output as shown in the following listing:</p> + + <pre class="xml"> +<?xml version="1.0"?> +<hello xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="hello.xsd"> + + <greeting>Hi</greeting> + + <name>sun</name> + <name>moon</name> + <name>world</name> + <name>mars</name> + +</hello> + </pre> + + <p>We can also create and serialize an object model from scratch + as shown in the following example:</p> + + <pre class="c++"> +#include <iostream> +#include <fstream> +#include "hello.hxx" + +using namespace std; + +int +main (int argc, char* argv[]) +{ + try + { + hello_t h ("Hi"); + + hello_t::name_sequence& ns (h.name ()); + + ns.push_back ("Jane"); + ns.push_back ("John"); + + // Serialize the object model to XML. + // + xml_schema::namespace_infomap map; + map[""].name = ""; + map[""].schema = "hello.xsd"; + + std::ofstream ofs (argv[1]); + hello (ofs, h, map); + } + catch (const xml_schema::exception& e) + { + cerr << e << endl; + return 1; + } +} + </pre> + + <p>In this example we used the generated constructor to create + an instance of type <code>hello_t</code>. To reduce typing, + we obtained a reference to the name sequence which we then + used to add a few names. The serialization part is identical + to the previous example except this time we are writing to + a file. If we compile and run this program, it produces the + following XML file:</p> + + <pre class="xml"> +<?xml version="1.0"?> +<hello xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="hello.xsd"> + + <greeting>Hi</greeting> + + <name>Jane</name> + <name>John</name> + +</hello> + </pre> + + <h2><a name="2.6">2.6 Selecting Naming Convention</a></h2> + + <p>By default XSD uses the so-called K&R (Kernighan and Ritchie) + identifier naming convention in the generated code. In this + convention both type and function names are in lower case and + words are separated by underscores. If your application code or + schemas use a different notation, you may want to change the + naming convention used in the generated code for consistency. + XSD supports a set of widely-used naming conventions + that you can select with the <code>--type-naming</code> and + <code>--function-naming</code> options. You can also further + refine one of the predefined conventions or create a completely + custom naming scheme by using the <code>--*-regex</code> options.</p> + + <p>As an example, let's assume that our "Hello World" application + uses the so-called upper-camel-case naming convention for types + (that is, each word in a type name is capitalized) and the K&R + convention for function names. Since K&R is the default + convention for both type and function names, we only need to + change the type naming scheme:</p> + + <pre class="terminal"> +$ xsd cxx-tree --type-naming ucc hello.xsd + </pre> + + <p>The <code>ucc</code> argument to the <code>--type-naming</code> + options stands for upper-camel-case. If we now examine the + generated <code>hello.hxx</code>, we will see the following + changes compared to the declarations shown in the previous + sections:</p> + + <pre class="c++"> +class Hello_t +{ +public: + // greeting + // + typedef xml_schema::String GreetingType; + + const GreetingType& + greeting () const; + + GreetingType& + greeting (); + + void + greeting (const GreetingType& x); + + // name + // + typedef xml_schema::String NameType; + typedef xsd::sequence<NameType> NameSequence; + typedef NameSequence::iterator NameIterator; + typedef NameSequence::const_iterator NameConstIterator; + + const NameSequence& + name () const; + + NameSequence& + name (); + + void + name (const NameSequence& s); + + // Constructor. + // + Hello_t (const GreetingType&); + + ... + +}; + +std::auto_ptr<Hello_t> +hello (const std::string& uri); + +std::auto_ptr<Hello_t> +hello (std::istream&); + </pre> + + <p>Notice that the type names in the <code>xml_schema</code> namespace, + for example <code>xml_schema::String</code>, now also use the + upper-camel-case naming convention. The only thing that we may + be unhappy about in the above code is the <code>_t</code> + suffix in <code>Hello_t</code>. If we are not in a position + to change the schema, we can <em>touch-up</em> the <code>ucc</code> + convention with a custom translation rule using the + <code>--type-regex</code> option:</p> + + <pre class="terminal"> +$ xsd cxx-tree --type-naming ucc --type-regex '/ (.+)_t/\u$1/' hello.xsd + </pre> + + <p>This results in the following changes to the generated code:</p> + + <pre class="c++"> +class Hello +{ +public: + // greeting + // + typedef xml_schema::String GreetingType; + + const GreetingType& + greeting () const; + + GreetingType& + greeting (); + + void + greeting (const GreetingType& x); + + // name + // + typedef xml_schema::String NameType; + typedef xsd::sequence<NameType> NameSequence; + typedef NameSequence::iterator NameIterator; + typedef NameSequence::const_iterator NameConstIterator; + + const NameSequence& + name () const; + + NameSequence& + name (); + + void + name (const NameSequence& s); + + // Constructor. + // + Hello (const GreetingType&); + + ... + +}; + +std::auto_ptr<Hello> +hello (const std::string& uri); + +std::auto_ptr<Hello> +hello (std::istream&); + </pre> + + <p>For more detailed information on the <code>--type-naming</code>, + <code>--function-naming</code>, <code>--type-regex</code>, and + other <code>--*-regex</code> options refer to the NAMING + CONVENTION section in the <a href="http://www.codesynthesis.com/projects/xsd/documentation/xsd.xhtml">XSD + Compiler Command Line Manual</a>.</p> + + <h2><a name="2.7">2.7 Generating Documentation</a></h2> + + <p>While our object model is quite simple, real-world vocabularies + can be quite complex with hundreds of types, elements, and + attributes. For such vocabularies figuring out which types + provide which member functions by studying the generated + source code or schemas can be a daunting task. To provide + application developers with a more accessible way of + understanding the generated object models, the XSD compiler + can be instructed to produce source code with documentation + comments in the Doxygen format. Then the source code can be + processed with the <a href="http://www.doxygen.org">Doxygen</a> + documentation system to extract this information and produce + documentation in various formats. + </p> + + <p>In this section we will see how to generate documentation + for our "Hello World" vocabulary. To showcase the full power + of the XSD documentation facilities, we will first document + our schema. The XSD compiler will then transfer + this information from the schema to the generated code and + then to the object model documentation. Note that the + documentation in the schema is not required for XSD to + generate useful documentation. Below you will find + our <code>hello.xsd</code> with added documentation:</p> + + <pre class="xml"> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> + + <xs:complexType name="hello_t"> + + <xs:annotation> + <xs:documentation> + The hello_t type consists of a greeting phrase and a + collection of names to which this greeting applies. + </xs:documentation> + </xs:annotation> + + <xs:sequence> + + <xs:element name="greeting" type="xs:string"> + <xs:annotation> + <xs:documentation> + The greeting element contains the greeting phrase + for this hello object. + </xs:documentation> + </xs:annotation> + </xs:element> + + <xs:element name="name" type="xs:string" maxOccurs="unbounded"> + <xs:annotation> + <xs:documentation> + The name elements contains names to be greeted. + </xs:documentation> + </xs:annotation> + </xs:element> + + </xs:sequence> + </xs:complexType> + + <xs:element name="hello" type="hello_t"> + <xs:annotation> + <xs:documentation> + The hello element is a root of the Hello XML vocabulary. + Every conforming document should start with this element. + </xs:documentation> + </xs:annotation> + </xs:element> + +</xs:schema> + </pre> + + <p>The first step in obtaining the documentation is to recompile + our schema with the <code>--generate-doxygen</code> option:</p> + + <pre class="terminal"> +$ xsd cxx-tree --generate-serialization --generate-doxygen hello.xsd + </pre> + + <p>Now the generated <code>hello.hxx</code> file contains comments + in the Doxygen format. The next step is to process this file + with the Doxygen documentation system. If your project does + not use Doxygen then you first need to create a configuration + file for your project:</p> + + <pre class="terminal"> +$ doxygen -g hello.doxygen + </pre> + + <p>You only need to perform this step once. Now we can generate + the documentation by executing the following command in the + directory with the generated source code:</p> + + <pre class="terminal"> +$ doxygen hello.doxygen + </pre> + + <p>While the generated documentation can be useful as is, we can + go one step further and link (using the Doxygen tags mechanism) + the documentation for our object model with the documentation + for the XSD runtime library which defines C++ classes for the + built-in XML Schema types. This way we can seamlessly browse + between documentation for the <code>hello_t</code> class which + is generated by the XSD compiler and the <code>xml_schema::string</code> + class which is defined in the XSD runtime library. The Doxygen + configuration file for the XSD runtime is provided with the XSD + distribution.</p> + + <p>You can view the result of the steps described in this section + on the <a href="http://www.codesynthesis.com/projects/xsd/documentation/cxx/tree/hello/html/annotated.html">Hello + Example Documentation</a> page.</p> + + <!-- Chapater 3 --> + + + <h1><a name="3">3 Overall Mapping Configuration</a></h1> + + <p>The C++/Tree mapping has a number of configuration parameters that + determine the overall properties and behavior of the generated code. + Configuration parameters are specified with the XSD command line + options. This chapter describes configuration aspects that are most + commonly encountered by application developers. These include: the + C++ standard, the character type that is used by the generated code, + handling of vocabularies that use XML Schema polymorphism, XML Schema + to C++ namespace mapping, and thread safety. For more ways to configure + the generated code refer to the + <a href="http://www.codesynthesis.com/projects/xsd/documentation/xsd.xhtml">XSD + Compiler Command Line Manual</a>. + </p> + + <h2><a name="3.1">3.1 C++ Standard</a></h2> + + <p>The C++/Tree mapping provides support for ISO/IEC C++ 1998/2003 (C++98) + and ISO/IEC C++ 2011 (C++11). To select the C++ standard for the + generated code we use the <code>--std</code> XSD compiler command + line option. While the majority of the examples in this guide use + C++98, support for the new functionality and library components + introduced in C++11 are discussed throughout the document.</p> + + <h2><a name="3.2">3.2 Character Type and Encoding</a></h2> + + <p>The C++/Tree mapping has built-in support for two character types: + <code>char</code> and <code>wchar_t</code>. You can select the + character type with the <code>--char-type</code> command line + option. The default character type is <code>char</code>. The + character type affects all string and string-based types that + are used in the mapping. These include the string-based built-in + XML Schema types, exception types, stream types, etc.</p> + + <p>Another aspect of the mapping that depends on the character type + is character encoding. For the <code>char</code> character type + the default encoding is UTF-8. Other supported encodings are + ISO-8859-1, Xerces-C++ Local Code Page (LPC), as well as + custom encodings. You can select which encoding should be used + in the object model with the <code>--char-encoding</code> command + line option.</p> + + <p>For the <code>wchar_t</code> character type the encoding is + automatically selected between UTF-16 and UTF-32/UCS-4 depending + on the size of the <code>wchar_t</code> type. On some platforms + (for example, Windows with Visual C++ and AIX with IBM XL C++) + <code>wchar_t</code> is 2 bytes long. For these platforms the + encoding is UTF-16. On other platforms <code>wchar_t</code> is 4 bytes + long and UTF-32/UCS-4 is used.</p> + + <p>Note also that the character encoding that is used in the object model + is independent of the encodings used in input and output XML. In fact, + all three (object mode, input XML, and output XML) can have different + encodings.</p> + + <h2><a name="3.3">3.3 Support for Polymorphism</a></h2> + + <p>By default XSD generates non-polymorphic code. If your vocabulary + uses XML Schema polymorphism in the form of <code>xsi:type</code> + and/or substitution groups, then you will need to compile + your schemas with the <code>--generate-polymorphic</code> option + to produce polymorphism-aware code. For more information on + working with polymorphic object models, refer to + <a href="http://www.codesynthesis.com/projects/xsd/documentation/cxx/tree/manual/#2.11">Section 2.11, + "Mapping for <code>xsi:type</code> and Substitution Groups"</a> in + the C++/Tree Mapping User Manual.</p> + + <h2><a name="3.4">3.4 Namespace Mapping</a></h2> + + <p>XSD maps XML namespaces specified in the <code>targetNamespace</code> + attribute in XML Schema to one or more nested C++ namespaces. By + default, a namespace URI is mapped to a sequence of C++ namespace + names by removing the protocol and host parts and splitting the + rest into a sequence of names with <code>'/'</code> as the name + separator.</p> + + <p>The default mapping of namespace URIs to C++ namespaces + can be altered using the <code>--namespace-map</code> and + <code>--namespace-regex</code> compiler options. For example, + to map namespace URI <code>http://www.codesynthesis.com/my</code> to + C++ namespace <code>cs::my</code>, we can use the following option:</p> + + <pre class="terminal"> +--namespace-map http://www.codesynthesis.com/my=cs::my + </pre> + + <p>A vocabulary without a namespace is mapped to the global scope. This + also can be altered with the above options by using an empty name + for the XML namespace:</p> + + <pre class="terminal"> +--namespace-map =cs + </pre> + + <h2><a name="3.5">3.5 Thread Safety</a></h2> + + <p>XSD-generated code is thread-safe in the sense that you can + use different instantiations of the object model in several + threads concurrently. This is possible due to the generated + code not relying on any writable global variables. If you need + to share the same object between several threads then you will + need to provide some form of synchronization. One approach would + be to use the generated code customization mechanisms to embed + synchronization primitives into the generated C++ classes. For more + information on generated code customization refer to the + <a href="http://wiki.codesynthesis.com/Tree/Customization_guide">C++/Tree + Mapping Customization Guide</a>.</p> + + <p>If you also would like to call parsing and/or serialization + functions from several threads potentially concurrently, then + you will need to make sure the Xerces-C++ runtime is initialized + and terminated only once. The easiest way to do this is to + initialize/terminate Xerces-C++ from <code>main()</code> when + there are no threads yet/anymore:</p> + + <pre class="c++"> +#include <xercesc/util/PlatformUtils.hpp> + +int +main () +{ + xercesc::XMLPlatformUtils::Initialize (); + + { + // Start/terminate threads and parse/serialize here. + } + + xercesc::XMLPlatformUtils::Terminate (); +} + </pre> + + <p>Because you initialize the Xerces-C++ runtime yourself you should + also pass the <code>xml_schema::flags::dont_initialize</code> flag + to parsing and serialization functions. See <a href="#5">Chapter 5, + "Parsing"</a> and <a href="#6">Chapter 6, "Serialization"</a> for + more information.</p> + + + <!-- Chapater 4 --> + + + <h1><a name="4">4 Working with Object Models</a></h1> + + <p>As we have seen in the previous chapters, the XSD compiler generates + a C++ class for each type defined in XML Schema. Together these classes + constitute an object model for an XML vocabulary. In this chapter we + will take a closer look at different elements that comprise an + object model class as well as how to create, access, and modify + object models.</p> + + <p>In this and subsequent chapters we will use the following schema + that describes a collection of person records. We save it in + <code>people.xsd</code>:</p> + + <pre class="xml"> +<?xml version="1.0"?> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> + + <xs:simpleType name="gender_t"> + <xs:restriction base="xs:string"> + <xs:enumeration value="male"/> + <xs:enumeration value="female"/> + </xs:restriction> + </xs:simpleType> + + <xs:complexType name="person_t"> + <xs:sequence> + <xs:element name="first-name" type="xs:string"/> + <xs:element name="middle-name" type="xs:string" minOccurs="0"/> + <xs:element name="last-name" type="xs:string"/> + <xs:element name="gender" type="gender_t"/> + <xs:element name="age" type="xs:short"/> + </xs:sequence> + <xs:attribute name="id" type="xs:unsignedInt" use="required"/> + </xs:complexType> + + <xs:complexType name="people_t"> + <xs:sequence> + <xs:element name="person" type="person_t" maxOccurs="unbounded"/> + </xs:sequence> + </xs:complexType> + + <xs:element name="people" type="people_t"/> + +</xs:schema> + </pre> + + <p>A sample XML instance to go along with this schema is saved + in <code>people.xml</code>:</p> + + <pre class="xml"> +<?xml version="1.0"?> +<people xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="people.xsd"> + + <person id="1"> + <first-name>John</first-name> + <last-name>Doe</last-name> + <gender>male</gender> + <age>32</age> + </person> + + <person id="2"> + <first-name>Jane</first-name> + <middle-name>Mary</middle-name> + <last-name>Doe</last-name> + <gender>female</gender> + <age>28</age> + </person> + +</people> + </pre> + + <p>Compiling <code>people.xsd</code> with the XSD compiler results + in three generated C++ classes: <code>gender_t</code>, + <code>person_t</code>, and <code>people_t</code>. + The <code>gender_t</code> class is modelled after the C++ + <code>enum</code> type. Its definition is presented below:</p> + + <pre class="c++"> +class gender_t: public xml_schema::string +{ +public: + enum value + { + male, + female + }; + + gender_t (value); + gender_t (const xml_schema::string&); + + gender_t& + operator= (value); + + operator value () const; +}; + </pre> + + <p>The following listing shows how we can use this type:</p> + + <pre class="c++"> +gender_t m (gender_t::male); +gender_t f ("female"); + +if (m == "female" || f == gender_t::male) +{ + ... +} + +switch (m) +{ +case gender_t::male: + { + ... + } +case gender_t::female: + { + ... + } +} + </pre> + + <p>The other two classes will be examined in detail in the subsequent + sections.</p> + + <h2><a name="4.1">4.1 Attribute and Element Cardinalities</a></h2> + + <p>As we have seen in the previous chapters, XSD generates a different + set of type definitions and member functions for elements with + different cardinalities. The C++/Tree mapping divides all the possible + element and attribute cardinalities into three cardinality classes: + <em>one</em>, <em>optional</em>, and <em>sequence</em>.</p> + + <p>The <em>one</em> cardinality class covers all elements that should + occur exactly once as well as required attributes. In our + example, the <code>first-name</code>, <code>last-name</code>, + <code>gender</code>, and <code>age</code> elements as well as + the <code>id</code> attribute belong to this cardinality class. + The following code fragment shows type definitions as well as the + accessor and modifier functions that are generated for the + <code>gender</code> element in the <code>person_t</code> class:</p> + + <pre class="c++"> +class person_t +{ + // gender + // + typedef gender_t gender_type; + + const gender_type& + gender () const; + + gender_type& + gender (); + + void + gender (const gender_type&); +}; + </pre> + + <p>The <code>gender_type</code> type is an alias for the element's type. + The first two accessor functions return read-only (constant) and + read-write references to the element's value, respectively. The + modifier function sets the new value for the element.</p> + + <p>The <em>optional</em> cardinality class covers all elements that + can occur zero or one time as well as optional attributes. In our + example, the <code>middle-name</code> element belongs to this + cardinality class. The following code fragment shows the type + definitions as well as the accessor and modifier functions that + are generated for this element in the <code>person_t</code> class:</p> + + <pre class="c++"> +class person_t +{ + // middle-name + // + typedef xml_schema::string middle_name_type; + typedef xsd::optional<middle_name_type> middle_name_optional; + + const middle_name_optional& + middle_name () const; + + middle_name_optional& + middle_name (); + + void + middle_name (const middle_name_type&); + + void + middle_name (const middle_name_optional&); +}; + </pre> + + <p>As with the <code>gender</code> element, <code>middle_name_type</code> + is an alias for the element's type. The <code>middle_name_optional</code> + type is a container for the element's optional value. It can be queried + for the presence of the value using the <code>present()</code> function. + The value itself can be retrieved using the <code>get()</code> + accessor and set using the <code>set()</code> modifier. The container + can be reverted to the value not present state with the call to the + <code>reset()</code> function. The following example shows how we + can use this container:</p> + + <pre class="c++"> +person_t::middle_name_optional n ("John"); + +if (n.present ()) +{ + cout << n.get () << endl; +} + +n.set ("Jane"); +n.reset (); + </pre> + + + <p>Unlike the <em>one</em> cardinality class, the accessor functions + for the <em>optional</em> class return read-only (constant) and + read-write references to the container instead of the element's + value directly. The modifier functions set the new value for the + element.</p> + + <p>Finally, the <em>sequence</em> cardinality class covers all elements + that can occur more than once. In our example, the + <code>person</code> element in the <code>people_t</code> type + belongs to this cardinality class. The following code fragment shows + the type definitions as well as the accessor and modifier functions + that are generated for this element in the <code>people_t</code> + class:</p> + + <pre class="c++"> +class people_t +{ + // person + // + typedef person_t person_type; + typedef xsd::sequence<person_type> person_sequence; + typedef person_sequence::iterator person_iterator; + typedef person_sequence::const_iterator person_const_iterator; + + const person_sequence& + person () const; + + person_sequence& + person (); + + void + person (const person_sequence&); +}; + </pre> + + <p>Identical to the other cardinality classes, <code>person_type</code> + is an alias for the element's type. The <code>person_sequence</code> + type is a sequence container for the element's values. It is based + on and has the same interface as <code>std::vector</code> and + therefore can be used in similar ways. The <code>person_iterator</code> + and <code>person_const_iterator</code> types are read-only + (constant) and read-write iterators for the <code>person_sequence</code> + container.</p> + + <p>Similar to the <em>optional</em> cardinality class, the + accessor functions for the <em>sequence</em> class return + read-only (constant) and read-write references to the sequence + container. The modifier functions copies the entries from + the passed sequence.</p> + + <p>C++/Tree is a "flattening" mapping in a sense that many levels of + nested compositors (<code>choice</code> and <code>sequence</code>), + all potentially with their own cardinalities, are in the end mapped + to a flat set of elements with one of the three cardinality classes + discussed above. While this results in a simple and easy to use API + for most types, in certain cases, the order of elements in the actual + XML documents is not preserved once parsed into the object model. To + overcome this limitation we can mark certain schema types, for which + content order is not sufficiently preserved, as ordered. For more + information on this functionality refer to + <a href="http://www.codesynthesis.com/projects/xsd/documentation/cxx/tree/manual/#2.8.4">Section + 2.8.4, "Element Order"</a> in the C++/Tree Mapping User Manual.</p> + + <p>For complex schemas with many levels of nested compositors + (<code>choice</code> and <code>sequence</code>) it can also + be hard to deduce the cardinality class of a particular element. + The generated Doxygen documentation can greatly help with + this task. For each element and attribute the documentation + clearly identifies its cardinality class. Alternatively, you + can study the generated header files to find out the cardinality + class of a particular attribute or element.</p> + + <p>In the next sections we will examine how to access and modify + information stored in an object model using accessor and modifier + functions described in this section.</p> + + <h2><a name="4.2">4.2 Accessing the Object Model</a></h2> + + <p>In this section we will learn how to get to the information + stored in the object model for our person records vocabulary. + The following application accesses and prints the contents + of the <code>people.xml</code> file:</p> + + <pre class="c++"> +#include <iostream> +#include "people.hxx" + +using namespace std; + +int +main () +{ + auto_ptr<people_t> ppl (people ("people.xml")); + + // Iterate over individual person records. + // + people_t::person_sequence& ps (ppl->person ()); + + for (people_t::person_iterator i (ps.begin ()); i != ps.end (); ++i) + { + person_t& p (*i); + + // Print names: first-name and last-name are required elements, + // middle-name is optional. + // + cout << "name: " << p.first_name () << " "; + + if (p.middle_name ().present ()) + cout << p.middle_name ().get () << " "; + + cout << p.last_name () << endl; + + // Print gender, age, and id which are all required. + // + cout << "gender: " << p.gender () << endl + << "age: " << p.age () << endl + << "id: " << p.id () << endl + << endl; + } +} + </pre> + + <p>This code shows common patterns of accessing elements and attributes + with different cardinality classes. For the sequence element + (<code>person</code> in <code>people_t</code>) we first obtain a + reference to the container and then iterate over individual + records. The values of elements and attributes with the + <em>one</em> cardinality class (<code>first-name</code>, + <code>last-name</code>, <code>gender</code>, <code>age</code>, + and <code>id</code>) can be obtained directly by calling the + corresponding accessor functions. For the optional element + <code>middle-name</code> we first check if the value is present + and only then call <code>get()</code> to retrieve it.</p> + + <p>Note that when we want to reduce typing by creating a variable + representing a fragment of the object model that we are currently + working with (<code>ps</code> and <code>p</code> above), we obtain + a reference to that fragment instead of making a potentially + expensive copy. This is generally a good rule to follow when + creating high-performance applications.</p> + + <p>If we run the above application on our sample + <code>people.xml</code>, the output looks as follows:</p> + + <pre class="terminal"> +name: John Doe +gender: male +age: 32 +id: 1 + +name: Jane Mary Doe +gender: female +age: 28 +id: 2 + </pre> + + + <h2><a name="4.3">4.3 Modifying the Object Model</a></h2> + + <p>In this section we will learn how to modify the information + stored in the object model for our person records vocabulary. + The following application changes the contents of the + <code>people.xml</code> file:</p> + + <pre class="c++"> +#include <iostream> +#include "people.hxx" + +using namespace std; + +int +main () +{ + auto_ptr<people_t> ppl (people ("people.xml")); + + // Iterate over individual person records and increment + // the age. + // + people_t::person_sequence& ps (ppl->person ()); + + for (people_t::person_iterator i (ps.begin ()); i != ps.end (); ++i) + { + // Alternative way: i->age ()++; + // + i->age (i->age () + 1); + } + + // Add middle-name to the first record and remove it from + // the second. + // + person_t& john (ps[0]); + person_t& jane (ps[1]); + + john.middle_name ("Mary"); + jane.middle_name ().reset (); + + // Add another John record. + // + ps.push_back (john); + + // Serialize the modified object model to XML. + // + xml_schema::namespace_infomap map; + map[""].name = ""; + map[""].schema = "people.xsd"; + + people (cout, *ppl, map); +} + </pre> + + <p>The first modification the above application performs is iterating + over person records and incrementing the age value. This code + fragment shows how to modify the value of a required attribute + or element. The next modification shows how to set a new value + for the optional <code>middle-name</code> element as well + as clear its value. Finally the example adds a copy of the + John Doe record to the <code>person</code> element sequence.</p> + + <p>Note that in this case using references for the <code>ps</code>, + <code>john</code>, and <code>jane</code> variables is no longer + a performance improvement but a requirement for the application + to function correctly. If we hadn't used references, all our changes + would have been made on copies without affecting the object model.</p> + + <p>If we run the above application on our sample <code>people.xml</code>, + the output looks as follows:</p> + + <pre class="xml"> +<?xml version="1.0"?> +<people xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="people.xsd"> + + <person id="1"> + <first-name>John</first-name> + <middle-name>Mary</middle-name> + <last-name>Doe</last-name> + <gender>male</gender> + <age>33</age> + </person> + + <person id="2"> + <first-name>Jane</first-name> + <last-name>Doe</last-name> + <gender>female</gender> + <age>29</age> + </person> + + <person id="1"> + <first-name>John</first-name> + <middle-name>Mary</middle-name> + <last-name>Doe</last-name> + <gender>male</gender> + <age>33</age> + </person> + +</people> + </pre> + + + <h2><a name="4.4">4.4 Creating the Object Model from Scratch</a></h2> + + <p>In this section we will learn how to create a new object model + for our person records vocabulary. The following application + recreates the content of the original <code>people.xml</code> + file:</p> + + <pre class="c++"> +#include <iostream> +#include "people.hxx" + +using namespace std; + +int +main () +{ + people_t ppl; + people_t::person_sequence& ps (ppl.person ()); + + // Add the John Doe record. + // + ps.push_back ( + person_t ("John", // first-name + "Doe", // last-name + gender_t::male, // gender + 32, // age + 1)); + + // Add the Jane Doe record. + // + ps.push_back ( + person_t ("Jane", // first-name + "Doe", // last-name + gender_t::female, // gender + 28, // age + 2)); // id + + // Add middle name to the Jane Doe record. + // + person_t& jane (ps.back ()); + jane.middle_name ("Mary"); + + // Serialize the object model to XML. + // + xml_schema::namespace_infomap map; + map[""].name = ""; + map[""].schema = "people.xsd"; + + people (cout, ppl, map); +} + </pre> + + <p>The only new part in the above application is the calls + to the <code>people_t</code> and <code>person_t</code> + constructors. As a general rule, for each C++ class + XSD generates a constructor with initializers + for each element and attribute belonging to the <em>one</em> + cardinality class. For our vocabulary, the following + constructors are generated:</p> + + <pre class="c++"> +class person_t +{ + person_t (const first_name_type&, + const last_name_type&, + const gender_type&, + const age_type&, + const id_type&); +}; + +class people_t +{ + people_t (); +}; + </pre> + + <p>Note also that we set the <code>middle-name</code> element + on the Jane Doe record by obtaining a reference to that record + in the object model and setting the <code>middle-name</code> + value on it. This is a general rule that should be followed + in order to obtain the best performance: if possible, + direct modifications to the object model should be preferred + to modifications on temporaries with subsequent copying. The + following code fragment shows a semantically equivalent but + slightly slower version:</p> + + <pre class="c++"> +// Add the Jane Doe record. +// +person_t jane ("Jane", // first-name + "Doe", // last-name + gender_t::female, // gender + 28, // age + 2); // id + +jane.middle_name ("Mary"); + +ps.push_back (jane); + </pre> + + <p>We can also go one step further to reduce copying and improve + the performance of our application by using the non-copying + <code>push_back()</code> function which assumes ownership + of the passed objects:</p> + + <pre class="c++"> +// Add the John Doe record. C++98 version. +// +auto_ptr<person_t> john_p ( + new person_t ("John", // first-name + "Doe", // last-name + gender_t::male, // gender + 32, // age + 1)); +ps.push_back (john_p); // assumes ownership + +// Add the Jane Doe record. C++11 version +// +unique_ptr<person_t> jane_p ( + new person_t ("Jane", // first-name + "Doe", // last-name + gender_t::female, // gender + 28, // age + 2)); // id +ps.push_back (std::move (jane_p)); // assumes ownership + </pre> + + <p>For more information on the non-copying modifier functions refer to + <a href="http://www.codesynthesis.com/projects/xsd/documentation/cxx/tree/manual/#2.8">Section + 2.8, "Mapping for Local Elements and Attributes"</a> in the C++/Tree Mapping + User Manual. The above application produces the following output:</p> + + <pre class="xml"> +<?xml version="1.0" ?> +<people xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="people.xsd"> + + <person id="1"> + <first-name>John</first-name> + <last-name>Doe</last-name> + <gender>male</gender> + <age>32</age> + </person> + + <person id="2"> + <first-name>Jane</first-name> + <middle-name>Mary</middle-name> + <last-name>Doe</last-name> + <gender>female</gender> + <age>28</age> + </person> + +</people> + </pre> + + <h2><a name="4.5">4.5 Mapping for the Built-in XML Schema Types</a></h2> + + <p>Our person record vocabulary uses several built-in XML Schema + types: <code>string</code>, <code>short</code>, and + <code>unsignedInt</code>. Until now we haven't talked about + the mapping of built-in XML Schema types to C++ types and how + to work with them. This section provides an overview + of the built-in types. For more detailed information refer + to <a href="http://www.codesynthesis.com/projects/xsd/documentation/cxx/tree/manual/#2.5">Section + 2.5, "Mapping for Built-in Data Types"</a> in the C++/Tree Mapping + User Manual.</p> + + <p>In XML Schema, built-in types are defined in the XML Schema namespace. + By default, the C++/Tree mapping maps this namespace to C++ + namespace <code>xml_schema</code> (this mapping can be altered + with the <code>--namespace-map</code> option). The following table + summarizes the mapping of XML Schema built-in types to C++ types:</p> + + <!-- border="1" is necessary for html2ps --> + <table id="builtin" border="1"> + <tr> + <th>XML Schema type</th> + <th>Alias in the <code>xml_schema</code> namespace</th> + <th>C++ type</th> + </tr> + + <tr> + <th colspan="3">fixed-length integral types</th> + </tr> + <!-- 8-bit --> + <tr> + <td><code>byte</code></td> + <td><code>byte</code></td> + <td><code>signed char</code></td> + </tr> + <tr> + <td><code>unsignedByte</code></td> + <td><code>unsigned_byte</code></td> + <td><code>unsigned char</code></td> + </tr> + + <!-- 16-bit --> + <tr> + <td><code>short</code></td> + <td><code>short_</code></td> + <td><code>short</code></td> + </tr> + <tr> + <td><code>unsignedShort</code></td> + <td><code>unsigned_short</code></td> + <td><code>unsigned short</code></td> + </tr> + + <!-- 32-bit --> + <tr> + <td><code>int</code></td> + <td><code>int_</code></td> + <td><code>int</code></td> + </tr> + <tr> + <td><code>unsignedInt</code></td> + <td><code>unsigned_int</code></td> + <td><code>unsigned int</code></td> + </tr> + + <!-- 64-bit --> + <tr> + <td><code>long</code></td> + <td><code>long_</code></td> + <td><code>long long</code></td> + </tr> + <tr> + <td><code>unsignedLong</code></td> + <td><code>unsigned_long</code></td> + <td><code>unsigned long long</code></td> + </tr> + + <tr> + <th colspan="3">arbitrary-length integral types</th> + </tr> + <tr> + <td><code>integer</code></td> + <td><code>integer</code></td> + <td><code>long long</code></td> + </tr> + <tr> + <td><code>nonPositiveInteger</code></td> + <td><code>non_positive_integer</code></td> + <td><code>long long</code></td> + </tr> + <tr> + <td><code>nonNegativeInteger</code></td> + <td><code>non_negative_integer</code></td> + <td><code>unsigned long long</code></td> + </tr> + <tr> + <td><code>positiveInteger</code></td> + <td><code>positive_integer</code></td> + <td><code>unsigned long long</code></td> + </tr> + <tr> + <td><code>negativeInteger</code></td> + <td><code>negative_integer</code></td> + <td><code>long long</code></td> + </tr> + + <tr> + <th colspan="3">boolean types</th> + </tr> + <tr> + <td><code>boolean</code></td> + <td><code>boolean</code></td> + <td><code>bool</code></td> + </tr> + + <tr> + <th colspan="3">fixed-precision floating-point types</th> + </tr> + <tr> + <td><code>float</code></td> + <td><code>float_</code></td> + <td><code>float</code></td> + </tr> + <tr> + <td><code>double</code></td> + <td><code>double_</code></td> + <td><code>double</code></td> + </tr> + + <tr> + <th colspan="3">arbitrary-precision floating-point types</th> + </tr> + <tr> + <td><code>decimal</code></td> + <td><code>decimal</code></td> + <td><code>double</code></td> + </tr> + + <tr> + <th colspan="3">string types</th> + </tr> + <tr> + <td><code>string</code></td> + <td><code>string</code></td> + <td>type derived from <code>std::basic_string</code></td> + </tr> + <tr> + <td><code>normalizedString</code></td> + <td><code>normalized_string</code></td> + <td>type derived from <code>string</code></td> + </tr> + <tr> + <td><code>token</code></td> + <td><code>token</code></td> + <td>type derived from <code>normalized_string</code></td> + </tr> + <tr> + <td><code>Name</code></td> + <td><code>name</code></td> + <td>type derived from <code>token</code></td> + </tr> + <tr> + <td><code>NMTOKEN</code></td> + <td><code>nmtoken</code></td> + <td>type derived from <code>token</code></td> + </tr> + <tr> + <td><code>NMTOKENS</code></td> + <td><code>nmtokens</code></td> + <td>type derived from <code>sequence<nmtoken></code></td> + </tr> + <tr> + <td><code>NCName</code></td> + <td><code>ncname</code></td> + <td>type derived from <code>name</code></td> + </tr> + <tr> + <td><code>language</code></td> + <td><code>language</code></td> + <td>type derived from <code>token</code></td> + </tr> + + <tr> + <th colspan="3">qualified name</th> + </tr> + <tr> + <td><code>QName</code></td> + <td><code>qname</code></td> + <td><code>xml_schema::qname</code></td> + </tr> + + <tr> + <th colspan="3">ID/IDREF types</th> + </tr> + <tr> + <td><code>ID</code></td> + <td><code>id</code></td> + <td>type derived from <code>ncname</code></td> + </tr> + <tr> + <td><code>IDREF</code></td> + <td><code>idref</code></td> + <td>type derived from <code>ncname</code></td> + </tr> + <tr> + <td><code>IDREFS</code></td> + <td><code>idrefs</code></td> + <td>type derived from <code>sequence<idref></code></td> + </tr> + + <tr> + <th colspan="3">URI types</th> + </tr> + <tr> + <td><code>anyURI</code></td> + <td><code>uri</code></td> + <td>type derived from <code>std::basic_string</code></td> + </tr> + + <tr> + <th colspan="3">binary types</th> + </tr> + <tr> + <td><code>base64Binary</code></td> + <td><code>base64_binary</code></td> + <td><code>xml_schema::base64_binary</code></td> + </tr> + <tr> + <td><code>hexBinary</code></td> + <td><code>hex_binary</code></td> + <td><code>xml_schema::hex_binary</code></td> + </tr> + + <tr> + <th colspan="3">date/time types</th> + </tr> + <tr> + <td><code>date</code></td> + <td><code>date</code></td> + <td><code>xml_schema::date</code></td> + </tr> + <tr> + <td><code>dateTime</code></td> + <td><code>date_time</code></td> + <td><code>xml_schema::date_time</code></td> + </tr> + <tr> + <td><code>duration</code></td> + <td><code>duration</code></td> + <td><code>xml_schema::duration</code></td> + </tr> + <tr> + <td><code>gDay</code></td> + <td><code>gday</code></td> + <td><code>xml_schema::gday</code></td> + </tr> + <tr> + <td><code>gMonth</code></td> + <td><code>gmonth</code></td> + <td><code>xml_schema::gmonth</code></td> + </tr> + <tr> + <td><code>gMonthDay</code></td> + <td><code>gmonth_day</code></td> + <td><code>xml_schema::gmonth_day</code></td> + </tr> + <tr> + <td><code>gYear</code></td> + <td><code>gyear</code></td> + <td><code>xml_schema::gyear</code></td> + </tr> + <tr> + <td><code>gYearMonth</code></td> + <td><code>gyear_month</code></td> + <td><code>xml_schema::gyear_month</code></td> + </tr> + <tr> + <td><code>time</code></td> + <td><code>time</code></td> + <td><code>xml_schema::time</code></td> + </tr> + + <tr> + <th colspan="3">entity types</th> + </tr> + <tr> + <td><code>ENTITY</code></td> + <td><code>entity</code></td> + <td>type derived from <code>name</code></td> + </tr> + <tr> + <td><code>ENTITIES</code></td> + <td><code>entities</code></td> + <td>type derived from <code>sequence<entity></code></td> + </tr> + </table> + + <p>As you can see from the table above a number of built-in + XML Schema types are mapped to fundamental C++ types such + as <code>int</code> or <code>bool</code>. All string-based + XML Schema types are mapped to C++ types that are derived + from either <code>std::string</code> or + <code>std::wstring</code>, depending on the character + type selected. For access and modification purposes these + types can be treated as <code>std::string</code>. A number + of built-in types, such as <code>qname</code>, the binary + types, and the date/time types do not have suitable + fundamental or standard C++ types to map to. As a result, + these types are implemented from scratch in the XSD runtime. + For more information on their interfaces refer to + <a href="http://www.codesynthesis.com/projects/xsd/documentation/cxx/tree/manual/#2.5">Section + 2.5, "Mapping for Built-in Data Types"</a> in the C++/Tree Mapping + User Manual.</p> + + + <!-- Chapater 5 --> + + + <h1><a name="5">5 Parsing</a></h1> + + <p>We have already seen how to parse XML to an object model in this guide + before. In this chapter we will discuss the parsing topic in more + detail.</p> + + <p>By default, the C++/Tree mapping provides a total of 14 overloaded + parsing functions. They differ in the input methods used to + read XML as well as the error reporting mechanisms. It is also possible + to generate types for root elements instead of parsing and serialization + functions. This may be useful if your XML vocabulary has multiple + root elements. For more information on element types refer to + <a href="http://www.codesynthesis.com/projects/xsd/documentation/cxx/tree/manual/#2.9">Section + 2.9, "Mapping for Global Elements"</a> in the C++/Tree Mapping User + Manual.</p> + + + <p>In this section we will discuss the most commonly used versions of + the parsing functions. For a comprehensive description of parsing + refer to <a href="http://www.codesynthesis.com/projects/xsd/documentation/cxx/tree/manual/#3">Chapter + 3, "Parsing"</a> in the C++/Tree Mapping User Manual. For the <code>people</code> + global element from our person record vocabulary, we will concentrate + on the following three parsing functions:</p> + + <pre class="c++"> +std::[auto|unique]_ptr<people_t> +people (const std::string& uri, + xml_schema::flags f = 0, + const xml_schema::properties& p = xml_schema::properties ()); + +std::[auto|unique]_ptr<people_t> +people (std::istream& is, + xml_schema::flags f = 0, + const xml_schema::properties& p = xml_schema::properties ()); + +std::[auto|unique]_ptr<people_t> +people (std::istream& is, + const std::string& resource_id, + xml_schema::flags f = 0, + const xml_schema::properties& p = ::xml_schema::properties ()); + </pre> + + <p>The first function parses a local file or a URI. We have already + used this parsing function in the previous chapters. The second + and third functions read XML from a standard input stream. The + last function also requires a resource id. This id is used to + identify the XML document being parser in diagnostics messages + as well as to resolve relative paths to other documents (for example, + schemas) that might be referenced from the XML document.</p> + + <p>The last two arguments to all three parsing functions are parsing + flags and properties. The flags argument provides a number of ways + to fine-tune the parsing process. The properties argument allows + to pass additional information to the parsing functions. We will + use these two arguments in <a href="#5.1">Section 5.1, "XML Schema + Validation and Searching"</a> below. All three functions return + the object model as either <code>std::auto_ptr</code> (C++98) or + <code>std::unique_ptr</code> (C++11), depending on the C++ standard + selected (<code>--std</code> XSD compiler option). The following + example shows how we can use the above parsing functions:</p> + + <pre class="c++"> +using std::auto_ptr; + +// Parse a local file or URI. +// +auto_ptr<people_t> p1 (people ("people.xml")); +auto_ptr<people_t> p2 (people ("http://example.com/people.xml")); + +// Parse a local file via ifstream. +// +std::ifstream ifs ("people.xml"); +auto_ptr<people_t> p3 (people (ifs, "people.xml")); + +// Parse an XML string. +// +std::string str ("..."); // XML in a string. +std::istringstream iss (str); +auto_ptr<people_t> p4 (people (iss)); + </pre> + + + <h2><a name="5.1">5.1 XML Schema Validation and Searching</a></h2> + + <p>The C++/Tree mapping relies on the underlying Xerces-C++ XML + parser for full XML document validation. The XML Schema + validation is enabled by default and can be disabled by + passing the <code>xml_schema::flags::dont_validate</code> + flag to the parsing functions, for example:</p> + + <pre class="c++"> +auto_ptr<people_t> p ( + people ("people.xml", xml_schema::flags::dont_validate)); + </pre> + + <p>Even when XML Schema validation is disabled, the generated + code still performs a number of checks to prevent + construction of an inconsistent object model (for example, an + object model with missing required attributes or elements).</p> + + <p>When XML Schema validation is enabled, the XML parser needs + to locate a schema to validate against. There are several + methods to provide the schema location information to the + parser. The easiest and most commonly used method is to + specify schema locations in the XML document itself + with the <code>schemaLocation</code> or + <code>noNamespaceSchemaLocation</code> attributes, for example:</p> + + <pre class="xml"> +<?xml version="1.0" ?> +<people xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="people.xsd" + xsi:schemaLocation="http://www.w3.org/XML/1998/namespace xml.xsd"> + </pre> + + <p>As you might have noticed, we used this method in all the sample XML + documents presented in this guide up until now. Note that the + schema locations specified with these two attributes are relative + to the document's path unless they are absolute URIs (that is + start with <code>http://</code>, <code>file://</code>, etc.). + In particular, if you specify just file names as your schema + locations, as we did above, then the schemas should reside in + the same directory as the XML document itself.</p> + + <p>Another method of providing the schema location information + is via the <code>xml_schema::properties</code> argument, as + shown in the following example:</p> + + <pre class="c++"> +xml_schema::properties props; +props.no_namespace_schema_location ("people.xsd"); +props.schema_location ("http://www.w3.org/XML/1998/namespace", "xml.xsd"); + +auto_ptr<people_t> p (people ("people.xml", 0, props)); + </pre> + + <p>The schema locations provided with this method overrides + those specified in the XML document. As with the previous + method, the schema locations specified this way are + relative to the document's path unless they are absolute URIs. + In particular, if you want to use local schemas that are + not related to the document being parsed, then you will + need to use the <code>file://</code> URI. The following + example shows how to use schemas that reside in the current + working directory:</p> + + <pre class="c++"> +#include <unistd.h> // getcwd +#include <limits.h> // PATH_MAX + +char cwd[PATH_MAX]; +if (getcwd (cwd, PATH_MAX) == 0) +{ + // Buffer too small? +} + +xml_schema::properties props; + +props.no_namespace_schema_location ( + "file:///" + std::string (cwd) + "/people.xsd"); + +props.schema_location ( + "http://www.w3.org/XML/1998/namespace", + "file:///" + std::string (cwd) + "/xml.xsd"); + +auto_ptr<people_t> p (people ("people.xml", 0, props)); + </pre> + + <p>A third method is the most useful if you are planning to parse + several XML documents of the same vocabulary. In that case + it may be beneficial to pre-parse and cache the schemas in + the XML parser which can then be used to parse all documents + without re-parsing the schemas. For more information on + this method refer to the <code>caching</code> example in the + <code>examples/cxx/tree/</code> directory of the XSD + distribution. It is also possible to convert the schemas into + a pre-compiled binary representation and embed this representation + directly into the application executable. With this approach your + application can perform XML Schema validation without depending on + any external schema files. For more information on how to achieve + this refer to the <code>embedded</code> example in the + <code>examples/cxx/tree/</code> directory of the XSD distribution.</p> + + <p>When the XML parser cannot locate a schema for the + XML document, the validation fails and XML document + elements and attributes for which schema definitions could + not be located are reported in the diagnostics. For + example, if we remove the <code>noNamespaceSchemaLocation</code> + attribute in <code>people.xml</code> from the previous chapter, + then we will get the following diagnostics if we try to parse + this file with validation enabled:</p> + + <pre class="terminal"> +people.xml:2:63 error: no declaration found for element 'people' +people.xml:4:18 error: no declaration found for element 'person' +people.xml:4:18 error: attribute 'id' is not declared for element 'person' +people.xml:5:17 error: no declaration found for element 'first-name' +people.xml:6:18 error: no declaration found for element 'middle-name' +people.xml:7:16 error: no declaration found for element 'last-name' +people.xml:8:13 error: no declaration found for element 'gender' +people.xml:9:10 error: no declaration found for element 'age' + </pre> + + <h2><a name="5.2">5.2 Error Handling</a></h2> + + <p>The parsing functions offer a number of ways to handle error conditions + with the C++ exceptions being the most commonly used mechanism. All + C++/Tree exceptions derive from common base <code>xml_schema::exception</code> + which in turn derives from <code>std::exception</code>. The easiest + way to uniformly handle all possible C++/Tree exceptions and print + detailed information about the error is to catch and print + <code>xml_schema::exception</code>, as shown in the following + example:</p> + + <pre class="c++"> +try +{ + auto_ptr<people_t> p (people ("people.xml")); +} +catch (const xml_schema::exception& e) +{ + cerr << e << endl; +} + </pre> + + <p>Each individual C++/Tree exception also allows you to obtain + error details programmatically. For example, the + <code>xml_schema::parsing</code> exception is thrown when + the XML parsing and validation in the underlying XML parser + fails. It encapsulates various diagnostics information + such as the file name, line and column numbers, as well as the + error or warning message for each entry. For more information + about this and other exceptions that can be thrown during + parsing, refer to + <a href="http://www.codesynthesis.com/projects/xsd/documentation/cxx/tree/manual/#3.3">Section + 3.3, "Error Handling"</a> in the C++/Tree Mapping + User Manual.</p> + + <p>Note that if you are parsing <code>std::istream</code> on which + exceptions are not enabled, then you will need to check the + stream state after the call to the parsing function in order + to detect any possible stream failures, for example:</p> + + <pre class="c++"> +std::ifstream ifs ("people.xml"); + +if (ifs.fail ()) +{ + cerr << "people.xml: unable to open" << endl; + return 1; +} + +auto_ptr<people_t> p (people (ifs, "people.xml")); + +if (ifs.fail ()) +{ + cerr << "people.xml: read error" << endl; + return 1; +} + </pre> + + <p>The above example can be rewritten to use exceptions as + shown below:</p> + + <pre class="c++"> +try +{ + std::ifstream ifs; + ifs.exceptions (std::ifstream::badbit | std::ifstream::failbit); + ifs.open ("people.xml"); + + auto_ptr<people_t> p (people (ifs, "people.xml")); +} +catch (const std::ifstream::failure&) +{ + cerr << "people.xml: unable to open or read error" << endl; + return 1; +} + </pre> + + + <!-- Chapater 6 --> + + + <h1><a name="6">6 Serialization</a></h1> + + <p>We have already seen how to serialize an object model back to XML + in this guide before. In this chapter we will discuss the + serialization topic in more detail.</p> + + <p>By default, the C++/Tree mapping provides a total of 8 overloaded + serialization functions. They differ in the output methods used to write + XML as well as the error reporting mechanisms. It is also possible to + generate types for root elements instead of parsing and serialization + functions. This may be useful if your XML vocabulary has multiple + root elements. For more information on element types refer to + <a href="http://www.codesynthesis.com/projects/xsd/documentation/cxx/tree/manual/#2.9">Section + 2.9, "Mapping for Global Elements"</a> in the C++/Tree Mapping User + Manual.</p> + + + <p>In this section we will discuss the most commonly + used version of serialization functions. For a comprehensive description + of serialization refer to + <a href="http://www.codesynthesis.com/projects/xsd/documentation/cxx/tree/manual/#4">Chapter + 4, "Serialization"</a> in the C++/Tree Mapping User Manual. For the + <code>people</code> global element from our person record vocabulary, + we will concentrate on the following serialization function:</p> + + <pre class="c++"> +void +people (std::ostream& os, + const people_t& x, + const xml_schema::namespace_infomap& map = + xml_schema::namespace_infomap (), + const std::string& encoding = "UTF-8", + xml_schema::flags f = 0); + </pre> + + <p>This function serializes the object model passed as the second + argument to the standard output stream passed as the first + argument. The third argument is a namespace information map + which we will discuss in more detail in the next section. + The fourth argument is a character encoding that the resulting + XML document should be in. Possible valid values for this + argument are "US-ASCII", "ISO8859-1", "UTF-8", "UTF-16BE", + "UTF-16LE", "UCS-4BE", and "UCS-4LE". Finally, the flags + argument allows fine-tuning of the serialization process. + The following example shows how we can use the above serialization + function:</p> + + <pre class="c++"> +people_t& p = ... + +xml_schema::namespace_infomap map; +map[""].schema = "people.xsd"; + +// Serialize to stdout. +// +people (std::cout, p, map); + +// Serialize to a file. +// +std::ofstream ofs ("people.xml"); +people (ofs, p, map); + +// Serialize to a string. +// +std::ostringstream oss; +people (oss, p, map); +std::string xml (oss.str ()); + </pre> + + + <h2><a name="6.1">6.1 Namespace and Schema Information</a></h2> + + <p>While XML serialization can be done just from the object + model alone, it is often desirable to assign meaningful + prefixes to XML namespaces used in the vocabulary as + well as to provide the schema location information. + This is accomplished by passing the namespace information + map to the serialization function. The key in this map is + a namespace prefix that should be assigned to an XML namespace + specified in the <code>name</code> variable of the + map value. You can also assign an optional schema location for + this namespace in the <code>schema</code> variable. Based + on each key-value entry in this map, the serialization + function adds two attributes to the resulting XML document: + the namespace-prefix mapping attribute and schema location + attribute. The empty prefix indicates that the namespace + should be mapped without a prefix. For example, the following + map:</p> + + <pre class="c++"> +xml_schema::namespace_infomap map; + +map[""].name = "http://www.example.com/example"; +map[""].schema = "example.xsd"; + +map["x"].name = "http://www.w3.org/XML/1998/namespace"; +map["x"].schema = "xml.xsd"; + </pre> + + <p>Results in the following XML document:</p> + + <pre class="xml"> +<?xml version="1.0" ?> +<example + xmlns="http://www.example.com/example" + xmlns:x="http://www.w3.org/XML/1998/namespace" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://www.example.com/example example.xsd + http://www.w3.org/XML/1998/namespace xml.xsd"> + </pre> + + <p>The empty namespace indicates that the vocabulary has no target + namespace. For example, the following map results in only the + <code>noNamespaceSchemaLocation</code> attribute being added:</p> + + <pre class="c++"> +xml_schema::namespace_infomap map; + +map[""].name = ""; +map[""].schema = "example.xsd"; + </pre> + + <h2><a name="6.2">6.2 Error Handling</a></h2> + + <p>Similar to the parsing functions, the serialization functions offer a + number of ways to handle error conditions with the C++ exceptions being + the most commonly used mechanisms. As with parsing, the easiest way to + uniformly handle all possible serialization exceptions and print + detailed information about the error is to catch and print + <code>xml_schema::exception</code>:</p> + + <pre class="c++"> +try +{ + people_t& p = ... + + xml_schema::namespace_infomap map; + map[""].schema = "people.xsd"; + + people (std::cout, p, map)); +} +catch (const xml_schema::exception& e) +{ + cerr << e << endl; +} + </pre> + + <p>The most commonly encountered serialization exception is + <code>xml_schema::serialization</code>. It is thrown + when the XML serialization in the underlying XML writer + fails. It encapsulates various diagnostics information + such as the file name, line and column numbers, as well as the + error or warning message for each entry. For more information + about this and other exceptions that can be thrown during + serialization, refer to + <a href="http://www.codesynthesis.com/projects/xsd/documentation/cxx/tree/manual/#4.4">Section + 4.4, "Error Handling"</a> in the C++/Tree Mapping + User Manual.</p> + + <p>Note that if you are serializing to <code>std::ostream</code> on + which exceptions are not enabled, then you will need to check the + stream state after the call to the serialization function in order + to detect any possible stream failures, for example:</p> + + <pre class="c++"> +std::ofstream ofs ("people.xml"); + +if (ofs.fail ()) +{ + cerr << "people.xml: unable to open" << endl; + return 1; +} + +people (ofs, p, map)); + +if (ofs.fail ()) +{ + cerr << "people.xml: write error" << endl; + return 1; +} + </pre> + + <p>The above example can be rewritten to use exceptions as + shown below:</p> + + <pre class="c++"> +try +{ + std::ofstream ofs; + ofs.exceptions (std::ofstream::badbit | std::ofstream::failbit); + ofs.open ("people.xml"); + + people (ofs, p, map)); +} +catch (const std::ofstream::failure&) +{ + cerr << "people.xml: unable to open or write error" << endl; + return 1; +} + </pre> + + </div> +</div> + +</body> +</html> diff --git a/xsd/doc/cxx/tree/guide/makefile b/xsd/doc/cxx/tree/guide/makefile new file mode 100644 index 0000000..3e6fba2 --- /dev/null +++ b/xsd/doc/cxx/tree/guide/makefile @@ -0,0 +1,54 @@ +# file : doc/cxx/tree/guide/makefile +# copyright : Copyright (c) 2006-2014 Code Synthesis Tools CC +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +include $(dir $(lastword $(MAKEFILE_LIST)))../../../../build/bootstrap.make + +default := $(out_base)/ +install := $(out_base)/.install +dist := $(out_base)/.dist +dist-win := $(out_base)/.dist-win +clean := $(out_base)/.clean + +# Build. +# +$(default): $(out_base)/cxx-tree-guide.ps $(out_base)/cxx-tree-guide.pdf + + +$(out_base)/cxx-tree-guide.ps: $(src_base)/index.xhtml \ + $(src_base)/guide.html2ps \ + | $(out_base)/. + $(call message,html2ps $<,html2ps -f $(src_base)/guide.html2ps -o $@ $<) + +$(out_base)/cxx-tree-guide.pdf: $(out_base)/cxx-tree-guide.ps | $(out_base)/. + $(call message,ps2pdf $<,ps2pdf14 $< $@) + +# Install & Dist. +# +$(install): path := $(subst $(src_root)/doc/,,$(src_base)) +$(dist): path := $(subst $(src_root)/,,$(src_base)) + +$(install): $(out_base)/cxx-tree-guide.ps $(out_base)/cxx-tree-guide.pdf + $(call install-data,$(src_base)/index.xhtml,$(install_doc_dir)/xsd/$(path)/index.xhtml) + $(call install-data,$(out_base)/cxx-tree-guide.ps,$(install_doc_dir)/xsd/$(path)/cxx-tree-guide.ps) + $(call install-data,$(out_base)/cxx-tree-guide.pdf,$(install_doc_dir)/xsd/$(path)/cxx-tree-guide.pdf) + +$(dist): $(out_base)/cxx-tree-guide.ps $(out_base)/cxx-tree-guide.pdf + $(call install-data,$(src_base)/index.xhtml,$(dist_prefix)/$(path)/index.xhtml) + $(call install-data,$(out_base)/cxx-tree-guide.ps,$(dist_prefix)/$(path)/cxx-tree-guide.ps) + $(call install-data,$(out_base)/cxx-tree-guide.pdf,$(dist_prefix)/$(path)/cxx-tree-guide.pdf) + +$(dist-win): $(dist) + + +# Clean +# +$(clean): +ifneq ($(xsd_clean_gen),n) + $(call message,rm $$1,rm -f $$1,$(out_base)/cxx-tree-guide.ps) + $(call message,rm $$1,rm -f $$1,$(out_base)/cxx-tree-guide.pdf) +endif + +# How to. +# +$(call include,$(bld_root)/install.make) diff --git a/xsd/doc/cxx/tree/makefile b/xsd/doc/cxx/tree/makefile new file mode 100644 index 0000000..4163730 --- /dev/null +++ b/xsd/doc/cxx/tree/makefile @@ -0,0 +1,41 @@ +# file : doc/cxx/tree/makefile +# copyright : Copyright (c) 2006-2014 Code Synthesis Tools CC +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +include $(dir $(lastword $(MAKEFILE_LIST)))../../../build/bootstrap.make + +docs := guide manual + +default := $(out_base)/ +install := $(out_base)/.install +dist := $(out_base)/.dist +dist-win := $(out_base)/.dist-win +clean := $(out_base)/.clean + +# Build. +# +$(default): $(addprefix $(out_base)/,$(addsuffix /,$(docs))) + +# Install & Dist. +# +dist-common := $(out_base)/.dist-common + +$(install): path := $(subst $(src_root)/doc/,,$(src_base)) +$(dist-common): path := $(subst $(src_root)/,,$(src_base)) + +$(install): $(addprefix $(out_base)/,$(addsuffix /.install,$(docs))) + $(call install-dir,$(src_base)/reference,$(install_doc_dir)/xsd/$(path)/reference) + +$(dist-common): + $(call install-dir,$(src_base)/reference,$(dist_prefix)/$(path)/reference) + +$(dist): $(dist-common) $(addprefix $(out_base)/,$(addsuffix /.dist,$(docs))) +$(dist-win): $(dist-common) $(addprefix $(out_base)/,$(addsuffix /.dist-win,$(docs))) + +# Clean. +# +$(clean): $(addprefix $(out_base)/,$(addsuffix /.clean,$(docs))) + +$(call include,$(bld_root)/install.make) + +$(foreach m,$(docs),$(call import,$(src_base)/$m/makefile)) diff --git a/xsd/doc/cxx/tree/manual/cxx-tree-manual.pdf b/xsd/doc/cxx/tree/manual/cxx-tree-manual.pdf Binary files differnew file mode 100644 index 0000000..73131a3 --- /dev/null +++ b/xsd/doc/cxx/tree/manual/cxx-tree-manual.pdf diff --git a/xsd/doc/cxx/tree/manual/cxx-tree-manual.ps b/xsd/doc/cxx/tree/manual/cxx-tree-manual.ps new file mode 100644 index 0000000..38335e9 --- /dev/null +++ b/xsd/doc/cxx/tree/manual/cxx-tree-manual.ps @@ -0,0 +1,7382 @@ +%!PS +%%Title: C++/Tree Mapping User Manual +%%Creator: html2ps version 1.0 beta7 +%%EndComments +save +2000 dict begin +/d {bind def} bind def +/D {def} d +/t true D +/f false D +/FL [/Times-Roman +/Times-Italic +/Times-Bold +/Times-BoldItalic +/Courier +/Courier-Oblique +/Courier-Bold +/Courier-BoldOblique +/Helvetica +/Helvetica-Oblique +/Helvetica-Bold +/Helvetica-BoldOblique] D +/WF t D +/WI 0 D +/F 1 D +/IW 471 F div D +/IL 621 F div D +/PS 791 D +/EF [0 1 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 2 2] D +/EZ [12 10 19 17 15 13 12 11 12 12 12 12 12 12 12 12 12 12 12 12 12 12 8 8] D +/Ey [0 0 2 2 2 2 2 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0] D +/EG [-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1] D +/Tm [1 1 0.8 0.8 0.8 0.8 0.8 0.8 0 0 0 0 0 0 0.5 1 1 1 1 0 0 1.3 0 0] D +/Bm [1 1 0.5 0.5 0.5 0.5 0.5 0.5 0 0 0 0 0 0 0.5 1 1 1 1 0 0 1 0 0] D +/Lm [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 2 2 0 0 2 0 0 0] D +/Rm [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0] D +/EU [-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 0 0] D +/NO f D +/YY [[{()}{ h }][{ h }{()}][{()}{()}]] D +/ZZ [[{ (July 2014) }{ Pn }][{ Pn }{ (July 2014) }][{ Ti(, v)join ME 0 get join }{ Ti(, v)join ME 0 get join }]] D +/Ts EZ 0 get D +/TU f D +/Xp t D +/AU f D +/SN 0 D +/Cf t D +/Tp t D +/Fe f D +/TI 2 Ts mul D +/Fm 14 D +/xL 71 D +/xR 71 D +/yL 706 D +/yR 706 D +/Wl 471 F div D +/Wr 471 F div D +/hL 621 F div D +/hR 621 F div D +/FE {newpath Fm neg Fm M CP BB IW Fm add Fm L IW Fm add IL Fm add neg L CP BB + Fm neg IL Fm add neg L closepath} D +/LA {PM 0 eq{/IW Wl D /IL hL D}{/IW Wr D /IL hR D}ie /W IW D /LL W D /LS W D + TU PM 0 eq and{IW 56 F div add SA{Sf div}if 0 translate} + {PM 0 eq{xL yL}{xR yR}ie translate F SA{Sf mul}if dup scale + CS CF FS Cf{CA CL get VC}if /Bb f D}ie 0 0 M + TF not Tc or {Cf{gsave SA{1 Sf div dup scale}if Cb VC FE fill grestore}if}if}D +/Pi 0 Ts mul D +/SG [0.8 1 1] D +/Ab 15 D +/J 0 D +/Tc t D +/NH 6 D +/Nf f D +/Pa f D +/LH 1.2 D +/XR f D +/Xr {/pN E D ( [p ) WB pN WB (] )WB} D +/Db [16#FF 16#FF 16#FF] D +/Dt [16#00 16#00 16#00] D +/eA f D +/Fi f D +/bT f D +/Lc t D +/Dl [16#00 16#00 16#00] D +/LX f D +/Br 0.25 D +/IA ([IMAGE]) D +/DS {/PF f D()WB NL NP()pop RC ZF} D +/Gb f D +/Mb t D +/Hc [16#00 16#00 16#00] D +/Bl 3 D +/MI -15.6 D +/DX (DRAFT) D +/Di 0 D +/Tt 113.385826771654 D +/Th { ( +) 2 Al()BR ( + ) 0 1 -1 H()4 FZ (C++/Tree Mapping User Manual) ES()EH ( + ) 0 1 -1 H ( ) EH ( + ) 0 1 -1 H ( ) EH ( + ) 0 1 -1 H ( ) EH ( + ) 0 1 -1 H ( ) EH ( + ) 0 1 -1 H ( ) EH ( + ) 0 1 -1 H ( ) EH ( + ) 0 1 -1 H ( ) EH ( +) Ea()BR ( + ) 0 P (Revision ) ME 0 get join( July 2014)join EP ( + ) 0 P (Copyright © 2005-2014 CODE SYNTHESIS TOOLS CC) EP ( + + ) 0 P (Permission is granted to copy, distribute and/or modify this + document under the terms of the + ) R0 2 A (GNU Free + Documentation License, version 1.2) EA (; with no Invariant Sections, + no Front-Cover Texts and no Back-Cover Texts. + ) EP ( + + ) 0 P (This document is available in the following formats: + ) R1 2 A (XHTML) EA (, + ) R2 2 A (PDF) EA (, and + ) R3 2 A (PostScript) EA (.) EP()} D +/tH {()0 1 -1 H (Table of Contents) EH()} D +/FD 2 D +/Dy 2 D +/cD [16#F0 16#F0 16#F0] D +/FW 0.6 D +/FU [16#00 16#00 16#00] D +/ET {/RM f D /A0 3 D /PN SN D /OU t D /Ou t D /W IW D /LL W D D1 + Ms not TP and{Ip}if /TF f D} D + +%-- End of variable part -- +/MySymbol 10 dict dup begin + /FontType 3 D /FontMatrix [.001 0 0 .001 0 0 ] D /FontBBox [25 -10 600 600] D + /Encoding 256 array D 0 1 255{Encoding exch /.notdef put}for + Encoding (e) 0 get /euro put + /Metrics 2 dict D Metrics begin + /.notdef 0 D + /euro 651 D + end + /BBox 2 dict D BBox begin + /.notdef [0 0 0 0] D + /euro [25 -10 600 600] D + end + /CharacterDefs 2 dict D CharacterDefs begin + /.notdef {} D + /euro{newpath 114 600 moveto 631 600 lineto 464 200 lineto 573 200 lineto + 573 0 lineto -94 0 lineto 31 300 lineto -10 300 lineto closepath clip + 50 setlinewidth newpath 656 300 moveto 381 300 275 0 360 arc stroke + -19 350 moveto 600 0 rlineto -19 250 moveto 600 0 rlineto stroke}d + end + /BuildChar{0 begin + /char E D /fontdict E D /charname fontdict /Encoding get char get D + fontdict begin + Metrics charname get 0 BBox charname get aload pop setcachedevice + CharacterDefs charname get exec + end + end}D + /BuildChar load 0 3 dict put /UniqueID 1 D +end +definefont pop + +/Cd {aload length 2 idiv dup dict begin {D} repeat currentdict end} D +/EX {EC cvx exec} D +/DU {} d +/BB {pop pop}d +/ie {ifelse} d +/E {exch} d +/M {moveto} d +/R {rmoveto} d +/L {lineto} d +/RL {rlineto} d +/CP {currentpoint} d +/SW {stringwidth} d +/GI {getinterval} d +/PI {putinterval} d +/Sg {setgray} d +/LW {setlinewidth} d +/S {dup () ne OU and{0 Co R AT 3 eq LB and HF not and A1 0 ne A2 0 ne or and + {A2 0 32 A1 0 6 -1 roll awidthshow}{show}ie 0 Co neg R}{pop}ie + OU PH 3 eq or{/Ms t D}if} D +/U {OU{gsave CP currentfont /FontInfo get /UnderlinePosition get + 0 E currentfont /FontMatrix get dtransform E pop add newpath M dup SW pop + CJ 0 RL stroke grestore}if} D +/B {OU Br 0 gt and{CP Ts neg Ts .33 mul R gsave 0 Sg + CP newpath Ts Br mul 0 360 arc closepath UI 2 mod 0 eq{stroke}{fill}ie + grestore M CP E Ts Br 1 add mul sub E BB /Ms t D}if}D +/NP {Ms TP not or PA and OU and{TP{OR}if f1{mF k2 /mF E D /YC 0 D}if + TP TU not PM 0 eq or and{showpage}if DU Ip TE not{LA}if 0.6 LW + /CI 0 D /TP t D /Hs f D /hl 6 D /Hv 6 D /HI hi D /Ms f D}if Bs XO BO M} D +/Np {LE sub CP E pop gt PL 0 eq and{NP}if}D +/Ip {/PN PN 1 add D /Pn RM{1}{4}ie PN Ns D /PM PN SN sub 2 mod D} D +/GP {E dup 3 -1 roll get PN 1 add 2 mod get dup type /integertype eq + {get 0 get}{E pop}ie}d +/Fc {dup 2 GP exec SW pop /S1 E D dup 1 GP exec SW pop /S2 E D 0 GP exec SW + pop /S3 E D S1 0 gt{S2 2 mul S1 add S3 2 mul S1 add 2 copy lt{E}if pop}{0}ie + S2 S3 add 2 copy lt{E}if pop IW .9 mul div dup 1 gt{1 E div}{pop 1}ie}D +/OR {Df{Sd}if tp not{gsave SA{1 Sf div dup scale}if Fe{Cf{FU VC}if FW LW + 1 setlinejoin FE stroke}if /YO {60 F div dup 40 gt{pop 40}if}D /cs CS D + /cf CF D /CF 0 D /pf PF D /PF f D /Fn FN D /At AT D /AT 0 D /FN EF Hf 1 add + get D Fz Fs FS ZZ Fc Fz mul Fs FS EU Hf 1 add get dup type /arraytype eq + Cf and{VC}{pop 0 Sg}ie IW IL neg YO sub M ZZ 1 GP exec dup SW pop neg 0 R Sh + 0 IL neg YO sub M ZZ 0 GP exec Sh ZZ 2 GP exec dup SW pop IW E sub 2 div + IL neg YO sub M Sh Fz Fs FS NO{/AW IW Pn SW pop sub D AW 2 div IL neg YO sub + S1 0 gt S2 AW .45 mul gt or S3 AW .45 mul gt or{Fz 2 mul sub}if M Pn Sh}if + EU Hf get dup type /arraytype eq Cf and{VC}{pop 0 Sg}ie YY Fc /FN EF Hf get D + Hz mul HS FS IW YO M YY 1 GP exec dup SW pop neg 0 R Sh 0 YO M YY 0 GP exec Sh + YY 2 GP exec dup SW pop IW E sub 2 div YO M Sh /FN Fn D /AT At D t Pb XO SZ + SL get neg R /PF pf D grestore /CF 0 D cs cf FS}if}D +/Sh {dup () ne{CP Hz 4 div sub BB show CP CS add BB}{pop}ie}D +/Pb {/OU E D /Ou OU D /PB t D 0 0 M Ba{/Sa save D /BP t D /Fl t D RC /PL 0 D + /PH 0 D /W IW D /LE IL .7 mul D /EO 0 D SI ZF /YA 0 D /BO 0 D /C1 () D + BA 0 Ts neg R Bb{Xl Yl Xh Yh}if Bb CP Sa restore M + {/Yh E D /Xh E D /Yl E D /Xl E D}if /Fl t D}if + BL /OU t D /HM f D /Ou t D /PB f D} D +/Bs {/BP Ba not D}D +/reencodeISO { + dup dup findfont dup length dict begin{1 index /FID ne{D}{pop pop}ie}forall + /Encoding ISOLatin1Encoding D currentdict end definefont} D +/ISOLatin1Encoding [ +/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef +/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef +/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef +/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef +/space/exclam/quotedbl/numbersign/dollar/percent/ampersand/quoteright +/parenleft/parenright/asterisk/plus/comma/hyphen/period/slash +/zero/one/two/three/four/five/six/seven/eight/nine/colon/semicolon +/less/equal/greater/question/at/A/B/C/D/E/F/G/H/I/J/K/L/M/N +/O/P/Q/R/S/T/U/V/W/X/Y/Z/bracketleft/backslash/bracketright +/asciicircum/underscore/quoteleft/a/b/c/d/e/f/g/h/i/j/k/l/m +/n/o/p/q/r/s/t/u/v/w/x/y/z/braceleft/bar/braceright/asciitilde +/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef +/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef +/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef +/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef +/.notdef/space/exclamdown/cent/sterling/currency/yen/brokenbar +/section/dieresis/copyright/ordfeminine/guillemotleft/logicalnot +/hyphen/registered/macron/degree/plusminus/twosuperior/threesuperior +/acute/mu/paragraph/periodcentered/cedilla/onesuperior/ordmasculine +/guillemotright/onequarter/onehalf/threequarters/questiondown +/Agrave/Aacute/Acircumflex/Atilde/Adieresis/Aring/AE/Ccedilla +/Egrave/Eacute/Ecircumflex/Edieresis/Igrave/Iacute/Icircumflex +/Idieresis/Eth/Ntilde/Ograve/Oacute/Ocircumflex/Otilde/Odieresis +/multiply/Oslash/Ugrave/Uacute/Ucircumflex/Udieresis/Yacute +/Thorn/germandbls/agrave/aacute/acircumflex/atilde/adieresis +/aring/ae/ccedilla/egrave/eacute/ecircumflex/edieresis/igrave +/iacute/icircumflex/idieresis/eth/ntilde/ograve/oacute/ocircumflex +/otilde/odieresis/divide/oslash/ugrave/uacute/ucircumflex/udieresis +/yacute/thorn/ydieresis +] D +[128/backslash 129/parenleft 130/parenright 141/circumflex 142/tilde +143/perthousand 144/dagger 145/daggerdbl 146/Ydieresis 147/scaron 148/Scaron +149/oe 150/OE 151/guilsinglleft 152/guilsinglright 153/quotesinglbase +154/quotedblbase 155/quotedblleft 156/quotedblright 157/endash 158/emdash +159/trademark] +aload length 2 idiv 1 1 3 -1 roll{pop ISOLatin1Encoding 3 1 roll put}for +/colorimage where{pop}{ + /colorimage { + pop pop /Pr E D {/Cv Pr D /Gr Cv length 3 idiv string D 0 1 Gr length 1 sub + {Gr E dup /i E 3 mul D Cv i get 0.299 mul Cv i 1 add get 0.587 mul add + Cv i 2 add get 0.114 mul add cvi put}for Gr} image} D +}ie +/pdfmark where{pop}{userdict /pdfmark /cleartomark load put}ie +WF{FL{reencodeISO D}forall}{4 1 FL length 1 sub{FL E get reencodeISO D}for}ie +/Symbol dup dup findfont dup length dict begin + {1 index /FID ne{D}{pop pop}ie}forall /Encoding [Encoding aload pop] + dup 128 /therefore put D currentdict end definefont D + +/SF {/CS E D SZ SL CS put FO SL FN put /YI CS LH neg mul D dup ST cvs ( ) join + CS ST cvs join C1 E join ( NF ) join /C1 E D CS NF /Wf WF FN 0 gt or D + /BW Wf{( ) SW pop}{0}ie D}D +/NF {/cS E D /cF E D cF 0 ge{FL cF get}{cF -1 eq{/Symbol}{/MySymbol}ie}ie + findfont cS scalefont setfont} D +/FS {CF or /CF E D FR SL CF put CF CF 0 ge{FN 4 mul add}if E SF} D +/PC {SH /BP f D fin not GL not and{NL}if /HM t D /LL LS D} D +/BS {/TX E D Wf{/fin f D /CW 0 D /LK 0 D /SC 0 D + /RT TX D {RT ( ) search{/NW E D pop /RT E D /WH NW SW pop D CW WH add LL gt + {TX SC LK SC sub 1 sub NN GI GL{SH cF cS OC + 2 copy cS ne E cF ne or{NF}{pop pop}ie}{PC /CW WH BW add D}ie + /SC LK D} + {GL{JC}if + /CW CW WH add BW add D /HM t D}ie /GL f D /Ph f D + /LK LK NW length 1 add add D}{pop exit}ie}loop + /fin t D TX SC LK SC sub GI SH RT () ne{GL not{CC}if}if + /LC TX length D /WH RT SW pop D CW WH add Hy{HC SW pop add}if LL gt + {RT GL{SH cF cS OC 2 copy cS ne E cF ne or{NF}{pop pop}ie + Hy{/Ph t D}if /LL LS D}{NL /LL LS D SH}ie} + {RT PC Hy{CC}if /Ph Ph Hy or D}ie RT () ne{/GL t D /HM t D}if} + {TX SW pop LL le{TX SH}{/NW () D 0 2 TX length 1 sub + {/CW E D TX 0 CW GI dup SW pop LL gt{pop NW SH /HM t D NL/LL W XO sub MR sub D + /CW CW 2 sub NN D /TX TX CW TX length CW sub GI D TX BS exit} + {/NW E D}ie}for}ie}ie /HM t D}D +/CC {C0 length 0 gt{JC}if /C0 [C1 L1 YA YB Mf NS NB TB AF Bw] D + /C1 () D /L0 L1 D /YA 0 D /YB 0 D /Mf 0 D /NS 0 D /NB 0 D}D +/JC {C0 aload length 0 gt{pop pop pop NB add /NB E D NS add /NS E D + dup Mf gt{/Mf E D}{pop}ie dup YB gt{/YB E D}{pop}ie + dup YA gt{/YA E D}{pop}ie pop C1 join /C1 E D /C0 [] D}if}D +/OC {C0 length 0 gt{C1 L1 L0 sub YA YB Mf NS NB TB AF Bw GL C0 aload pop + /Bw E D /AF E D /TB E D /NB E D /NS E D /Mf E D /YB E D /YA E D /C0 [] D + /L1 E D /C1 E D Ph{HC SH}if NL /GL E D /Bw E D /AF E D /TB E D /NB E D /NS E D + /Mf E D /YB E D /YA E D /L1 E D /LL W L1 sub XO sub MR sub WH sub D /CW 0 D + C1 E join /C1 E D}if}D +/BT {/LB t D dup length string copy RS dup dup () ne E ( ) ne and + {/CI 0 D /LS LL D /LL W L1 sub XO sub MR sub D BS} + {dup ( ) eq{/GL f D}if dup () eq L1 0 eq or{pop}{SH /BP f D /Ph f D}ie}ie + /LB f D} D +/BL {CP E pop XO E M} D +/NL {JC /GL f D /SK W XO sub MR sub L1 sub TB{Bw add}if D + /YA LF{Mf HM Fl not and PF or{LH mul}if}{0 /LF t D}ie YA 2 copy lt{E}if pop D + C1 () ne{/FB YB Mf SA{Sf mul}if 4 div 2 copy lt{E}if pop D}if Fl{/Ya YA D}if + CP E pop YA sub YB sub LE neg lt Fl not and PB not and{NP}if NT TL BL + OU PF not and PB or{/RE L1 TB{Bw sub}if + W XO sub MR sub div YA YB add LE BO add div 2 copy lt{E}if pop D + RE 1 gt{BL 1 RE div dup scale}if}if + AT 2 le{SK AT mul 2 div YA neg R}if + AT 3 eq{0 YA neg R TB{/NB NB 1 sub D /NS NS 1 sub D}if /NB NB 1 sub NN D + /A3 NS 6 mul NB add D NS NB add 0 eq + {/A1 0 D /A2 0 D} + {NS 0 eq{/A1 SK NB div dup J gt{pop 0}if D /A2 0 D}{J A3 mul SK lt + {/A1 J D /A2 SK J NB mul sub NS div dup Ab gt{/A1 0 D pop 0}if D} + {/A1 SK A3 div D /A2 A1 6 mul D}ie}ie}ie /A1 A1 NN D /A2 A2 NN D}if + AT 4 eq{0 YA neg R PH 2 le{PD 0 lt{/PD L1 D}if PD M1 gt{/M1 PD D}if + L1 PD sub M2 gt{/M2 L1 PD sub D}if}{DV ID 1 sub get 0 ge{Lo 0 R}if}ie}if + F0 cF ne Cs cS ne or{F0 Cs NF}if + /ms Ms D /Ms f D CP FB sub + C1 cvx exec XO EO sub L1 add TB{BW sub}if dup LM gt{/LM E D}{pop}ie + PH 0 eq PH 4 eq or Ms and{HF not{/PO t D /AH t D}if + BB CP YA add E AT 3 eq LB and{A1 sub}if TB{BW sub}if E BB} + {pop pop}ie Ms HM PH 3 eq and or{/BP f D /Fl f D}if + /Lo 0 D /L1 0 D /F0 cF D /Cs cS D BP not{0 YB NN neg R}if + OU f1 and mF not and{k2 /f1 f D}if + OU PF not and PB or{RE 1 gt{RE dup scale}if}if /Ms ms Ms or D + /C1 AF{(Cp )}{()}ie D /YA 0 D /YB 0 D BL + AT 4 eq LB not and PH 3 ge and + {ID DV length lt{DV ID get dup 0 ge{DO E sub /Lo E D /L1 Lo D}{pop}ie + /ID ID 1 add D}if}if /T t D CD{/LN LN 1 add D PD}if + /PD -1 D /NS 0 D /NB 0 D /TB f D /Ph f D /Mf 0 D /HM f D} D +/RS {/TM E D /CN 0 D TM{10 eq{TM CN ( ) PI}if /CN CN 1 add D}forall + /CN 0 D /BK HM EN and{0}{1}ie D TM + {dup 32 ne{TM CN 3 2 roll put /CN CN 1 add D /BK 0 D} + {pop BK 0 eq{TM CN 32 put /CN CN 1 add D}if /BK 1 D}ie}forall + TM 0 CN GI dup dup () ne E ( ) ne and + {dup CN 1 sub get 32 eq{/EN f D}{/EN t D}ie}if} D +/join {2 copy length E length add string dup 4 2 roll 2 index 0 3 index + PI E length E PI}d +/WR {(\n) search{dup () ne BP not or + {Li 4 le CP E pop YI Li mul add LE add 0 lt and PL 0 eq and{NP}if + SH NL pop /Li Li 1 sub D WR}{pop pop WR}ie}{SH}ie /CI 0 D /BP f D} D +/SH {dup dup () ne E ( ) ne and PF or CS Mf gt and{/Mf CS D}if + T not Wf and{( ) E join /T t D}if dup BP{/MF CS D}if + AT 3 eq{2 copy length dup 0 gt{/NB E NB add D + {( ) search{/NS NS 1 add D pop pop}{pop exit}ie}loop}{pop pop}ie}if + CD PD 0 lt and{dup DC search{SW pop /PD E L1 add D pop pop}{pop}ie}if + 0 Np dup SW pop L1 add /L1 E D dup () ne + {C1 (\() join E join (\)) join AU AF and UF or Wf and{( U ) join}if + sF{( s ) join}if ( S ) join + /C1 E D dup length 1 sub get 32 eq /TB E D /Bw BW D}{pop pop}ie} D +/BG {AI LG BC add add 0 eq} D +/ON {OU{Ty AR AI NN get dup 1 add Ln Ns Ty 2 mod 0 eq{(. )}{(\) )}ie join + dup SW pop neg 0 R CP E 0 lt{0 E M}{pop}ie CP BB show /Ms t D}if} D +/Ln {AR AI 3 -1 roll put}D +/SP {dup CI lt BP not and{dup CI sub 0 E R /CI E D}{pop}ie} D +/BN {PF{WR /HM f D}{BT NL}ie} D +/NN {dup 0 lt{pop 0}if} D +/h {(h) HI ST cvs join cvx exec dup 1 get E Nf{0 get E join}{pop}ie} D +/H {/fn FN D /Hi E 1 add D 1 sub /HL E D /H2 HL 2 add D /GS EZ H2 get D + E Tm H2 get GS mul BE dup 0 gt{1 sub}{pop EG H2 get dup 0 lt{pop AT}if}ie NA + WW Np /SL SL 1 add D /FN EF H2 get D GS Ey H2 get FS + EU H2 get Sc Hs not HL Hl lt and Hs HL hl lt and or Hi 0 eq or + {/HI Hi D /Hs t D /hl HL D /Hv HL D}if HL Hl lt{/hi Hi D}if + Nf HI 0 gt and{(h) Hi ST cvs join cvx exec 0 get WB}if + /HF t D /AH f D /PO f D} D +/EH {Bm H2 get GS mul BE OA /SL SL 1 sub NN D /CF 0 D /FN fn D + SZ SL get FR SL get FS /HF f D /GS Ts D ()Ec} D +/P {E PF{WR}{PO{EP}{BN}ie Ts 4 mul Np AE not{Tm 0 get Ts mul neg SP}if + dup 0 ge AH and{Pi Pd}if}ie 1 sub dup 0 lt{pop AV AL get}if /AT E D /PO t D} D +/EP {PF{WR}{BN Ts 4 mul Np}ie AE not{Bm 0 get Ts mul neg SP}if + /AT AV AL get D /PO f D} D +/BE {E PO{EP}{BN}ie Ts 4 mul Np neg SP} D +/HR {/Aw W EO sub D /RW E dup 0 gt{Aw mul}{neg}ie dup Aw gt{pop Aw}if D /RZ E D + E BN Ts neg SP 1 sub 2 div Aw RW sub mul EO add CP E pop M PF{0 Ps neg R}if + 0 Np OU{gsave RZ LW Cf{Hc VC}{0 Sg}ie CP BB RW 0 RL CP BB stroke grestore}if + /CI 0 D /BP f D PF not{Ts neg SP}if /Ms t D} D +/AD {I NL EG 14 get dup 0 lt{pop AT}if NA /AE t D Tm 14 get Ts mul neg SP + Cf{EU 14 get dup -1 eq{pop CA CL get}if Sc}if} D +/DA {BN ()ES OA /AE f D ()Ec Bm 14 get Ts mul neg SP} D +/PR {/MW E D /Li E D Tm 1 get Ps mul BE 0 NA /FN Fp D /PF t D SI /SL SL 1 add D + /CF 0 D Ps CS mul Ts div MW WC mul CS mul Ts div dup LL gt PL 0 eq and + {LL div div}{pop}ie Ey 1 get FS CP E pop LE add YI neg div cvi dup Li lt + AH and{4 lt YI Li mul 5 mul LE add 0 gt or PL 0 eq and{NP}if}{pop}ie + EU 1 get Sc /GS Ps D}D +/RP {WR NL () /PF f D SI /FN 0 D ES Bm 1 get Ps mul neg SP OA /GS Ts D} D +/SI {/XO Lm 15 get BC NN mul Lm 16 get AI UI sub NN mul add + Lm 17 get UI NN mul add Lm 20 get LG NN mul add Ts mul + PF{Lm 1 get Ps mul add}if EO add D + /MR Rm 15 get BC NN mul Rm 16 get AI UI sub NN mul add + Rm 17 get UI NN mul add Rm 20 get LG NN mul add Ts mul + PF{Rm 1 get Ps mul add}if D /LL W XO sub MR sub D} D +/DT {/cC E D BN /LG LG 1 sub D SI /LG LG 1 add D WW 2 div Np BL} D +/DD {WB Cc 0 eq cC 0 eq and L1 0 eq or Lm 20 get Ts mul L1 sub TB{BW add}if + Ts 2 div lt or NL /LF E D SI BL /cC 0 D} D +/DL {Dc LG Cc put /Cc E D BG{Tm 18 get Ts mul BE}{BN}ie /LG LG 1 add D BL} D +/LD {BN LG 0 gt{/LG LG 1 sub D}if /Cc Dc LG get D SI + BG{()Bm 18 get Ts mul BE}if BL} D +/UL {BG{Tm 17 get Ts mul BE}{BN}ie NR AI NN 0 put /UI UI 1 add D + /AI AI 1 add D SI BL} D +/LU {BN /UI UI 1 sub D /AI AI 1 sub D SI BG{()Bm 17 get Ts mul BE}if BL} D +/OL {E BG{Tm 16 get Ts mul BE}{BN}ie TR AI NN Ty put /Ty E D NR AI NN 1 put + /AI AI 1 add D SI BL 1 Ln} D +/LO {BN /AI AI 1 sub D /Ty TR AI get D SI BG{()Bm 16 get Ts mul BE}if BL} D +/LI {E BN -1 SP /BP f D /CI 0 D 0 Np NR AI 1 sub NN get 1 eq + {dup dup 0 gt E 4 le and{/Ty E D}{pop}ie + /L1 L1 Ty AR AI NN get Ns SW pop XO sub dup 0 lt{pop 0}if add D ( ON )} + {pop ( B )}ie C1 E join /C1 E D CS Mf gt{/Mf CS D}if BL} D +/BQ {Tm 15 get Ts mul BE /BC BC 1 add D SI BL} D +/QB {Bm 15 get Ts mul BE /BC BC 1 sub D SI BL} D +/Al {E EP 1 sub dup 0 lt{pop AV AL get}if NA} D +/Ea {EP OA} D +/WB {PF{WR}{BT}ie} D +/F1 {WB /FN 0 D CS 0 FS} D +/F2 {WB /FN WI D CS 0 FS} D +/HY {/Hy t D WB /Hy f D} D +/YH {WB} D +/A {/LT E D LT 1 eq{/RN E D}if /Lh E D WB /C1 C1 ( Cp ) join D + Lc AF not and{Cl Sc}if /AF t D} D +/EA {Lc AF and{Ec}{WB}ie TL Pa AF and Lh 0 ne and + {( \() Lh join (\)) join /AF f D WB}if /AF f D} D +/TL {C1 ( Tl ) apa /C1 E D} d +/apa {AF OU and Lh 0 ne LT 1 eq or and{LT 1 eq{RN ( /) E ST cvs join} + {(\() Lh join (\)) join}ie E join join}{pop}ie} d +/Cp {/Xc CP /Yc E D D} D +/SS {Cf{dup 0 ge{EU E get dup -1 eq{pop CA CL get}if}{pop CA CL get}ie Sc} + {pop}ie SZ SL get /SL SL 1 add D} D +/I {WB 8 SS 1 FS} D +/EM {WB 8 SS /CF CF 1 xor D 0 FS} D +/BD {WB 9 SS 2 FS} D +/TT {WB 10 SS /FN Fp D 0 FS} D +/KB {WB 11 SS /FN Fp D 2 FS} D +/CT {WB 12 SS 1 FS} D +/SM {WB 13 SS /FN Fp D 0 FS} D +/Q {/QL QL 1 add D QO QL 2 mod get La get join WB} D +/EQ {QC QL 2 mod get La get join WB /QL QL 1 sub D} D +/RO {WB -1 SS /CF 0 D 0 FS} D +/SY {WB -1 SS -1 FS} D +/MY {WB -1 SS -2 FS} D +/ES {WB /SL SL 1 sub NN D /CF 0 D /FN FO SL get D SZ SL get FR SL get FS ()Ec}D +/FZ {3 sub 1.2 E exp GS mul E WB TL /C1 C1 ( Cp ) join D /SL SL 1 add D 0 FS} D +/Ef {WB TL ()ES /C1 C1 ( Cp ) join D} D +/BZ {dup /Bf E D FZ}D +/Sc {dup -1 ne Cf and{/CL CL 1 add D dup 0 eq{pop [0 0 0]}if + dup CA E CL E put VS ( VC ) join C1 E join /C1 E D}{pop}ie} D +/Ec {WB Cf{/CL CL 1 sub NN D CA CL get VS ( VC ) join C1 E join /C1 E D}if} D +/VS {dup type /arraytype eq{([) E {ST cvs join ( ) join}forall (]) join}if} D +/VC {{255 div}forall setrgbcolor} D +/Sl {dup type /integertype ne{Ds}if /La E D WB}d +/UN {WB /UF t D} D +/NU {WB /UF f D} D +/SE {WB /sF t D} D +/XE {WB /sF f D} D +/sM {/C1 C1 ( k1 ) join D}d +/eM {/C1 C1 ( k2 ) join D}d +/k1 {/YC CP E pop Ts add D /mF t D /f1 t D}d +/k2 {gsave 3 LW -9 CP E pop Ts 0.2 mul sub M -9 YC L stroke grestore /mF f D}d +/Ac {/AC E D WB}d +/Ca {eA{( \()join AC join(\) )join}if WB}d +/s {OU{gsave 0 CS .25 mul R dup SW pop CJ 0 RL stroke grestore}if}D +/CJ {AT 3 eq LB and{E dup dup length 1 sub A1 mul E + {( ) search{pop pop E A2 add E}{pop exit}ie}loop 3 -1 roll add + W CP pop sub 2 copy gt{E}if pop}if}D +/So {/Co E D} D +/SO {C1 Yo ST cvs join ( So ) join /C1 E D (j) SW pop 2 div Pd} D +/Se {E WB CS E div Pd}D +/Pd {dup type /stringtype eq{SW pop}if dup /L1 E L1 add D + ST cvs ( 0 R ) join C1 E join /C1 E D} D +/Sp {0.35 CO} D +/Sb {-0.2 CO} D +/CO {OV Io Yo put /Yo E CS mul Yo add D /Io Io 1 add D -1.5 Io mul 3 add FZ SO + CS Yo add dup YA gt{/YA E D}{pop}ie + Yo neg dup YB gt{/YB E D}{pop}ie} D +/Es {ES /Io Io 1 sub NN D /Yo OV Io get D SO} D +/SB {/N2 0 D 0 1 NI{/N E D{IX N2 get 0 lt{/N2 N2 1 add D}{exit}ie}loop + /K WS N get FC N get mul D /NY AY N2 get D /BV NY array D + 0 1 NY 1 sub{/TM K string D currentfile TM readhexstring pop pop BV E TM put} + for BM N BV put /N2 N2 1 add D}for} D +/IC [{/MA E D /MB 0 D}{2 div /MA E D /MB MA D}{/MB E CS sub D /MA CS D} + {pop /MA YS AB mul D /MB 1 AB sub YS mul D}{pop /MA 0 D /MB 0 D}] D +/IP {BV N get /N N 1 add D} D +/II {/K E D IX K get 0 lt{/EC E D}if /TY E D + TY 4 eq{/Y E D /X E D}if TY 3 eq{/AB E D}if + /XW AX K get D /YW AY K get D /IS SG IT K get get D /XS XW IS mul D + /YS YW IS mul D YS IC TY get exec /MA MA Fl not{3 add}if D} D +/IM {II /ty TY D /xs XS D /ys YS D /ya YA D /yb YB D /ma MA D /mb MB D /k K D + /ec EC D /BP f D /CI 0 D WB TL L1 xs add dup XO add MR add W gt + {pop /ma ma Fl{3 add}if D NL /YA ma D /YB mb D /YS ys D /L1 xs D} + {/L1 E D ma YA gt{/YA ma D}if mb YB gt{/YB mb D}if}ie /TB f D + OU{CP E pop YS sub LE neg lt Fl not and PB not and{NP /YA ma D /YB mb D}if + /BP f D ty ST cvs ( ) join IX k get 0 lt{(\() join ec join (\) ) join}if + k ST cvs join ty 3 eq{AB ST cvs ( ) join E join}if + ty 4 eq{X ST cvs ( ) join Y ST cvs join ( ) join E join}if C1 E join + ( DI ) join FP 2 eq FP 1 eq AF and or{( FM ) join}if + ( Il Cp ) apa /C1 E D /EN f D}if /HM t D /T f D} D +/DI {II /Xc CP /Yc E D D /YN YW neg D /HM t D /CI 0 D /K2 IX K get D gsave + TY 4 eq{OX X IS mul add OY FY add YS sub Y IS mul sub} + {/FY YS D CP MB sub 2 copy /OY E D /OX E D}ie + translate K2 0 ge{/DP AZ K2 get D /BV BM K2 get D XS YS scale /N 0 D XW YW DP + [XW 0 0 YN 0 YW] {IP} FC K2 get 1 eq{image}{f 3 colorimage}ie} + {EX}ie grestore XS 0 R /Ms t D} D +/FM {gsave 0 Sg CP MB sub translate XS neg 0 M 0 YS RL XS 0 RL 0 YS neg RL + XS neg 0 RL stroke grestore} D +/NA {/AT E D /AL AL 1 add D AV AL AT put} D +/OA {AL 0 gt{/AL AL 1 sub D /AT AV AL get D}if} D +/D1 {/BR {CP E pop E BN Mb{CP E pop eq{0 YI R}if}{pop}ie} D + /Sn {OU{C1 E ST cvs join ( Ld ) join /C1 E D}{pop}ie} D} D +/D1 {/BR {BN} D /Sn {OU {C1 E ST cvs join ( Ld ) join /C1 E D} {pop} ie} D} D +/TC {/TF t D /ML 0 D HN{SW pop dup ML gt{/ML E D}{pop}ie}forall NP /RM RM not D + RC /OU Tc D Ep /PN 0 D Ms not TP and{Ip}if /W IW ML sub Ts sub D + /A0 0 D TH{/BR {( ) join BT} D /Sn {pop} D /Au () D}if} D +/TN {0 eq{E EA PF HF or not XR and{HN E get Xr}{pop}ie} + {OU{Tn 0 ge{() BN}if /Tn E D}{pop}ie WB}ie} D +/NT {OU LB not and Tn 0 ge and{PL 0 eq{Ms not{CS CF FS}if CP dup + /y E YA sub D W 9 sub CS -1.8 mul XO L1 add 2 add{y M (.) show}for + HN Tn get dup SW pop IW E sub y M show CP BB M}if /Tn -1 D}if} D +/Ld {/DN E D HN DN Pn put [/View [/XYZ -4 Fl{PS}{CP YA add US E pop}ie null] + /Dest DN ST cvs cvn /DEST pdfmark} D +/C {ND 1 eq{1 sub}if TI mul /XO E D NL Nf not{pop()}if 0 3 -1 roll 1 A} D +/OP {BP not{NP}if PN 2 mod 0 eq{/Ms t D NP}if}D +/Ep {Xp PN 2 mod 0 eq and OU and{/Pn (-) D showpage /PM 1 D LA}if}D +/Dg [73 86 88 76 67 68 77] D +/Rd [0 [1 1 0][2 1 0][3 1 0][2 1 1][1 1 1][2 2 1][3 3 1][4 4 1][2 1 2]] D +/Ns {/m E D /c E 32 mul D /j m 1000 idiv D /p j 12 add string D + c 96 le m 0 gt and{c 32 le {/i 0 D /d 77 D /l 100 D /m m j 1000 mul sub D + j -1 1 {pop p i d c add put /i i 1 add D}for + 4 -2 0 {/j E D /n m l idiv D /m m n l mul sub D /d Dg j get D + n 0 gt {/x Rd n get D x 0 get -1 1 {pop p i d c add put /i i 1 add D}for + p i x 1 get sub Dg x 2 get j add get c add put}if /l l 10 idiv D + }for p 0 i GI} + {/i ST length 1 sub D m {1 sub dup 0 ge{dup 26 mod c add 1 add + ST i 3 -1 roll put 26 idiv dup 0 eq{pop exit}if}if /i i 1 sub D}loop + ST i ST length i sub GI}ie} + {m p cvs}ie} D +/US {matrix currentmatrix matrix defaultmatrix matrix invertmatrix + matrix concatmatrix transform} D +/GB {Gb{US}if}D +/Tl {/Rn E D Xc CP pop ne{ + [/Rect [Xc 1 sub Yc cS 0.25 mul sub GB CP E 1 add E cS 0.85 mul add GB] + /Subtype /Link /Border [0 0 Cf Lc and LX and AU or{0}{1}ie] Rn type + /nametype eq {/Dest Rn}{/Action [/Subtype /URI /URI Rn] Cd}ie + /ANN pdfmark}if} D +/Il {/Rn E D [/Rect [Xc Yc GB Xc XS add Yc YS add GB] /Subtype /Link + /Border [0 0 0] Rn type /nametype eq{/Dest Rn} + {/Action [/Subtype /URI /URI Rn] Cd}ie /ANN pdfmark} D +/XP {[{/Z Bz 2 div D Z 0 R Z Z RL Z neg Z RL Z neg Z neg RL Z Z neg RL + Fi cH 1 eq and{fill}if} {Bz 0 RL 0 Bz RL Bz neg 0 RL 0 Bz neg RL + Fi cH 1 eq and{fill}if} {0 -5 R Bz 0 RL 0 21 RL Bz neg 0 RL 0 -21 RL}]} D +/MS {/Sm E D WB}D +/O {BN()0 Sm BX} D +/BX {/Bt E D Bt 2 lt{/Ch E D CS 0.8 mul}{11 mul}ie W XO sub MR sub + 2 copy gt{E}if pop /HZ E D Bt 2 eq{Fi not{pop()}if ( )E join /Ft E D TT + /PF t D /MW 1 D /Li 1 D /Fw Ft SW pop D Fw HZ gt{/HZ Fw 8 add D}if + HZ ST cvs( )join}{WB Ch ST cvs( )join}ie L1 HZ add XO add MR add W gt{NL}if + Bt 2 eq{Ft ES Fw neg HM{CS sub}if Pd}if Bt ST cvs join( Bx )join + Bt 2 eq HM and{CS Pd}if C1 E join /C1 E D /L1 L1 HZ add D /T f D + ( ) Pd /PF f D Bt 2 lt{YA CS .8 mul lt{/YA CS .8 mul D}if} + {YB 5 lt{/YB 5 D}if YA 21 lt{/YA 21 D}if}ie /CI 0 D} D +/Bx {dup 2 eq{E /Bz E D}{E /cH E D /Bz CS .8 mul D}ie + OU {gsave 0 Sg XP E get exec stroke grestore}{pop}ie Bz 0 R /Ms t D}D +/SD {FD 4 mul Dy add DZ NF newpath 0 0 M DX t charpath pathbbox + 3 -1 roll sub /DY E D E dup /X1 E D sub WM mul WX DY mul add WM DG mul E div + /DF E D /DR WX DF mul DY mul WM div 2 div D} d +/Sd {gsave 0 IL Di mul neg translate IL IW atan Di 0 eq{neg}if rotate + FD 4 mul Dy add DZ NF DR X1 sub DY 2 div neg M cD VC DX show grestore} d +/Pt {/tp t D Tp{NP /Pn (TP) D 0 Tt neg R Th BN NP Ep ET RC ZF}if /tp f D} D +/RC {/AI 0 D /LG 0 D /BC 0 D /UI 0 D /PF f D /Cc 0 D /cC 0 D /Dc 10 array D + /NR [0 1 9{pop 0}for] D /La Ds D /AR 10 array D /TR 10 array D /AV 30 array D + SI /AL -1 D /AT A0 D AT NA /OV 9 array D /Yo 0 D /Co 0 D /Io 0 D /Hy f D + /Ph f D /CL -1 D Ct Sc}D +/ZF {/FR [0 1 30{pop 0}for] D /SZ [0 1 30{pop 0}for] D /FO [0 1 30{pop 0}for] D + /SL 0 D /CF 0 D /FN 0 D 0 Ts SF}D +/QO [[(\234)(\233)(\253\240)(\232)(\273)(\253)][(')(`)(\253\240)(\231)(\273)(\253)]] D +/QC [[(\234)(\234)(\240\273)(\233)(\253)(\273)][(')(')(\240\273)(`)(\253)(\273)]] D +/Hf EF length 2 sub D +/Hz EZ Hf get D +/HS Ey Hf get D +/Fz EZ Hf 1 add get D +/Fs Ey Hf 1 add get D +/LE IL D +/Ps EZ 1 get D +/Fp EF 1 get D +/XO 0 D +/YI 0 D +/CI 0 D +/FP 0 D +/WW Ts 7 mul D +/Mf 0 D +/YA 0 D +/YB 0 D +/Cs Ts D +/GS Ts D +/F0 0 D +/NS 0 D +/NB 0 D +/N 0 D +/C0 [] D +/C1 () D +/Lo 0 D +/L1 0 D +/LM 0 D +/PH 0 D +/EC 0 D +/Lh 0 D +/LT 0 D +/CH 1 string D +/ST 16 string D +/CA 9 array D +/HC (\255) D +/HM f D +/PF f D +/EN f D +/TB f D +/UF f D +/sF f D +/AE f D +/AF f D +/BP t D +/CD f D +/PA t D +/GL f D +/T t D +/HF f D +/AH f D +/SA f D +/PB f D +/f1 f D +/mF f D +/OX 0 D +/OY 0 D +/FY 0 D +/EO 0 D +/FB 0 D +/PL 0 D +/Bw 0 D +/PD -1 D +/TP f D +/tp f D +/TH t D +/Ty 4 D +/Tn -1 D +/Fl t D +/LB t D +/PM 1 D +/Ms f D +/Ba f D +/Bb f D +/Hl 3 D +/hl 6 D +/Hv 6 D +/Hs f D +/HI 0 D +/hi 0 D +/PO t D +/TE f D +/LF t D +/BO 0 D +/Sm 1 D +/Bf 3 D +/A1 0 D +/A2 0 D +/Ds 1 D +/QL -1 D +/Cb Db D +/Ct Dt D +/Cl Dl D +[/Creator (html2ps version 1.0 beta7) /Author () /Keywords (xsd, xml, schema, c++, mapping, data, binding, tree, serialization, guide, manual, examples) /Subject () + /Title (C++/Tree Mapping User Manual) /DOCINFO pdfmark +/ND 1 D +/HN [(1) (1) (1) (1) (1) (1) (1) (2) (2) (2) (2) (3) (3) (4) (4) (5) (5) (5) +(6) (6) (7) (7) (??) (10) (11) (12) (13) (14) (16) (19) (20) (21) (22) (24) +(24) (25) (26) (27) (28) (29) (29) (30) (31) (32) (33) (37) (37) (37) (39) +(41) (45) (48) (55) (55) (58) (59) (60) (62) (64) (65) (68) (74) (75) (80) +(82) (85) (85) (86) (88) (89) (89) (90) (91) (91) (91) (92) (92) (93) (93) +(94) (94) (94) (96) (97) (99) (99) (100) (100) (100) (101) (101) (102) (103) +(103) (106) (107) (??) (1) (1) (1) (1) (2) (2) (2) (2) (3) (3) (4) (4) (5) +(5) (5) (6) (6) (7) (7) (10) (11) (12) (13) (14) (16) (19) (20) (21) (22) +(24) (24) (25) (26) (27) (28) (29) (29) (30) (31) (32) (33) (37) (37) (37) +(39) (41) (45) (48) (55) (55) (58) (59) (60) (62) (64) (65) (68) (74) (75) +(80) (82) (85) (85) (86) (88) (89) (89) (90) (91) (91) (91) (92) (92) (93) +(93) (94) (94) (94) (96) (97) (99) (99) (100) (100) (100) (101) (101) (102) +(103) (103) (106) (107)] D +/h0 [()(Table of Contents)] D +/h1 [(1\240\240)(Preface)] D +/h2 [(1.1\240\240)(About This Document)] D +/h3 [(1.2\240\240)(More Information)] D +/h4 [(2\240\240)(1 Introduction)] D +/h5 [(3\240\240)(2 C++/Tree Mapping)] D +/h6 [(3.1\240\240)(2.1 Preliminary Information)] D +/h7 [(3.1.1\240\240)(2.1.1 C++ Standard)] D +/h8 [(3.1.2\240\240)(2.1.2 Identifiers)] D +/h9 [(3.1.3\240\240)(2.1.3 Character Type and Encoding)] D +/h10 [(3.1.4\240\240)(2.1.4 XML Schema Namespace)] D +/h11 [(3.1.5\240\240)(2.1.5 Anonymous Types)] D +/h12 [(3.2\240\240)(2.2 Error Handling)] D +/h13 [(3.2.1\240\240)(2.2.1 xml_schema::duplicate_id)] D +/h14 [(3.3\240\240)(2.3 Mapping for import and include)] D +/h15 [(3.3.1\240\240)(2.3.1 Import)] D +/h16 [(3.3.2\240\240)(2.3.2 Inclusion with Target Namespace)] D +/h17 [(3.3.3\240\240)(2.3.3 Inclusion without Target Namespace)] D +/h18 [(3.4\240\240)(2.4 Mapping for Namespaces)] D +/h19 [(3.5\240\240)(2.5 Mapping for Built-in Data Types)] D +/h20 [(3.5.1\240\240)(2.5.1 Inheritance from Built-in Data Types)] D +/h21 [(3.5.2\240\240)(2.5.2 Mapping for anyType)] D +/h22 [(3.5.3\240\240)(2.5.3 Mapping for anySimpleType)] D +/h23 [(3.5.4\240\240)(2.5.4 Mapping for QName)] D +/h24 [(3.5.5\240\240)(2.5.5 Mapping for IDREF)] D +/h25 [(3.5.6\240\240)(2.5.6 Mapping for base64Binary and hexBinary)] D +/h26 [(3.6\240\240)(2.5.7 Time Zone Representation)] D +/h27 [(3.7\240\240)(2.5.8 Mapping for date)] D +/h28 [(3.8\240\240)(2.5.9 Mapping for dateTime)] D +/h29 [(3.9\240\240)(2.5.10 Mapping for duration)] D +/h30 [(3.10\240\240)(2.5.11 Mapping for gDay)] D +/h31 [(3.11\240\240)(2.5.12 Mapping for gMonth)] D +/h32 [(3.12\240\240)(2.5.13 Mapping for gMonthDay)] D +/h33 [(3.13\240\240)(2.5.14 Mapping for gYear)] D +/h34 [(3.14\240\240)(2.5.15 Mapping for gYearMonth)] D +/h35 [(3.15\240\240)(2.5.16 Mapping for time)] D +/h36 [(3.16\240\240)(2.6 Mapping for Simple Types)] D +/h37 [(3.16.1\240\240)(2.6.1 Mapping for Derivation by Restriction)] D +/h38 [(3.16.2\240\240)(2.6.2 Mapping for Enumerations)] D +/h39 [(3.16.3\240\240)(2.6.3 Mapping for Derivation by List)] D +/h40 [(3.16.4\240\240)(2.6.4 Mapping for Derivation by Union)] D +/h41 [(3.17\240\240)(2.7 Mapping for Complex Types)] D +/h42 [(3.17.1\240\240)(2.7.1 Mapping for Derivation by Extension)] D +/h43 [(3.17.2\240\240)(2.7.2 Mapping for Derivation by Restriction)] D +/h44 [(3.18\240\240)(2.8 Mapping for Local Elements and Attributes)] D +/h45 [(3.18.1\240\240)(2.8.1 Mapping for Members with the One Cardinality Class)] D +/h46 [(3.18.2\240\240)(2.8.2 Mapping for Members with the Optional Cardinality Class)] D +/h47 [(3.18.3\240\240)(2.8.3 Mapping for Members with the Sequence Cardinality Class)] D +/h48 [(3.18.4\240\240)(2.8.4 Element Order)] D +/h49 [(3.19\240\240)(2.9 Mapping for Global Elements)] D +/h50 [(3.19.1\240\240)(2.9.1 Element Types)] D +/h51 [(3.19.2\240\240)(2.9.2 Element Map)] D +/h52 [(3.20\240\240)(2.10 Mapping for Global Attributes)] D +/h53 [(3.21\240\240)(2.11 Mapping for xsi:type and Substitution Groups)] D +/h54 [(3.22\240\240)(2.12 Mapping for any and anyAttribute)] D +/h55 [(3.22.1\240\240)(2.12.1 Mapping for any with the One Cardinality Class)] D +/h56 [(3.22.2\240\240)(2.12.2 Mapping for any with the Optional Cardinality Class)] D +/h57 [(3.22.3\240\240)(2.12.3 Mapping for any with the Sequence Cardinality Class)] D +/h58 [(3.22.4\240\240)(2.12.4 Element Wildcard Order)] D +/h59 [(3.22.5\240\240)(2.12.5 Mapping for anyAttribute)] D +/h60 [(3.23\240\240)(2.13 Mapping for Mixed Content Models)] D +/h61 [(4\240\240)(3 Parsing)] D +/h62 [(4.1\240\240)(3.1 Initializing the Xerces-C++ Runtime)] D +/h63 [(4.2\240\240)(3.2 Flags and Properties)] D +/h64 [(4.3\240\240)(3.3 Error Handling)] D +/h65 [(4.3.1\240\240)(3.3.1 xml_schema::parsing)] D +/h66 [(4.3.2\240\240)(3.3.2 xml_schema::expected_element)] D +/h67 [(4.3.3\240\240)(3.3.3 xml_schema::unexpected_element)] D +/h68 [(4.3.4\240\240)(3.3.4 xml_schema::expected_attribute)] D +/h69 [(4.3.5\240\240)(3.3.5 xml_schema::unexpected_enumerator)] D +/h70 [(4.3.6\240\240)(3.3.6 xml_schema::expected_text_content)] D +/h71 [(4.3.7\240\240)(3.3.7 xml_schema::no_type_info)] D +/h72 [(4.3.8\240\240)(3.3.8 xml_schema::not_derived)] D +/h73 [(4.3.9\240\240)(3.3.9 xml_schema::no_prefix_mapping)] D +/h74 [(4.4\240\240)(3.4 Reading from a Local File or URI)] D +/h75 [(4.5\240\240)(3.5 Reading from std::istream)] D +/h76 [(4.6\240\240)(3.6 Reading from xercesc::InputSource)] D +/h77 [(4.7\240\240)(3.7 Reading from DOM)] D +/h78 [(5\240\240)(4 Serialization)] D +/h79 [(5.1\240\240)(4.1 Initializing the Xerces-C++ Runtime)] D +/h80 [(5.2\240\240)(4.2 Namespace Infomap and Character Encoding)] D +/h81 [(5.3\240\240)(4.3 Flags)] D +/h82 [(5.4\240\240)(4.4 Error Handling)] D +/h83 [(5.4.1\240\240)(4.4.1 xml_schema::serialization)] D +/h84 [(5.4.2\240\240)(4.4.2 xml_schema::unexpected_element)] D +/h85 [(5.4.3\240\240)(4.4.3 xml_schema::no_type_info)] D +/h86 [(5.5\240\240)(4.5 Serializing to std::ostream)] D +/h87 [(5.6\240\240)(4.6 Serializing to xercesc::XMLFormatTarget)] D +/h88 [(5.7\240\240)(4.7 Serializing to DOM)] D +/h89 [(6\240\240)(5 Additional Functionality)] D +/h90 [(6.1\240\240)(5.1 DOM Association)] D +/h91 [(6.2\240\240)(5.2 Binary Serialization)] D +/h92 [(7\240\240)(Appendix A \236 Default and Fixed Values)] D +/Hr [97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 +115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 +133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 +151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 +169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 +187 188]D +/HV [1 2 2 1 1 2 3 3 3 3 3 2 3 2 3 3 3 2 2 3 3 3 3 3 3 2 2 2 2 2 2 2 2 +2 2 2 3 3 3 3 2 3 3 2 3 3 3 3 2 3 3 2 2 2 3 3 3 3 3 2 1 2 2 2 3 3 3 3 3 +3 3 3 3 2 2 2 2 1 2 2 2 2 3 3 3 2 2 2 1 2 2 1]D +/Cn [2 0 0 0 23 5 0 0 0 0 0 1 0 3 0 0 0 0 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 4 0 0 0 0 2 0 0 4 0 0 0 0 2 0 0 0 0 5 0 0 0 0 0 0 7 0 0 9 0 0 0 0 0 +0 0 0 0 0 0 0 0 7 0 0 0 3 0 0 0 0 0 0 2 0 0 0]D +Hr length 0 gt{[/PageMode /UseOutlines /DOCVIEW pdfmark}if +/Hn 1 D +0 1 Hr length 1 sub{ + /Bn E D [Cn Bn get dup 0 gt{/Count E HV Bn get Bl ge{neg}if}{pop}ie + /Dest Hr Bn get dup abs ST cvs cvn E 0 ge{(h)Hn ST cvs join cvx exec + dup 1 get E Nf{0 get E join}{pop}ie /Hn Hn 1 add D}{()}ie + /Title E dup length 255 gt{0 255 getinterval}if /OUT pdfmark}for +ZF /FN Fp D Ps 0 FS /WC Wf{( )}{<A1A1>}ie SW pop D +ET RC ZF +/Df f D +/R0 (http://www.codesynthesis.com/licenses/fdl-1.2.txt) D +/R1 (http://www.codesynthesis.com/projects/xsd/documentation/cxx/tree/manual/index.xhtml) D +/R2 (http://www.codesynthesis.com/projects/xsd/documentation/cxx/tree/manual/cxx-tree-manual.pdf) D +/R3 (http://www.codesynthesis.com/projects/xsd/documentation/cxx/tree/manual/cxx-tree-manual.ps) D +/R1 (http://www.codesynthesis.com/products/xsd) D +/R2 (http://codesynthesis.com/projects/xsd/documentation/cxx/tree/manual/index.xhtml) D +/R3 (http://codesynthesis.com/projects/xsd/documentation/cxx/tree/manual/cxx-tree-manual.pdf) D +/R4 (http://codesynthesis.com/projects/xsd/documentation/cxx/tree/manual/cxx-tree-manual.ps) D +/R5 (http://www.codesynthesis.com/projects/xsd/documentation/cxx/tree/guide/) D +/R6 (http://wiki.codesynthesis.com/Tree/Customization_guide) D +/R7 (http://wiki.codesynthesis.com/Tree/FAQ) D +/R8 (http://www.codesynthesis.com/projects/xsd/documentation/xsd.xhtml) D +/R9 (http://www.codesynthesis.com/mailman/listinfo/xsd-users) D +/R10 (http://www.codesynthesis.com/pipermail/xsd-users/) D +/R11 (http://en.wikipedia.org/wiki/Character_code) D +/TS { + tables E get /table E D + table aload pop /rdesc E D /cdesc E D /tdesc E D + tdesc aload pop /capalg E D /caption E D /rules E D /frame E D /nfoot E D + /nhead E D /ncol E D /nrow E D /border E D /twid E D /units E D /talign E D + /flow E D /clear E D /tclass E D pop pop + /w W D /eps 0.1 D /OU f D /PL 1 D + /FN EF 21 get D EZ 21 get Ey 21 get FS + 0 1 1{ + /pass E D + 0 1 nrow{ + /irow E D + /cells rdesc irow get 6 get D + 0 1 ncol{ + /icol E D + /cell cells icol get D + cell 0 ne{ + cell aload pop /ang E D /CB E D pop pop pop + /DV E D /bot E D /top E D /right E D /left E D /nowrap E D /valign E D + /dp E D /align E D /rspan E D /cspan E D /cclass E D /ctype E D /cmax E D + /cmin E D /proc E D + rspan 0 eq{/rspan nrow irow sub 1 add D}if + cspan 0 eq{/cspan ncol icol sub 1 add D}if + pass 0 eq cspan 1 eq and pass 1 eq cspan 1 gt and or{ + /W 1e5 D /LL W D /PH 1 D + ctype 1 eq{() BD}if + RC align NA + AT 4 eq{/CD t D /DC dp D /LN 0 D /M1 0 D /M2 0 D}{/CD f D}ie + 0 0 M /LM 0 D proc exec BN + AT 4 eq{ + LN array astore cell 15 3 -1 roll put + cdesc icol get dup dup 5 get M1 lt{5 M1 put}{5 get /M1 E D}ie + dup 6 get M2 lt{6 M2 put}{6 get /M2 E D}ie + /LM M1 M2 add D + }if + /CD f D + ang 0 ne{/LM CP E pop neg D}if + /thiswid LM left add right add eps add D + /oldmin 0 D /oldmax 0 D + 0 1 cspan 1 sub{ + icol add cdesc E get dup 2 get /oldmax E oldmax add D + 1 get /oldmin E oldmin add D + }for + thiswid oldmax ge{ + 0 1 cspan 1 sub{ + icol add cdesc E get dup 2 E 2 get oldmax 0 eq + {pop thiswid cspan div}{thiswid mul oldmax div}ie + put + }for + }if + nowrap 1 eq{ + thiswid oldmin ge{ + 0 1 cspan 1 sub{ + icol add cdesc E get dup 1 E 1 get oldmin 0 eq + {pop thiswid cspan div}{thiswid mul oldmin div}ie + put + }for + }if + }{ + /W 0 D /LL W D /PH 2 D + ctype 1 eq{() ES () BD}if + 0 0 M /LM 0 D RC proc exec BN + /thiswid LM left add right add eps add D + thiswid oldmin ge{ + 0 1 cspan 1 sub{ + icol add cdesc E get dup 1 E 1 get oldmin 0 eq + {pop thiswid cspan div}{thiswid mul oldmin div}ie + put + }for + }if + }ie + ctype 1 eq{() ES}if + }if + }if + }for + }for + }for + /tmin 0 D /tmax 0 D + 0 1 ncol{ + cdesc E get dup 1 get E 2 get 2 copy gt{pop dup}if + tmax add /tmax E D tmin add /tmin E D + }for + twid 0 lt{twid neg IW gt{IW neg}{twid}ie /twid E D}if + tdesc 0 twid neg tmin 2 copy lt{E}if pop put + tdesc 1 twid neg tmax 2 copy lt{E}if pop put + /W w D /LL W D /OU t D /PH 0 D /PL 0 D +} D +/PT { + /PL PL 1 add D + tables E get /table E D Tm 21 get Ts mul BE + PL 2 ge{save}if + /SL SL 1 add D /FN EF 21 get D EZ 21 get Ey 21 get FS + table aload pop /rdesc E D /cdesc E D /tdesc E D + tdesc aload pop /capalg E D /caption E D /rules E D /frame E D /nfoot E D + /nhead E D /ncol E D /nrow E D /border E D /twid E D /units E D /talign E D + /flow E D /clear E D /tclass E D /tmax E D /tmin E D + /w W D /xo XO D /mr MR D /ll LL D /lg LG D /ai AI D /bc BC D /nr NR D /ar AR D + /tr TR D /ui UI D /ph PH D /a0 A0 D /pf PF D /at AT D /av AV D /al AL D + /Le LE D /la La D + talign 0 lt{/talign AL 0 gt{AV AL get}{A0 2 le{A0}{0}ie}ie D}if + ph 1 eq ph 2 eq or{ + NL ph 1 eq{tmax}{tmin}ie dup XO add LM gt{/LM E XO add D}{pop}ie LM E + }{ + /PH 3 D /LE 1e5 D RC %ZF + border 0 gt{/border 1 D}if + /twidth 0 D /avail W xo sub D + twid 0 eq{0 1 ncol{cdesc E get dup 2 get E 3 get dup 0 gt{div neg dup twid lt + {/twid E D}{pop}ie}{pop pop}ie}for}if + /twid twid dup 0 lt{neg avail 2 copy gt{E}if pop}{avail mul}ie D + /OK t D 0 1 ncol{cdesc E get dup 1 get E 3 get twid mul gt{/OK f D}if}for + 0 1 ncol{ + cdesc E get dup 1 get /colmin E D dup 3 get /cwid E twid mul D dup + tmax avail le{2 get}if + tmin avail le tmax avail gt and{ + dup 2 get E 1 get dup 3 1 roll sub avail tmin sub mul tmax tmin sub div add + }if + tmin avail gt{1 get}if + 0 E colmin cwid lt OK and{pop cwid}if dup /twidth E twidth add D put + }for + /OU f D CP + tmin twid le{ + 0 1 ncol{cdesc E get dup 0 get twidth div twid mul 0 E put}for + /twidth twid D + }if + CP printcap CP E pop sub /caphig E D pop + 0 1 1{ + /pass E D + 0 1 nrow{ + /irow E D + /cells rdesc irow get 6 get D + 0 1 ncol{ + /icol E D + /cell cells icol get D + cell 0 ne{ + cell aload pop /ang E D /CB E D pop pop pop + /DV E D /bot E D /top E D /right E D /left E D /nowrap E D /valign E D + /dp E D /align E D /rspan E D /cspan E D /cclass E D /ctype E D /cmax E D + /cmin E D /proc E D + rspan 0 eq{/rspan nrow irow sub 1 add D}if + cspan 0 eq{/cspan ncol icol sub 1 add D}if + /W 0 D + 0 1 cspan 1 sub{icol add cdesc E get 0 get /W E W add D}for + pass 0 eq rspan 1 eq and pass 1 eq rspan 1 gt and or{ + ctype 1 eq{() BD}if + /W W left sub right sub D /XO 0 D /EO 0 D SI + /A0 align D RC align NA + AT 4 eq{ + /DC dp D /DO 0 D /ID 1 D + 0 1 DV length 1 sub{DV E get dup DO gt{/DO E D}{pop}ie}for + /Lo DO DV 0 get sub D /L1 Lo D + }if + 0 0 M /BP t D /Fl t D /MF 0 D /FB 0 D + proc exec T not{/CI 0 D}if BN 0 FB neg R MF 0 eq{/MF CS D}if + CP /thishig E neg bot add top add CI add D pop + ang 0 ne{/thishig LM bot add top add D}if + cell 16 MF put cell 17 Ya put cell 18 thishig put + valign 4 eq{ + /below thishig Ya sub D + rdesc irow get dup dup 4 get Ya lt + {4 Ya put}{4 get /Ya E D}ie + dup 5 get below lt{5 below put}{5 get /below E D}ie + /thishig Ya below add D + }if + ctype 1 eq{()ES}if + /oldhig 0 D + 0 1 rspan 1 sub{ + irow add rdesc E get 0 get /oldhig E oldhig add D + }for + thishig oldhig ge{ + 0 1 rspan 1 sub{ + irow add rdesc E get dup 0 E 0 get oldhig 0 eq + {pop thishig rspan div}{thishig mul oldhig div}ie + put + }for + }if + }if + }if + }for + }for + }for M RC %ZF + /thight 0 D /racc 0 D /maxh 0 D /brk 0 D /rbeg nhead nfoot add D + 0 1 nrow{ + rdesc E get dup 0 get dup /thight E thight add D + brk 0 eq{/racc E D}{/racc E racc add D}ie + racc maxh gt{/maxh racc D}if 2 get /brk E D + }for + ph 3 ge{thight caphig add E}if + ph 0 eq ph 4 eq or{ + /PH 4 D /LE Le D /OU Ou D /yoff 0 D /headsz 0 D + 0 1 nhead 1 sub{rdesc E get 0 get headsz add /headsz E D}for + /footsz 0 D + 0 1 nfoot 1 sub{rdesc E nhead add get 0 get footsz add /footsz E D}for + /ahig LE BO add MI add D /maxh maxh headsz add footsz add D + /thight thight headsz add footsz add D + tmin avail gt maxh ahig gt or + {/Sf avail tmin div dup ahig maxh div gt{pop ahig maxh div}if D /SA t D} + {/Sf 1 D}ie + tclass 1 eq thight LE 15 sub gt and + {/SA t D LE 15 sub thight div dup Sf lt{/Sf E D}{pop}ie}if + SA{Sf Sf scale /ll ll Sf div D /xo xo Sf div D /LE LE Sf div D + /mr mr Sf div D /BO BO Sf div D /ahig ahig Sf div D}if + nhead nfoot add getwid + LE CP E pop add capalg 0 eq{caphig sub}if + bT{f}{dup thight lt thight ahig lt and}ie + E headsz sub footsz sub rwid lt or{NP}if + capalg 0 eq{printcap -8 SP}if + CP /ycur E D pop + printhead + rbeg 1 nrow{/row E D row + getwid + ycur yoff add rwid sub footsz sub LE add 0 lt + {nfoot 0 gt{printfoot}if Tf NP /rbeg irow1 D + Ba{MI /MI MI SA{Sf div}if D MI SP /MI E D}if + CP /ycur E D pop /yoff 0 D printhead}if + irow1 printrow + }for + printfoot /row row 1 add D Tf + 0 ycur yoff add M + capalg 1 eq{/EO 0 D SI -3 SP printcap}if + Sf 1 lt{1 Sf div dup scale /ll ll Sf mul D /xo xo Sf mul D /LE LE Sf mul D + /mr mr Sf mul D /BO BO Sf mul D /SA f D}if + /EO 0 D + }if + }ie + /W w D /XO xo D /MR mr D /LL ll D /LG lg D /AI ai D /BC bc D /NR nr D /AR ar D + /TR tr D /UI ui D /PH ph D /A0 a0 D /PF pf D /AT at D /AV av D /AL al D + /La la D + /SL SL 1 sub NN D /CF 0 D /FN 0 D SZ SL get FR SL get FS Wf not{()F2}if + PL 2 ge{Ms E restore Ms or /Ms E D PH 1 eq PH 2 eq or + {/LM E D}if PH 3 ge{/CI 0 D NL 0 E neg R}if + }if + /PL PL 1 sub D /CI 0 D /BP f D /PO f D () Bm 21 get Ts mul BE BL %CF CS SF +} D +/printcap{ + capalg 0 ge{ + SA{/W w Sf div D} + {talign 1 eq{/XO xo ll twidth sub 2 div add D}if + talign 2 eq{/XO xo ll twidth sub add D}if + /W XO twidth add D + }ie /XO xo D /LL W XO sub MR sub D + /PA f D /Fl capalg 0 eq D + 1 NA BL caption exec BN OA /PA t D + }if +} D +/getwid{ + /irow1 E D + /irow2 irow1 D + /rwid 0 D + {rdesc irow2 get dup 0 get rwid add /rwid E D 2 get 0 eq + {exit}{/irow2 irow2 1 add D}ie + }loop +} D +/printrow{ + /xoff ll twidth PL 2 ge{Sf div}if sub talign mul 2 div D + /xleft xoff xo add D + /irow E D + /cells rdesc irow get 6 get D + 0 1 ncol{ + /icol E D + /cell cells icol get D + cell 0 ne{ + cell aload pop /ang E D /CB E D /cvsize E D /above E D /fontsz E D + /DV E D /bot E D /top E D /right E D /left E D /nowrap E D /valign E D + /dp E D /align E D /rspan E D /cspan E D /cclass E D /ctype E D /cmax E D + /cmin E D /proc E D + rspan 0 eq{/rspan nrow irow sub 1 add D}if + cspan 0 eq{/cspan ncol icol sub 1 add D}if + /width 0 D + 0 1 cspan 1 sub{icol add cdesc E get 0 get /width E width add D}for + /rhight rdesc irow get 0 get D + /hight rhight D + 1 1 rspan 1 sub{irow add rdesc E get 0 get /hight E hight add D}for + /W xo xoff add width add right sub D + ang 0 ne{/W xo xoff add hight add right sub D}if + /EO xo xoff add left add D SI + Cf{ + gsave CB VC xo xoff add ycur yoff add M + 0 hight neg RL width 0 RL 0 hight RL width neg 0 RL fill + grestore + }if + ctype 1 eq{() BD}if + /A0 align D RC + AT 4 eq{ + /DC dp D /ID 1 D /DO cdesc icol get 5 get D /Lo DO DV 0 get sub D /L1 Lo D + }if + ang 0 ne{ + gsave ang 90 eq + {xoff ycur add hight cvsize sub 2 div sub ycur hight sub xoff sub} + {xoff ycur sub width add hight cvsize sub 2 div add ycur xoff add}ie + translate ang rotate + }if + valign 3 le{0 ycur yoff add top sub + hight cvsize sub valign 1 sub mul 2 div sub M} + {0 ycur yoff add top sub above add rdesc irow get 4 get sub M}ie + /PA f D /BP t D /Fl t D + BL proc exec BN + ang 0 ne{grestore}if + /PA t D + ctype 1 eq{() ES}if + }if + /xoff xoff cdesc icol get 0 get add D + }for + /yoff yoff rhight sub D +} D +/printhead {0 1 nhead 1 sub{printrow}for} D +/printfoot {nhead 1 nhead nfoot add 1 sub{printrow}for} D +/Tf { + OU{rules 2 ge{/yoff 0 D + gsave 0 Sg + [0 1 nhead 1 sub{}for rbeg 1 row 1 sub{}for nhead 1 nhead nfoot add 1 sub{}for]{ + /irow E D + /xoff ll twidth PL 2 ge{Sf div}if sub talign mul 2 div D + /cells rdesc irow get 6 get D + 0 1 ncol{ + /icol E D + /cell cells icol get D + cell 0 ne{ + /rspan cell 6 get D + /cspan cell 5 get D + rspan 0 eq{/rspan nrow irow sub 1 add D}if + cspan 0 eq{/cspan ncol icol sub 1 add D}if + /width 0 D + 0 1 cspan 1 sub{icol add cdesc E get 0 get /width E width add D}for + /rhight rdesc irow get 0 get D + /hight rhight D + 1 1 rspan 1 sub{irow add rdesc E get 0 get /hight E hight add D}for + xo xoff add width add ycur yoff add M + 0 hight neg icol cspan add 1 sub ncol lt + {cdesc icol 1 add get 4 get dup rules 3 le{1 eq}{pop t}ie + {1 eq{0.8}{0.3}ie + LW RL CP stroke M}{pop R}ie}{R}ie + irow nhead nfoot add 1 sub ne nfoot 0 eq or + {irow rspan add 1 sub nrow lt + {rdesc irow rspan add get 3 get}{nfoot 0 eq{0}{1}ie}ie + dup rules 2 mod 0 eq{1 eq}{pop t}ie + {1 eq irow rspan add nhead eq or irow rspan add row eq nfoot 0 gt and or + {0.8}{0.3}ie LW width neg 0 RL CP stroke M}{pop}ie}if + }if + /xoff xoff cdesc icol get 0 get add D + }for + /yoff yoff rhight sub D + }forall + grestore + /Ms t D + }if + frame 1 gt{ + gsave + 1 LW 0 Sg + xleft ycur M CP BB + 0 yoff frame 5 eq frame 7 ge or{RL}{R}ie + twidth 0 frame 3 eq frame 4 eq or frame 8 ge or{RL}{R}ie CP BB + 0 yoff neg frame 6 ge{RL}{R}ie + twidth neg 0 frame 2 eq frame 4 eq or frame 8 ge or{RL}{R}ie + closepath stroke + grestore + /Ms t D + }if + }if +} D +/tables [[[0 0 0 0 0 -1 0 0 1 58 2 0 0 9 5 {()} -1] + [[0 0 0 0 0 0 0][0 0 0 0 0 0 0][0 0 0 0 0 0 0]] + [[0 0 0 0 0 0 [[{()1 Sl()WB(XML Schema type)} 0 0 1 0 1 1 1 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB(Alias in the )SM(xml_schema)ES( names)HY(pace)YH()} 0 0 1 0 1 1 1 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB(C++ type + )} 0 0 1 0 1 1 1 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +]] +[0 0 0 0 0 0 [[{()1 Sl()WB(anyType and anySim)HY(ple)HY(Type)YH( types + )} 0 0 1 0 3 1 1 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +0 +0 +]] +[0 0 0 0 0 0 [[{()1 Sl()WB()SM(anyType)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(type)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()0 24 1 A(Section 2.5.2, "Mapping for )SM(anyType)ES(")24 0 TN TL()Ec /AF f D( + )} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +]] +[0 0 0 0 0 0 [[{()1 Sl()WB()SM(anySim)HY(ple)HY(Type)YH()ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(simple_type)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()0 25 1 A(Section 2.5.3, "Mapping for )SM(anySim)HY(ple)HY(Type)YH()ES(")25 0 TN TL()Ec /AF f D( + )} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +]] +[0 0 0 0 0 0 [[{()1 Sl()WB(fixed-length inte)HY(gral)YH( types + )} 0 0 1 0 3 1 1 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +0 +0 +]] +[0 0 0 0 0 0 [[{()1 Sl()WB()SM(byte)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(byte)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(signed\240char)ES( + )} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +]] +[0 0 0 0 0 0 [[{()1 Sl()WB()SM(unsigned)HY(Byte)YH()ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(unsigned_byte)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(unsigned\240char)ES( + )} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +]] +[0 0 0 0 0 0 [[{()1 Sl()WB()SM(short)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(short_)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(short)ES( + )} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +]] +[0 0 0 0 0 0 [[{()1 Sl()WB()SM(unsigned)HY(Short)YH()ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(unsigned_short)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(unsigned\240short)ES( + )} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +]] +[0 0 0 0 0 0 [[{()1 Sl()WB()SM(int)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(int_)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(int)ES( + )} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +]] +[0 0 0 0 0 0 [[{()1 Sl()WB()SM(unsignedInt)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(unsigned_int)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(unsigned\240int)ES( + )} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +]] +[0 0 0 0 0 0 [[{()1 Sl()WB()SM(long)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(long_)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(long\240long)ES( + )} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +]] +[0 0 0 0 0 0 [[{()1 Sl()WB()SM(unsigned)HY(Long)YH()ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(unsigned_long)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(unsigned\240long\240long)ES( + )} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +]] +[0 0 0 0 0 0 [[{()1 Sl()WB(arbi)HY(trary)YH(-length inte)HY(gral)YH( types + )} 0 0 1 0 3 1 1 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +0 +0 +]] +[0 0 0 0 0 0 [[{()1 Sl()WB()SM(integer)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(integer)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(long\240long)ES( + )} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +]] +[0 0 0 0 0 0 [[{()1 Sl()WB()SM(nonPos)HY(i)HY(tiveIn)HY(te)HY(ger)YH()ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(non_posi)HY(tive)YH(_integer)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(long\240long)ES( + )} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +]] +[0 0 0 0 0 0 [[{()1 Sl()WB()SM(nonNeg)HY(a)HY(tiveIn)HY(te)HY(ger)YH()ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(non_nega)HY(tive)YH(_integer)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(unsigned long\240long)ES( + )} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +]] +[0 0 0 0 0 0 [[{()1 Sl()WB()SM(posi)HY(tiveIn)HY(te)HY(ger)YH()ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(posi)HY(tive)YH(_integer)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(unsigned long\240long)ES( + )} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +]] +[0 0 0 0 0 0 [[{()1 Sl()WB()SM(nega)HY(tiveIn)HY(te)HY(ger)YH()ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(nega)HY(tive)YH(_integer)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(long\240long)ES( + )} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +]] +[0 0 0 0 0 0 [[{()1 Sl()WB(boolean types + )} 0 0 1 0 3 1 1 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +0 +0 +]] +[0 0 0 0 0 0 [[{()1 Sl()WB()SM(boolean)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(boolean)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(bool)ES( + )} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +]] +[0 0 0 0 0 0 [[{()1 Sl()WB(fixed-preci)HY(sion)YH( float)HY(ing)YH(-point types + )} 0 0 1 0 3 1 1 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +0 +0 +]] +[0 0 0 0 0 0 [[{()1 Sl()WB()SM(float)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(float_)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(float)ES( + )} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +]] +[0 0 0 0 0 0 [[{()1 Sl()WB()SM(double)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(double_)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(double)ES( + )} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +]] +[0 0 0 0 0 0 [[{()1 Sl()WB(arbi)HY(trary)YH(-preci)HY(sion)YH( float)HY(ing)YH(-point types + )} 0 0 1 0 3 1 1 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +0 +0 +]] +[0 0 0 0 0 0 [[{()1 Sl()WB()SM(decimal)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(decimal)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(double)ES( + )} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +]] +[0 0 0 0 0 0 [[{()1 Sl()WB(string types + )} 0 0 1 0 3 1 1 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +0 +0 +]] +[0 0 0 0 0 0 [[{()1 Sl()WB()SM(string)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(string)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB(type derived from )SM(std::basic_string)ES( + )} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +]] +[0 0 0 0 0 0 [[{()1 Sl()WB()SM(normal)HY(ized)HY(String)YH()ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(normal)HY(ized)YH(_string)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB(type derived from )SM(string)ES( + )} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +]] +[0 0 0 0 0 0 [[{()1 Sl()WB()SM(token)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(token)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB(type\240derived\240from\240)SM(normal)HY(ized)YH(_string)ES( + )} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +]] +[0 0 0 0 0 0 [[{()1 Sl()WB()SM(Name)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(name)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB(type derived from )SM(token)ES( + )} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +]] +[0 0 0 0 0 0 [[{()1 Sl()WB()SM(NMTOKEN)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(nmtoken)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB(type derived from )SM(token)ES( + )} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +]] +[0 0 0 0 0 0 [[{()1 Sl()WB()SM(NMTO)HY(KENS)YH()ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(nmto)HY(kens)YH()ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB(type derived from )SM(sequence<nmtoken>)ES( + )} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +]] +[0 0 0 0 0 0 [[{()1 Sl()WB()SM(NCName)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(ncname)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB(type derived from )SM(name)ES( + )} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +]] +[0 0 0 0 0 0 [[{()1 Sl()WB()SM(language)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(language)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB(type derived from )SM(token)ES( + )} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +]] +[0 0 0 0 0 0 [[{()1 Sl()WB(qual)HY(i)HY(fied)YH( name + )} 0 0 1 0 3 1 1 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +0 +0 +]] +[0 0 0 0 0 0 [[{()1 Sl()WB()SM(QName)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(qname)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()0 26 1 A(Section 2.5.4, "Mapping for )SM(QName)ES(")26 0 TN TL()Ec /AF f D( + )} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +]] +[0 0 0 0 0 0 [[{()1 Sl()WB(ID/IDREF types + )} 0 0 1 0 3 1 1 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +0 +0 +]] +[0 0 0 0 0 0 [[{()1 Sl()WB()SM(ID)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(id)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB(type derived from )SM(ncname)ES( + )} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +]] +[0 0 0 0 0 0 [[{()1 Sl()WB()SM(IDREF)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(idref)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()0 27 1 A(Section 2.5.5, "Mapping for )SM(IDREF)ES(")27 0 TN TL()Ec /AF f D( + )} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +]] +[0 0 0 0 0 0 [[{()1 Sl()WB()SM(IDREFS)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(idrefs)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB(type derived from )SM(sequence<idref>)ES( + )} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +]] +[0 0 0 0 0 0 [[{()1 Sl()WB(URI types + )} 0 0 1 0 3 1 1 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +0 +0 +]] +[0 0 0 0 0 0 [[{()1 Sl()WB()SM(anyURI)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(uri)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB(type derived from )SM(std::basic_string)ES( + )} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +]] +[0 0 0 0 0 0 [[{()1 Sl()WB(binary types + )} 0 0 1 0 3 1 1 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +0 +0 +]] +[0 0 1 0 0 0 [[{()1 Sl()WB()SM(base64Binary)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(base64_binary)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()0 28 1 A(Section 2.5.6, "Mapping for + )SM(base64Binary)ES( and )SM(hexBi)HY(nary)YH()ES(")28 0 TN TL()Ec /AF f D( + )} 0 0 0 0 1 2 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +]] +[0 0 0 0 0 0 [[{()1 Sl()WB()SM(hexBi)HY(nary)YH()ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(hex_binary)ES( + )} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +0 +]] +[0 0 0 0 0 0 [[{()1 Sl()WB(date/time types + )} 0 0 1 0 3 1 1 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +0 +0 +]] +[0 0 0 0 0 0 [[{()1 Sl()WB()SM(date)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(date)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()0 30 1 A(Section 2.5.8, "Mapping for + )SM(date)ES(")30 0 TN TL()Ec /AF f D( + )} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +]] +[0 0 0 0 0 0 [[{()1 Sl()WB()SM(date)HY(Time)YH()ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(date_time)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()0 31 1 A(Section 2.5.9, "Mapping for + )SM(date)HY(Time)YH()ES(")31 0 TN TL()Ec /AF f D( + )} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +]] +[0 0 0 0 0 0 [[{()1 Sl()WB()SM(dura)HY(tion)YH()ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(dura)HY(tion)YH()ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()0 32 1 A(Section 2.5.10, "Mapping for + )SM(dura)HY(tion)YH()ES(")32 0 TN TL()Ec /AF f D( + )} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +]] +[0 0 0 0 0 0 [[{()1 Sl()WB()SM(gDay)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(gday)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()0 33 1 A(Section 2.5.11, "Mapping for + )SM(gDay)ES(")33 0 TN TL()Ec /AF f D( + )} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +]] +[0 0 0 0 0 0 [[{()1 Sl()WB()SM(gMonth)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(gmonth)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()0 34 1 A(Section 2.5.12, "Mapping for + )SM(gMonth)ES(")34 0 TN TL()Ec /AF f D( + )} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +]] +[0 0 0 0 0 0 [[{()1 Sl()WB()SM(gMon)HY(th)HY(Day)YH()ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(gmonth_day)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()0 35 1 A(Section 2.5.13, "Mapping for + )SM(gMon)HY(th)HY(Day)YH()ES(")35 0 TN TL()Ec /AF f D( + )} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +]] +[0 0 0 0 0 0 [[{()1 Sl()WB()SM(gYear)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(gyear)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()0 36 1 A(Section 2.5.14, "Mapping for + )SM(gYear)ES(")36 0 TN TL()Ec /AF f D( + )} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +]] +[0 0 0 0 0 0 [[{()1 Sl()WB()SM(gYear)HY(Month)YH()ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(gyear_month)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()0 37 1 A(Section 2.5.15, "Mapping for + )SM(gYear)HY(Month)YH()ES(")37 0 TN TL()Ec /AF f D( + )} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +]] +[0 0 0 0 0 0 [[{()1 Sl()WB()SM(time)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(time)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()0 38 1 A(Section 2.5.16, "Mapping for + )SM(time)ES(")38 0 TN TL()Ec /AF f D( + )} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +]] +[0 0 0 0 0 0 [[{()1 Sl()WB(entity types + )} 0 0 1 0 3 1 1 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +0 +0 +]] +[0 0 0 0 0 0 [[{()1 Sl()WB()SM(ENTITY)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(entity)ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB(type derived from )SM(name)ES( + )} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +]] +[0 0 0 0 0 0 [[{()1 Sl()WB()SM(ENTI)HY(TIES)YH()ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()SM(enti)HY(ties)YH()ES()} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB(type derived from )SM(sequence<entity>)ES( + )} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +]] +]] +[[0 0 0 0 0 -1 0 0 1 8 5 0 0 9 5 {()} -1] + [[0 0 0 0 0 0 0][0 0 0 0 0 0 0][0 0 0 0 0 0 0][0 0 0 0 0 0 0][0 0 0 0 0 0 0][0 0 0 0 0 0 0]] + [[0 0 0 0 0 0 [[{()1 Sl()WB()} 0 0 1 0 1 1 1 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB()} 0 0 1 0 1 1 1 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB(default)} 0 0 1 0 2 1 1 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +0 +[{()1 Sl()WB(fixed + )} 0 0 1 0 2 1 1 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +0 +]] +[0 0 1 0 0 0 [[{()1 Sl()WB(element)} 0 0 1 0 1 4 1 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB(not present)} 0 0 1 0 1 2 1 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB(optional)} 0 0 1 0 1 1 1 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB(required)} 0 0 1 0 1 1 1 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB(optional)} 0 0 1 0 1 1 1 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB(required + )} 0 0 1 0 1 1 1 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +]] +[0 0 1 0 0 0 [0 +0 +[{()1 Sl()WB(not present)} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB(invalid instance)} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB(not present)} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB(invalid instance + )} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +]] +[0 0 1 0 0 0 [0 +[{()1 Sl()WB(empty)} 0 0 1 0 1 1 1 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB(default value is used)} 0 0 0 0 2 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +0 +[{()1 Sl()WB(fixed value is used + )} 0 0 0 0 2 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +0 +]] +[0 0 0 0 0 0 [0 +[{()1 Sl()WB(value)} 0 0 1 0 1 1 1 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB(value is used)} 0 0 0 0 2 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +0 +[{()1 Sl()WB(value is used provided it's the same as fixed + )} 0 0 0 0 2 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +0 +]] +[0 0 1 0 0 0 [[{()1 Sl()WB(attribute)} 0 0 1 0 1 4 1 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB(not present)} 0 0 1 0 1 2 1 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB(optional)} 0 0 1 0 1 1 1 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB(required)} 0 0 1 0 1 1 1 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB(optional)} 0 0 1 0 1 1 1 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB(required + )} 0 0 1 0 1 1 1 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +]] +[0 0 1 0 0 0 [0 +0 +[{()1 Sl()WB(default value is used)} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB(invalid schema)} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB(fixed value is used)} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB(invalid instance + )} 0 0 0 0 1 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +]] +[0 0 1 0 0 0 [0 +[{()1 Sl()WB(empty)} 0 0 1 0 1 1 1 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB(empty value is used)} 0 0 0 0 2 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +0 +[{()1 Sl()WB(empty value is used provided it's the same as fixed + )} 0 0 0 0 2 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +0 +]] +[0 0 0 0 0 0 [0 +[{()1 Sl()WB(value)} 0 0 1 0 1 1 1 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +[{()1 Sl()WB(value is used)} 0 0 0 0 2 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +0 +[{()1 Sl()WB(value is used provided it's the same as fixed + )} 0 0 0 0 2 1 0 (.) 2 0 4 4 2 6 0 0 0 0 Db 0 ] +0 +]] +]] +] D +0 1 1{TS}for RC ZF +/Ba f D /BO 0 D Bs +/UR (/home/boris/work/xsd/xsd/doc/cxx/tree/manual/index.xhtml) D +/Ti (C++/Tree Mapping User Manual) D +/Au () D +/Df f D +/ME [(4.0.0)] D +Pt +/BO 0 D TC /Ba f D Bs /AU f D /UR () D RC ZF + tH WB +ND 1 gt{Ts 3 mul Np 0()0 C()BD(C++/Tree Mapping User Manual)ES()0 1 TN()EA()BN}if +1 NH le{97(1\240\240)1 C(Preface)WB 3 Sn()97 1 TN()EA()BN}if +2 NH le{98(1.1\240\240)2 C(About)WB 4 Sn( This Docu)HY(ment)YH()98 1 TN()EA()BN}if +2 NH le{99(1.2\240\240)2 C(More)WB 5 Sn( Infor)HY(ma)HY(tion)YH()99 1 TN()EA()BN}if +1 NH le{100(2\240\240)1 C(1)WB 6 Sn( Intro)HY(duc)HY(tion)YH()100 1 TN()EA()BN}if +1 NH le{101(3\240\240)1 C(2)WB 7 Sn( C++/Tree Mapping)101 1 TN()EA()BN}if +2 NH le{102(3.1\240\240)2 C(2.1)WB 8 Sn( Prelim)HY(i)HY(nary)YH( Infor)HY(ma)HY(tion)YH()102 1 TN()EA()BN}if +3 NH le{103(3.1.1\240\240)3 C(2.1.1)WB 9 Sn( C++ Stan)HY(dard)YH()103 1 TN()EA()BN}if +3 NH le{104(3.1.2\240\240)3 C(2.1.2)WB 10 Sn( Iden)HY(ti)HY(fiers)YH()104 1 TN()EA()BN}if +3 NH le{105(3.1.3\240\240)3 C(2.1.3)WB 11 Sn( Char)HY(ac)HY(ter)YH( Type and Encod)HY(ing)YH()105 1 TN()EA()BN}if +3 NH le{106(3.1.4\240\240)3 C(2.1.4)WB 12 Sn( XML Schema Names)HY(pace)YH()106 1 TN()EA()BN}if +3 NH le{107(3.1.5\240\240)3 C(2.1.5)WB 13 Sn( Anony)HY(mous)YH( Types)107 1 TN()EA()BN}if +2 NH le{108(3.2\240\240)2 C(2.2)WB 14 Sn( Error Handling)108 1 TN()EA()BN}if +3 NH le{109(3.2.1\240\240)3 C(2.2.1)WB 15 Sn( )SM(xml_schema::dupli)HY(cate)YH(_id)ES()109 1 TN()EA()BN}if +2 NH le{110(3.3\240\240)2 C(2.3)WB 16 Sn( Mapping for )SM(import)ES( and )SM(include)ES()110 1 TN()EA()BN}if +3 NH le{111(3.3.1\240\240)3 C(2.3.1)WB 17 Sn( Import)111 1 TN()EA()BN}if +3 NH le{112(3.3.2\240\240)3 C(2.3.2)WB 18 Sn( Inclu)HY(sion)YH( with Target Names)HY(pace)YH()112 1 TN()EA()BN}if +3 NH le{113(3.3.3\240\240)3 C(2.3.3)WB 19 Sn( Inclu)HY(sion)YH( without Target Names)HY(pace)YH()113 1 TN()EA()BN}if +2 NH le{114(3.4\240\240)2 C(2.4)WB 20 Sn( Mapping for Names)HY(paces)YH()114 1 TN()EA()BN}if +2 NH le{115(3.5\240\240)2 C(2.5)WB 21 Sn( Mapping for Built-in Data Types)115 1 TN()EA()BN}if +3 NH le{116(3.5.1\240\240)3 C(2.5.1)WB 23 Sn( Inher)HY(i)HY(tance)YH( from Built-in Data Types)116 1 TN()EA()BN}if +3 NH le{117(3.5.2\240\240)3 C(2.5.2)WB 24 Sn( Mapping for )SM(anyType)ES()117 1 TN()EA()BN}if +3 NH le{118(3.5.3\240\240)3 C(2.5.3)WB 25 Sn( Mapping for )SM(anySim)HY(ple)HY(Type)YH()ES()118 1 TN()EA()BN}if +3 NH le{119(3.5.4\240\240)3 C(2.5.4)WB 26 Sn( Mapping for )SM(QName)ES()119 1 TN()EA()BN}if +3 NH le{120(3.5.5\240\240)3 C(2.5.5)WB 27 Sn( Mapping for )SM(IDREF)ES()120 1 TN()EA()BN}if +3 NH le{121(3.5.6\240\240)3 C(2.5.6)WB 28 Sn( Mapping for )SM(base64Binary)ES( and + )SM(hexBi)HY(nary)YH()ES()121 1 TN()EA()BN}if +2 NH le{122(3.6\240\240)2 C(2.5.7)WB 29 Sn( Time Zone Repre)HY(sen)HY(ta)HY(tion)YH()122 1 TN()EA()BN}if +2 NH le{123(3.7\240\240)2 C(2.5.8)WB 30 Sn( Mapping for )SM(date)ES()123 1 TN()EA()BN}if +2 NH le{124(3.8\240\240)2 C(2.5.9)WB 31 Sn( Mapping for )SM(date)HY(Time)YH()ES()124 1 TN()EA()BN}if +2 NH le{125(3.9\240\240)2 C(2.5.10)WB 32 Sn( Mapping for )SM(dura)HY(tion)YH()ES()125 1 TN()EA()BN}if +2 NH le{126(3.10\240\240)2 C(2.5.11)WB 33 Sn( Mapping for )SM(gDay)ES()126 1 TN()EA()BN}if +2 NH le{127(3.11\240\240)2 C(2.5.12)WB 34 Sn( Mapping for )SM(gMonth)ES()127 1 TN()EA()BN}if +2 NH le{128(3.12\240\240)2 C(2.5.13)WB 35 Sn( Mapping for )SM(gMon)HY(th)HY(Day)YH()ES()128 1 TN()EA()BN}if +2 NH le{129(3.13\240\240)2 C(2.5.14)WB 36 Sn( Mapping for )SM(gYear)ES()129 1 TN()EA()BN}if +2 NH le{130(3.14\240\240)2 C(2.5.15)WB 37 Sn( Mapping for )SM(gYear)HY(Month)YH()ES()130 1 TN()EA()BN}if +2 NH le{131(3.15\240\240)2 C(2.5.16)WB 38 Sn( Mapping for )SM(time)ES()131 1 TN()EA()BN}if +2 NH le{132(3.16\240\240)2 C(2.6)WB 39 Sn( Mapping for Simple Types)132 1 TN()EA()BN}if +3 NH le{133(3.16.1\240\240)3 C(2.6.1)WB 40 Sn( Mapping for Deriva)HY(tion)YH( by Restric)HY(tion)YH()133 1 TN()EA()BN}if +3 NH le{134(3.16.2\240\240)3 C(2.6.2)WB 41 Sn( Mapping for Enumer)HY(a)HY(tions)YH()134 1 TN()EA()BN}if +3 NH le{135(3.16.3\240\240)3 C(2.6.3)WB 42 Sn( Mapping for Deriva)HY(tion)YH( by List)135 1 TN()EA()BN}if +3 NH le{136(3.16.4\240\240)3 C(2.6.4)WB 43 Sn( Mapping for Deriva)HY(tion)YH( by Union)136 1 TN()EA()BN}if +2 NH le{137(3.17\240\240)2 C(2.7)WB 44 Sn( Mapping for Complex Types)137 1 TN()EA()BN}if +3 NH le{138(3.17.1\240\240)3 C(2.7.1)WB 45 Sn( Mapping for Deriva)HY(tion)YH( by Exten)HY(sion)YH()138 1 TN()EA()BN}if +3 NH le{139(3.17.2\240\240)3 C(2.7.2)WB 46 Sn( Mapping for Deriva)HY(tion)YH( by Restric)HY(tion)YH()139 1 TN()EA()BN}if +2 NH le{140(3.18\240\240)2 C(2.8)WB 47 Sn( Mapping for Local Elements and Attributes)140 1 TN()EA()BN}if +3 NH le{141(3.18.1\240\240)3 C(2.8.1)WB 48 Sn( Mapping for Members with the One Cardi)HY(nal)HY(ity)YH( Class)141 1 TN()EA()BN}if +3 NH le{142(3.18.2\240\240)3 C(2.8.2)WB 49 Sn( Mapping for Members with the Optional Cardi)HY(nal)HY(ity)YH( Class)142 1 TN()EA()BN}if +3 NH le{143(3.18.3\240\240)3 C(2.8.3)WB 50 Sn( Mapping for Members with the Sequence Cardi)HY(nal)HY(ity)YH( Class)143 1 TN()EA()BN}if +3 NH le{144(3.18.4\240\240)3 C(2.8.4)WB 51 Sn( Element Order)144 1 TN()EA()BN}if +2 NH le{145(3.19\240\240)2 C(2.9)WB 52 Sn( Mapping for Global Elements)145 1 TN()EA()BN}if +3 NH le{146(3.19.1\240\240)3 C(2.9.1)WB 53 Sn( Element Types)146 1 TN()EA()BN}if +3 NH le{147(3.19.2\240\240)3 C(2.9.2)WB 54 Sn( Element Map)147 1 TN()EA()BN}if +2 NH le{148(3.20\240\240)2 C(2.10)WB 55 Sn( Mapping for Global Attributes)148 1 TN()EA()BN}if +2 NH le{149(3.21\240\240)2 C(2.11)WB 56 Sn( Mapping for )SM(xsi:type)ES( and Substi)HY(tu)HY(tion)YH( + Groups)149 1 TN()EA()BN}if +2 NH le{150(3.22\240\240)2 C(2.12)WB 57 Sn( Mapping for )SM(any)ES( and )SM(anyAt)HY(tribute)YH()ES()150 1 TN()EA()BN}if +3 NH le{151(3.22.1\240\240)3 C(2.12.1)WB 58 Sn( Mapping for )SM(any)ES( with the One Cardi)HY(nal)HY(ity)YH( Class)151 1 TN()EA()BN}if +3 NH le{152(3.22.2\240\240)3 C(2.12.2)WB 59 Sn( Mapping for )SM(any)ES( with the Optional Cardi)HY(nal)HY(ity)YH( Class)152 1 TN()EA()BN}if +3 NH le{153(3.22.3\240\240)3 C(2.12.3)WB 60 Sn( Mapping for )SM(any)ES( with the Sequence Cardi)HY(nal)HY(ity)YH( Class)153 1 TN()EA()BN}if +3 NH le{154(3.22.4\240\240)3 C(2.12.4)WB 61 Sn( Element Wild)HY(card)YH( Order)154 1 TN()EA()BN}if +3 NH le{155(3.22.5\240\240)3 C(2.12.5)WB 62 Sn( Mapping for )SM(anyAt)HY(tribute)YH()ES()155 1 TN()EA()BN}if +2 NH le{156(3.23\240\240)2 C(2.13)WB 63 Sn( Mapping for Mixed Content Models)156 1 TN()EA()BN}if +1 NH le{157(4\240\240)1 C(3)WB 64 Sn( Parsing)157 1 TN()EA()BN}if +2 NH le{158(4.1\240\240)2 C(3.1)WB 65 Sn( Initial)HY(iz)HY(ing)YH( the Xerces-C++ Runtime)158 1 TN()EA()BN}if +2 NH le{159(4.2\240\240)2 C(3.2)WB 66 Sn( Flags and Prop)HY(er)HY(ties)YH()159 1 TN()EA()BN}if +2 NH le{160(4.3\240\240)2 C(3.3)WB 67 Sn( Error Handling)160 1 TN()EA()BN}if +3 NH le{161(4.3.1\240\240)3 C(3.3.1)WB 68 Sn( )SM(xml_schema::parsing)ES()161 1 TN()EA()BN}if +3 NH le{162(4.3.2\240\240)3 C(3.3.2)WB 69 Sn( )SM(xml_schema::expected_element)ES()162 1 TN()EA()BN}if +3 NH le{163(4.3.3\240\240)3 C(3.3.3)WB 70 Sn( )SM(xml_schema::unex)HY(pected)YH(_element)ES()163 1 TN()EA()BN}if +3 NH le{164(4.3.4\240\240)3 C(3.3.4)WB 71 Sn( )SM(xml_schema::expected_attribute)ES()164 1 TN()EA()BN}if +3 NH le{165(4.3.5\240\240)3 C(3.3.5)WB 72 Sn( )SM(xml_schema::unex)HY(pected)YH(_enumer)HY(a)HY(tor)YH()ES()165 1 TN()EA()BN}if +3 NH le{166(4.3.6\240\240)3 C(3.3.6)WB 73 Sn( )SM(xml_schema::expected_text_content)ES()166 1 TN()EA()BN}if +3 NH le{167(4.3.7\240\240)3 C(3.3.7)WB 74 Sn( )SM(xml_schema::no_type_info)ES()167 1 TN()EA()BN}if +3 NH le{168(4.3.8\240\240)3 C(3.3.8)WB 75 Sn( )SM(xml_schema::not_derived)ES()168 1 TN()EA()BN}if +3 NH le{169(4.3.9\240\240)3 C(3.3.9)WB 76 Sn( )SM(xml_schema::no_prefix_mapping)ES()169 1 TN()EA()BN}if +2 NH le{170(4.4\240\240)2 C(3.4)WB 77 Sn( Reading from a Local File or URI)170 1 TN()EA()BN}if +2 NH le{171(4.5\240\240)2 C(3.5)WB 78 Sn( Reading from )SM(std::istream)ES()171 1 TN()EA()BN}if +2 NH le{172(4.6\240\240)2 C(3.6)WB 79 Sn( Reading from )SM(xercesc::Input)HY(Source)YH()ES()172 1 TN()EA()BN}if +2 NH le{173(4.7\240\240)2 C(3.7)WB 80 Sn( Reading from DOM)173 1 TN()EA()BN}if +1 NH le{174(5\240\240)1 C(4)WB 81 Sn( Seri)HY(al)HY(iza)HY(tion)YH()174 1 TN()EA()BN}if +2 NH le{175(5.1\240\240)2 C(4.1)WB 82 Sn( Initial)HY(iz)HY(ing)YH( the Xerces-C++ Runtime)175 1 TN()EA()BN}if +2 NH le{176(5.2\240\240)2 C(4.2)WB 83 Sn( Names)HY(pace)YH( Infomap and Char)HY(ac)HY(ter)YH( Encod)HY(ing)YH()176 1 TN()EA()BN}if +2 NH le{177(5.3\240\240)2 C(4.3)WB 84 Sn( Flags)177 1 TN()EA()BN}if +2 NH le{178(5.4\240\240)2 C(4.4)WB 85 Sn( Error Handling)178 1 TN()EA()BN}if +3 NH le{179(5.4.1\240\240)3 C(4.4.1)WB 86 Sn( )SM(xml_schema::seri)HY(al)HY(iza)HY(tion)YH()ES()179 1 TN()EA()BN}if +3 NH le{180(5.4.2\240\240)3 C(4.4.2)WB 87 Sn( )SM(xml_schema::unex)HY(pected)YH(_element)ES()180 1 TN()EA()BN}if +3 NH le{181(5.4.3\240\240)3 C(4.4.3)WB 88 Sn( )SM(xml_schema::no_type_info)ES()181 1 TN()EA()BN}if +2 NH le{182(5.5\240\240)2 C(4.5)WB 89 Sn( Seri)HY(al)HY(iz)HY(ing)YH( to )SM(std::ostream)ES()182 1 TN()EA()BN}if +2 NH le{183(5.6\240\240)2 C(4.6)WB 90 Sn( Seri)HY(al)HY(iz)HY(ing)YH( to )SM(xercesc::XMLFor)HY(mat)HY(Tar)HY(get)YH()ES()183 1 TN()EA()BN}if +2 NH le{184(5.7\240\240)2 C(4.7)WB 91 Sn( Seri)HY(al)HY(iz)HY(ing)YH( to DOM)184 1 TN()EA()BN}if +1 NH le{185(6\240\240)1 C(5)WB 92 Sn( Addi)HY(tional)YH( Func)HY(tion)HY(al)HY(ity)YH()185 1 TN()EA()BN}if +2 NH le{186(6.1\240\240)2 C(5.1)WB 93 Sn( DOM Asso)HY(ci)HY(a)HY(tion)YH()186 1 TN()EA()BN}if +2 NH le{187(6.2\240\240)2 C(5.2)WB 94 Sn( Binary Seri)HY(al)HY(iza)HY(tion)YH()187 1 TN()EA()BN}if +1 NH le{188(7\240\240)1 C(Appendix)WB 95 Sn( A \236 Default and Fixed Values)188 1 TN()EA()BN}if +/OU t D /Cb Db D NP Ep ET +/Cb Db D /Ct [16#00 16#00 16#00] D /Cl [16#00 16#00 16#00] D /CL -1 D Ct Sc + +/Ba f D /BO 0 D Bs +/UR (/home/boris/work/xsd/xsd/doc/cxx/tree/manual/index.xhtml) D +/Ti (C++/Tree Mapping User Manual) D +/Au () D +/Df f D +/ME [(4.0.0)] D + +NP RC ZF +()1 Sl()WB 0 Sn( + +)BR()WB 1 Sn( )BR()WB 2 Sn( + + + )0 1 0 H(Preface)WB 97 Sn()WB 3 Sn()EA()EH( + + )0 2 1 H(About)WB 98 Sn()WB 4 Sn( This Docu)HY(ment)YH()EA()EH( + + )0 P(This docu)HY(ment)YH( describes the mapping of W3C XML Schema + to the C++ program)HY(ming)YH( language as imple)HY(mented)YH( by + )R1 2 A(CodeSyn)HY(the)HY(sis)YH( + XSD)EA( - an XML Schema to C++ data binding compiler. The mapping + repre)HY(sents)YH( infor)HY(ma)HY(tion)YH( stored in XML instance docu)HY(ments)YH( as a + stat)HY(i)HY(cally)YH(-typed, tree-like in-memory data struc)HY(ture)YH( and is + called C++/Tree. + )EP( + + )0 P(Revi)HY(sion)YH( 4.0.0)BR( + This revi)HY(sion)YH( of the manual describes the C++/Tree + mapping as imple)HY(mented)YH( by CodeSyn)HY(the)HY(sis)YH( XSD version 4.0.0. + )EP( + + )0 P(This docu)HY(ment)YH( is avail)HY(able)YH( in the follow)HY(ing)YH( formats: + )R2 2 A(XHTML)EA(, + )R3 2 A(PDF)EA(, and + )R4 2 A(PostScript)EA(.)EP( + + )0 2 2 H(More)WB 99 Sn()WB 5 Sn( Infor)HY(ma)HY(tion)YH()EA()EH( + + )0 P(Beyond this manual, you may also find the follow)HY(ing)YH( sources of + infor)HY(ma)HY(tion)YH( useful:)EP( + + )UL( )-1 LI()R5 2 A(C++/Tree + Mapping Getting Started Guide)EA( + + )-1 LI()R6 2 A(C++/Tree + Mapping Customiza)HY(tion)YH( Guide)EA( + + )-1 LI()R7 2 A(C++/Tree + Mapping Frequently Asked Ques)HY(tions)YH( \201FAQ\202)EA( + + )-1 LI()R8 2 A(XSD + Compiler Command Line Manual)EA( + + )-1 LI(The )SM(exam)HY(ples)YH(/cxx/tree/)ES( direc)HY(tory)YH( in the XSD + distri)HY(bu)HY(tion)YH( contains a collec)HY(tion)YH( of exam)HY(ples)YH( and a README + file with an overview of each example. + + )-1 LI(The )SM(README)ES( file in the XSD distri)HY(bu)HY(tion)YH( explains + how to compile the exam)HY(ples)YH( on various plat)HY(forms)YH(. + + )-1 LI(The )R9 2 A(xsd-users)EA( + mailing list is a place to ask ques)HY(tions)YH(. Further)HY(more)YH( the + )R10 2 A(archives)EA( + may already have answers to some of your ques)HY(tions)YH(. + )LU( + + + )0 1 3 H(1)WB 100 Sn()WB 6 Sn( Intro)HY(duc)HY(tion)YH()EA()EH( + + )0 P(C++/Tree is a W3C XML Schema to C++ mapping that repre)HY(sents)YH( the + data stored in XML as a stat)HY(i)HY(cally)YH(-typed, vocab)HY(u)HY(lary)YH(-specific + object model. Based on a formal descrip)HY(tion)YH( of an XML vocab)HY(u)HY(lary)YH( + \201schema\202, the C++/Tree mapping produces a tree-like data struc)HY(ture)YH( + suit)HY(able)YH( for in-memory process)HY(ing)YH( as well as XML parsing and + seri)HY(al)HY(iza)HY(tion)YH( code.)EP( + + )0 P(A typical appli)HY(ca)HY(tion)YH( that processes XML docu)HY(ments)YH( usually + performs the follow)HY(ing)YH( three steps: it first reads \201parses\202 an XML + instance docu)HY(ment)YH( to an object model, it then performs + some useful compu)HY(ta)HY(tions)YH( on that model which may involve + modi)HY(fi)HY(ca)HY(tion)YH( of the model, and finally it may write \201seri)HY(al)HY(ize)YH(\202 + the modi)HY(fied)YH( object model back to XML. + )EP( + + )0 P(The C++/Tree mapping consists of C++ types that repre)HY(sent)YH( the + given vocab)HY(u)HY(lary)YH( \201)0 7 1 A(Chapter 2, "C++/Tree Mapping")7 0 TN TL()Ec /AF f D(\202, + a set of parsing func)HY(tions)YH( that convert XML docu)HY(ments)YH( to + a tree-like in-memory data struc)HY(ture)YH( \201)0 64 1 A(Chapter 3, + "Parsing")64 0 TN TL()Ec /AF f D(\202, and a set of seri)HY(al)HY(iza)HY(tion)YH( func)HY(tions)YH( that convert + the object model back to XML \201)0 81 1 A(Chapter 4, + "Seri)HY(al)HY(iza)HY(tion)YH(")81 0 TN TL()Ec /AF f D(\202. Further)HY(more)YH(, the mapping provides a number + of addi)HY(tional)YH( features, such as DOM asso)HY(ci)HY(a)HY(tion)YH( and binary + seri)HY(al)HY(iza)HY(tion)YH(, that can be useful in some appli)HY(ca)HY(tions)YH( + \201)0 92 1 A(Chapter 5, "Addi)HY(tional)YH( Func)HY(tion)HY(al)HY(ity)YH(")92 0 TN TL()Ec /AF f D(\202. + )EP( + + + + + + )0 1 4 H(2)WB 101 Sn()WB 7 Sn( C++/Tree Mapping)EA()EH( + + )0 2 5 H(2.1)WB 102 Sn()WB 8 Sn( Prelim)HY(i)HY(nary)YH( Infor)HY(ma)HY(tion)YH()EA()EH( + + )0 3 6 H(2.1.1)WB 103 Sn()WB 9 Sn( C++ Stan)HY(dard)YH()EA()EH( + + )0 P(The C++/Tree mapping provides support for ISO/IEC C++ 1998/2003 \201C++98\202 + and ISO/IEC C++ 2011 \201C++11\202. To select the C++ stan)HY(dard)YH( for the + gener)HY(ated)YH( code we use the )SM(--std)ES( XSD compiler command + line option. While the major)HY(ity)YH( of the exam)HY(ples)YH( in this manual use + C++98, support for the new func)HY(tion)HY(al)HY(ity)YH( and library compo)HY(nents)YH( + intro)HY(duced)YH( in C++11 are discussed through)HY(out)YH( the docu)HY(ment)YH(.)EP( + + )0 3 7 H(2.1.2)WB 104 Sn()WB 10 Sn( Iden)HY(ti)HY(fiers)YH()EA()EH( + + )0 P(XML Schema names may happen to be reserved C++ keywords or contain + char)HY(ac)HY(ters)YH( that are illegal in C++ iden)HY(ti)HY(fiers)YH(. To avoid C++ compi)HY(la)HY(tion)YH( + prob)HY(lems)YH(, such names are changed \201escaped\202 when mapped to C++. If an + XML Schema name is a C++ keyword, the "_" suffix is added to it. All + char)HY(ac)HY(ter)YH( of an XML Schema name that are not allowed in C++ iden)HY(ti)HY(fiers)YH( + are replaced with "_". + )EP( + + )0 P(For example, XML Schema name )SM(try)ES( will be mapped to + C++ iden)HY(ti)HY(fier)YH( )SM(try_)ES(. Simi)HY(larly)YH(, XML Schema name + )SM(strange.na-me)ES( will be mapped to C++ iden)HY(ti)HY(fier)YH( + )SM(strange_na_me)ES(. + )EP( + + )0 P(Further)HY(more)YH(, conflicts between type names and func)HY(tion)YH( names in the + same scope are resolved using name escap)HY(ing)YH(. Such conflicts include + both a global element \201which is mapped to a set of parsing and/or + seri)HY(al)HY(iza)HY(tion)YH( func)HY(tions)YH( or element types, see )0 52 1 A(Section + 2.9, "Mapping for Global Elements")52 0 TN TL()Ec /AF f D(\202 and a global type sharing the + same name as well as a local element or attribute inside a type having + the same name as the type itself.)EP( + + )0 P(For example, if we had a global type )SM(catalog)ES( + and a global element with the same name then the type would be + mapped to a C++ class with name )SM(catalog)ES( while the + parsing func)HY(tions)YH( corre)HY(spond)HY(ing)YH( to the global element would have + their names escaped as )SM(catalog_)ES(. + )EP( + + )0 P(By default the mapping uses the so-called K&R \201Kernighan and + Ritchie\202 iden)HY(ti)HY(fier)YH( naming conven)HY(tion)YH( which is also used through)HY(out)YH( + this manual. In this conven)HY(tion)YH( both type and func)HY(tion)YH( names are in + lower case and words are sepa)HY(rated)YH( by under)HY(scores)YH(. If your appli)HY(ca)HY(tion)YH( + code or schemas use a differ)HY(ent)YH( nota)HY(tion)YH(, you may want to change the + naming conven)HY(tion)YH( used by the mapping for consis)HY(tency)YH(. + The compiler supports a set of widely-used naming conven)HY(tions)YH( + that you can select with the )SM(--type-naming)ES( and + )SM(--func)HY(tion)YH(-naming)ES( options. You can also further + refine one of the prede)HY(fined)YH( conven)HY(tions)YH( or create a completely + custom naming scheme by using the )SM(--*-regex)ES( options. + For more detailed infor)HY(ma)HY(tion)YH( on these options refer to the NAMING + CONVEN)HY(TION)YH( section in the )R8 2 A(XSD + Compiler Command Line Manual)EA(.)EP( + + )0 3 8 H(2.1.3)WB 105 Sn()WB 11 Sn( Char)HY(ac)HY(ter)YH( Type and Encod)HY(ing)YH()EA()EH( + + )0 P(The code that imple)HY(ments)YH( the mapping, depend)HY(ing)YH( on the + )SM(--char-type)ES( option, is gener)HY(ated)YH( using either + )SM(char)ES( or )SM(wchar_t)ES( as the char)HY(ac)HY(ter)YH( + type. In this docu)HY(ment)YH( code samples use symbol )SM(C)ES( + to refer to the char)HY(ac)HY(ter)YH( type you have selected when trans)HY(lat)HY(ing)YH( + your schemas, for example )SM(std::basic_string<C>)ES(. + )EP( + + )0 P(Another aspect of the mapping that depends on the char)HY(ac)HY(ter)YH( type + is char)HY(ac)HY(ter)YH( encod)HY(ing)YH(. For the )SM(char)ES( char)HY(ac)HY(ter)YH( type + the default encod)HY(ing)YH( is UTF-8. Other supported encod)HY(ings)YH( are + ISO-8859-1, Xerces-C++ Local Code Page \201LPC\202, as well as + custom encod)HY(ings)YH( and can be selected with the + )SM(--char-encod)HY(ing)YH()ES( command line option.)EP( + + )0 P(For the )SM(wchar_t)ES( char)HY(ac)HY(ter)YH( type the encod)HY(ing)YH( is + auto)HY(mat)HY(i)HY(cally)YH( selected between UTF-16 and UTF-32/UCS-4 depend)HY(ing)YH( + on the size of the )SM(wchar_t)ES( type. On some plat)HY(forms)YH( + \201for example, Windows with Visual C++ and AIX with IBM XL C++\202 + )SM(wchar_t)ES( is 2 bytes long. For these plat)HY(forms)YH( the + encod)HY(ing)YH( is UTF-16. On other plat)HY(forms)YH( )SM(wchar_t)ES( is 4 bytes + long and UTF-32/UCS-4 is used.)EP( + + )0 3 9 H(2.1.4)WB 106 Sn()WB 12 Sn( XML Schema Names)HY(pace)YH()EA()EH( + + )0 P(The mapping relies on some prede)HY(fined)YH( types, classes, and func)HY(tions)YH( + that are logi)HY(cally)YH( defined in the XML Schema names)HY(pace)YH( reserved for + the XML Schema language \201)SM(http://www.w3.org/2001/XMLSchema)ES(\202. + By default, this names)HY(pace)YH( is mapped to C++ names)HY(pace)YH( + )SM(xml_schema)ES(. It is auto)HY(mat)HY(i)HY(cally)YH( acces)HY(si)HY(ble)YH( + from a C++ compi)HY(la)HY(tion)YH( unit that includes a header file gener)HY(ated)YH( + from an XML Schema defi)HY(ni)HY(tion)YH(. + )EP( + + )0 P(Note that, if desired, the default mapping of this names)HY(pace)YH( can be + changed as described in )0 20 1 A(Section 2.4, "Mapping for + Names)HY(paces)YH(")20 0 TN TL()Ec /AF f D(. + )EP( + + + )0 3 10 H(2.1.5)WB 107 Sn()WB 13 Sn( Anony)HY(mous)YH( Types)EA()EH( + + )0 P(For the purpose of code gener)HY(a)HY(tion)YH(, anony)HY(mous)YH( types defined in + XML Schema are auto)HY(mat)HY(i)HY(cally)YH( assigned names that are derived + from enclos)HY(ing)YH( attributes and elements. Other)HY(wise)YH(, such types + follows stan)HY(dard)YH( mapping rules for simple and complex type + defi)HY(ni)HY(tions)YH( \201see )0 39 1 A(Section 2.6, "Mapping for Simple Types")39 0 TN TL()Ec /AF f D( + and )0 44 1 A(Section 2.7, "Mapping for Complex Types")44 0 TN TL()Ec /AF f D(\202. + For example, in the follow)HY(ing)YH( schema frag)HY(ment)YH(: + )EP( + + ) 5 23 PR(<element name="object"> + <complexType> + ... + </complexType> +</element>)RP( + + )0 P(The anony)HY(mous)YH( type defined inside element )SM(object)ES( will + be given name )SM(object)ES(. The compiler has a number of + options that control the process of anony)HY(mous)YH( type naming. For more + infor)HY(ma)HY(tion)YH( refer to the )R8 2 A(XSD + Compiler Command Line Manual)EA(.)EP( + + + )0 2 11 H(2.2)WB 108 Sn()WB 14 Sn( Error Handling)EA()EH( + + )0 P(The mapping uses the C++ excep)HY(tion)YH( handling mech)HY(a)HY(nism)YH( as a primary way + of report)HY(ing)YH( error condi)HY(tions)YH(. All excep)HY(tions)YH( that are spec)HY(i)HY(fied)YH( in + this mapping derive from )SM(xml_schema::excep)HY(tion)YH()ES( which + itself is derived from )SM(std::excep)HY(tion)YH()ES(: + )EP( + + ) 14 60 PR(struct exception: virtual std::exception +{ + friend + std::basic_ostream<C>& + operator<< \201std::basic_ostream<C>& os, const exception& e\202 + { + e.print \201os\202; + return os; + } + +protected: + virtual void + print \201std::basic_ostream<C>&\202 const = 0; +};)RP( + + )0 P(The excep)HY(tion)YH( hier)HY(ar)HY(chy)YH( supports "virtual" )SM(oper)HY(a)HY(tor)YH(<<)ES( + which allows you to obtain diag)HY(nos)HY(tics)YH( corre)HY(spond)HY(ing)YH( to the thrown + excep)HY(tion)YH( using the base excep)HY(tion)YH( inter)HY(face)YH(. For example:)EP( + + ) 8 38 PR(try +{ + ... +} +catch \201const xml_schema::exception& e\202 +{ + cerr << e << endl; +})RP( + + )0 P(The follow)HY(ing)YH( sub-sections describe excep)HY(tions)YH( thrown by the + types that consti)HY(tute)YH( the object model. + )0 67 1 A(Section 3.3, "Error Handling")67 0 TN TL()Ec /AF f D( of + )0 64 1 A(Chapter 3, "Parsing")64 0 TN TL()Ec /AF f D( describes excep)HY(tions)YH( + and error handling mech)HY(a)HY(nisms)YH( specific to the parsing func)HY(tions)YH(. + )0 85 1 A(Section 4.4, "Error Handling")85 0 TN TL()Ec /AF f D( of + )0 81 1 A(Chapter 4, "Seri)HY(al)HY(iza)HY(tion)YH(")81 0 TN TL()Ec /AF f D( describes excep)HY(tions)YH( + and error handling mech)HY(a)HY(nisms)YH( specific to the seri)HY(al)HY(iza)HY(tion)YH( func)HY(tions)YH(. + )EP( + + + )0 3 12 H(2.2.1)WB 109 Sn()WB 15 Sn( )SM(xml_schema::dupli)HY(cate)YH(_id)ES()EA()EH( + + ) 10 48 PR(struct duplicate_id: virtual exception +{ + duplicate_id \201const std::basic_string<C>& id\202; + + const std::basic_string<C>& + id \201\202 const; + + virtual const char* + what \201\202 const throw \201\202; +};)RP( + + )0 P(The )SM(xml_schema::dupli)HY(cate)YH(_id)ES( is thrown when + a conflict)HY(ing)YH( instance of )SM(xml_schema::id)ES( \201see + )0 21 1 A(Section 2.5, "Mapping for Built-in Data Types")21 0 TN TL()Ec /AF f D(\202 + is added to a tree. The offend)HY(ing)YH( ID value can be obtained using + the )SM(id)ES( func)HY(tion)YH(. + )EP( + + )0 2 13 H(2.3)WB 110 Sn()WB 16 Sn( Mapping for )SM(import)ES( and )SM(include)ES()EA()EH( + + )0 3 14 H(2.3.1)WB 111 Sn()WB 17 Sn( Import)EA()EH( + + )0 P(The XML Schema )SM(import)ES( element is mapped to the C++ + Prepro)HY(ces)HY(sor)YH( )SM(#include)ES( direc)HY(tive)YH(. The value of + the )SM(schemaLo)HY(ca)HY(tion)YH()ES( attribute is used to derive + the name of the header file that appears in the )SM(#include)ES( + direc)HY(tive)YH(. For instance: + )EP( + + ) 2 53 PR(<import namespace="http://www.codesynthesis.com/test" + schemaLocation="test.xsd"/>)RP( + + )0 P(is mapped to:)EP( + + ) 1 19 PR(#include "test.hxx")RP( + + )0 P(Note that you will need to compile imported schemas sepa)HY(rately)YH( + in order to produce corre)HY(spond)HY(ing)YH( header files.)EP( + + )0 3 15 H(2.3.2)WB 112 Sn()WB 18 Sn( Inclu)HY(sion)YH( with Target Names)HY(pace)YH()EA()EH( + + )0 P(The XML Schema )SM(include)ES( element which refers to a schema + with a target names)HY(pace)YH( or appears in a schema without a target names)HY(pace)YH( + follows the same mapping rules as the )SM(import)ES( element, + see )0 17 1 A(Section 2.3.1, "Import")17 0 TN TL()Ec /AF f D(. + )EP( + + )0 3 16 H(2.3.3)WB 113 Sn()WB 19 Sn( Inclu)HY(sion)YH( without Target Names)HY(pace)YH()EA()EH( + + )0 P(For the XML Schema )SM(include)ES( element which refers to a schema + without a target names)HY(pace)YH( and appears in a schema with a target + names)HY(pace)YH( \201such inclu)HY(sion)YH( some)HY(times)YH( called "chameleon inclu)HY(sion)YH("\202, + decla)HY(ra)HY(tions)YH( and defi)HY(ni)HY(tions)YH( from the included schema are gener)HY(ated)YH( + in-line in the names)HY(pace)YH( of the includ)HY(ing)YH( schema as if they were + declared and defined there verba)HY(tim)YH(. For example, consider the + follow)HY(ing)YH( two schemas: + )EP( + + ) 11 60 PR(<-- common.xsd --> +<schema> + <complexType name="type"> + ... + </complexType> +</schema> + +<-- test.xsd --> +<schema targetNamespace="http://www.codesynthesis.com/test"> + <include schemaLocation="common.xsd"/> +</schema>)RP( + + )0 P(The frag)HY(ment)YH( of inter)HY(est)YH( from the gener)HY(ated)YH( header file for + )SM(text.xsd)ES( would look like this:)EP( + + ) 8 14 PR(// test.hxx +namespace test +{ + class type + { + ... + }; +})RP( + + )0 2 17 H(2.4)WB 114 Sn()WB 20 Sn( Mapping for Names)HY(paces)YH()EA()EH( + + )0 P(An XML Schema names)HY(pace)YH( is mapped to one or more nested C++ + names)HY(paces)YH(. XML Schema names)HY(paces)YH( are iden)HY(ti)HY(fied)YH( by URIs. + By default, a names)HY(pace)YH( URI is mapped to a sequence of + C++ names)HY(pace)YH( names by remov)HY(ing)YH( the proto)HY(col)YH( and host parts + and split)HY(ting)YH( the rest into a sequence of names with ')SM(/)ES(' + as the name sepa)HY(ra)HY(tor)YH(. For instance: + )EP( + + ) 3 67 PR(<schema targetNamespace="http://www.codesynthesis.com/system/test"> + ... +</schema>)RP( + + )0 P(is mapped to:)EP( + + ) 7 16 PR(namespace system +{ + namespace test + { + ... + } +})RP( + + )0 P(The default mapping of names)HY(pace)YH( URIs to C++ names)HY(pace)YH( names can be + altered using the )SM(--names)HY(pace)YH(-map)ES( and + )SM(--names)HY(pace)YH(-regex)ES( options. See the + )R8 2 A(XSD + Compiler Command Line Manual)EA( for more infor)HY(ma)HY(tion)YH(. + )EP( + + )0 2 18 H(2.5)WB 115 Sn()WB 21 Sn( Mapping for Built-in Data Types)EA()EH( + + )0 P(The mapping of XML Schema built-in data types to C++ types is + summa)HY(rized)YH( in the table below.)EP( + + + )0 PT( + + )0 P(All XML Schema built-in types are mapped to C++ classes that are + derived from the )SM(xml_schema::simple_type)ES( class except + where the mapping is to a funda)HY(men)HY(tal)YH( C++ type.)EP( + + )0 P(The )SM(sequence)ES( class template is defined in an + imple)HY(men)HY(ta)HY(tion)YH(-specific names)HY(pace)YH(. It conforms to the + sequence inter)HY(face)YH( as defined by the ISO/ANSI Stan)HY(dard)YH( for + C++ \201ISO/IEC 14882:1998, Section 23.1.1, "Sequences"\202. + Prac)HY(ti)HY(cally)YH(, this means that you can treat such a sequence + as if it was )SM(std::vector)ES(. One notable exten)HY(sion)YH( + to the stan)HY(dard)YH( inter)HY(face)YH( that is avail)HY(able)YH( only for + sequences of non-funda)HY(men)HY(tal)YH( C++ types is the addi)HY(tion)YH( of + the over)HY(loaded)YH( )SM(push_back)ES( and )SM(insert)ES( + member func)HY(tions)YH( which instead of the constant refer)HY(ence)YH( + to the element type accept auto)HY(matic)YH( pointer \201)SM(std::auto_ptr)ES( + or )SM(std::unique_ptr)ES(, depend)HY(ing)YH( on the C++ stan)HY(dard)YH( + selected\202 to the element type. These func)HY(tions)YH( assume owner)HY(ship)YH( + of the pointed to object and reset the passed auto)HY(matic)YH( pointer. + )EP( + + )0 3 19 H(2.5.1)WB 116 Sn()WB 23 Sn( Inher)HY(i)HY(tance)YH( from Built-in Data Types)EA()EH( + + )0 P(In cases where the mapping calls for an inher)HY(i)HY(tance)YH( from a built-in + type which is mapped to a funda)HY(men)HY(tal)YH( C++ type, a proxy type is + used instead of the funda)HY(men)HY(tal)YH( C++ type \201C++ does not allow + inher)HY(i)HY(tance)YH( from funda)HY(men)HY(tal)YH( types\202. For instance:)EP( + + ) 3 27 PR(<simpleType name="my_int"> + <restriction base="int"/> +</simpleType>)RP( + + )0 P(is mapped to:)EP( + + ) 4 42 PR(class my_int: public fundamental_base<int> +{ + ... +};)RP( + + )0 P(The )SM(funda)HY(men)HY(tal)YH(_base)ES( class template provides a close + emula)HY(tion)YH( \201though not exact\202 of a funda)HY(men)HY(tal)YH( C++ type. + It is defined in an imple)HY(men)HY(ta)HY(tion)YH(-specific names)HY(pace)YH( and has the + follow)HY(ing)YH( inter)HY(face)YH(:)EP( + + ) 22 44 PR(template <typename X> +class fundamental_base: public simple_type +{ +public: + fundamental_base \201\202; + fundamental_base \201X\202 + fundamental_base \201const fundamental_base&\202 + +public: + fundamental_base& + operator= \201const X&\202; + +public: + operator const X & \201\202 const; + operator X& \201\202; + + template <typename Y> + operator Y \201\202 const; + + template <typename Y> + operator Y \201\202; +};)RP( + + )0 3 20 H(2.5.2)WB 117 Sn()WB 24 Sn( Mapping for )SM(anyType)ES()EA()EH( + + )0 P(The XML Schema )SM(anyType)ES( built-in data type is mapped to the + )SM(xml_schema::type)ES( C++ class:)EP( + + ) 53 48 PR(class type +{ +public: + virtual + ~type \201\202; + + type \201\202; + type \201const type&\202; + + type& + operator= \201const type&\202; + + virtual type* + _clone \201\202 const; + + // anyType DOM content. + // +public: + typedef element_optional dom_content_optional; + + const dom_content_optional& + dom_content \201\202 const; + + dom_content_optional& + dom_content \201\202; + + void + dom_content \201const xercesc::DOMElement&\202; + + void + dom_content \201xercesc::DOMElement*\202;)WR( + + void + dom_content \201const dom_content_optional&\202; + + const xercesc::DOMDocument& + dom_content_document \201\202 const; + + xercesc::DOMDocument& + dom_content_document \201\202; + + bool + null_content \201\202 const; + + // DOM association. + // +public: + const xercesc::DOMNode* + _node \201\202 const; + + xercesc::DOMNode* + _node \201\202; +};)RP( + + )0 P(When )SM(xml_schema::type)ES( is used to create an instance + \201as opposed to being a base of a derived type\202, it repre)HY(sents)YH( + the XML Schema )SM(anyType)ES( type. )SM(anyType)ES( + allows any attributes and any content in any order. In the + C++/Tree mapping this content can be repre)HY(sented)YH( as a DOM + frag)HY(ment)YH(, similar to XML Schema wild)HY(cards)YH( \201)0 57 1 A(Section + 2.12, "Mapping for )SM(any)ES( and + )SM(anyAt)HY(tribute)YH()ES(")57 0 TN TL()Ec /AF f D(\202.)EP( + + )0 P(To enable auto)HY(matic)YH( extrac)HY(tion)YH( of )SM(anyType)ES( content + during parsing, the )SM(--gener)HY(ate)YH(-any-type)ES( option must be + spec)HY(i)HY(fied)YH(. Because the DOM API is used to access such content, the + Xerces-C++ runtime should be initial)HY(ized)YH( by the appli)HY(ca)HY(tion)YH( prior to + parsing and should remain initial)HY(ized)YH( for the life)HY(time)YH( of objects + with the DOM content. For more infor)HY(ma)HY(tion)YH( on the Xerces-C++ runtime + initial)HY(iza)HY(tion)YH( see )0 65 1 A(Section 3.1, "Initial)HY(iz)HY(ing)YH( the + Xerces-C++ Runtime")65 0 TN TL()Ec /AF f D(.)EP( + + )0 P(The DOM content is stored as the optional DOM element container + and the DOM content acces)HY(sors)YH( and modi)HY(fiers)YH( presented above are + iden)HY(ti)HY(cal)YH( to those gener)HY(ated)YH( for an optional element wild)HY(card)YH(. + Refer to )0 59 1 A(Section 2.12.2, "Mapping for )SM(any)ES( + with the Optional Cardi)HY(nal)HY(ity)YH( Class")59 0 TN TL()Ec /AF f D( for details on their + seman)HY(tics)YH(.)EP( + + )0 P(The )SM(dom_content_docu)HY(ment)YH(\201\202)ES( func)HY(tion)YH( returns the + DOM docu)HY(ment)YH( used to store the raw XML content corre)HY(spond)HY(ing)YH( + to the )SM(anyType)ES( instance. It is equiv)HY(a)HY(lent)YH( to the + )SM(dom_docu)HY(ment)YH(\201\202)ES( func)HY(tion)YH( gener)HY(ated)YH( for types + with wild)HY(cards)YH(.)EP( + + )0 P(The )SM(null_content\201\202)ES( acces)HY(sor)YH( is an opti)HY(miza)HY(tion)YH( func)HY(tion)YH( + that allows us to check for the lack of content without actu)HY(ally)YH( + creat)HY(ing)YH( its empty repre)HY(sen)HY(ta)HY(tion)YH(, that is, empty DOM docu)HY(ment)YH( for + )SM(anyType)ES( or empty string for )SM(anySim)HY(ple)HY(Type)YH()ES( + \201see the follow)HY(ing)YH( section for details on )SM(anySim)HY(ple)HY(Type)YH()ES(\202.)EP( + + )0 P(For more infor)HY(ma)HY(tion)YH( on DOM asso)HY(ci)HY(a)HY(tion)YH( refer to + )0 93 1 A(Section 5.1, "DOM Asso)HY(ci)HY(a)HY(tion)YH(")93 0 TN TL()Ec /AF f D(.)EP( + + )0 3 21 H(2.5.3)WB 118 Sn()WB 25 Sn( Mapping for )SM(anySim)HY(ple)HY(Type)YH()ES()EA()EH( + + )0 P(The XML Schema )SM(anySim)HY(ple)HY(Type)YH()ES( built-in data type is mapped + to the )SM(xml_schema::simple_type)ES( C++ class:)EP( + + ) 27 45 PR(class simple_type: public type +{ +public: + simple_type \201\202; + simple_type \201const C*\202; + simple_type \201const std::basic_string<C>&\202; + + simple_type \201const simple_type&\202; + + simple_type& + operator= \201const simple_type&\202; + + virtual simple_type* + _clone \201\202 const; + + // anySimpleType text content. + // +public: + const std::basic_string<C>& + text_content \201\202 const; + + std::basic_string<C>& + text_content \201\202; + + void + text_content \201const std::basic_string<C>&\202; +};)RP( + + )0 P(When )SM(xml_schema::simple_type)ES( is used to create an instance + \201as opposed to being a base of a derived type\202, it repre)HY(sents)YH( + the XML Schema )SM(anySim)HY(ple)HY(Type)YH()ES( type. )SM(anySim)HY(ple)HY(Type)YH()ES( + allows any simple content. In the C++/Tree mapping this content can + be repre)HY(sented)YH( as a string and accessed or modi)HY(fied)YH( with the + )SM(text_content\201\202)ES( func)HY(tions)YH( shown above.)EP( + + )0 3 22 H(2.5.4)WB 119 Sn()WB 26 Sn( Mapping for )SM(QName)ES()EA()EH( + + )0 P(The XML Schema )SM(QName)ES( built-in data type is mapped to the + )SM(xml_schema::qname)ES( C++ class:)EP( + + ) 25 36 PR(class qname: public simple_type +{ +public: + qname \201const ncname&\202; + qname \201const uri&, const ncname&\202; + qname \201const qname&\202; + +public: + qname& + operator= \201const qname&\202; + +public: + virtual qname* + _clone \201\202 const; + +public: + bool + qualified \201\202 const; + + const uri& + namespace_ \201\202 const; + + const ncname& + name \201\202 const; +};)RP( + + )0 P(The )SM(qual)HY(i)HY(fied)YH()ES( acces)HY(sor)YH( func)HY(tion)YH( can be used to deter)HY(mine)YH( + if the name is qual)HY(i)HY(fied)YH(.)EP( + + )0 3 23 H(2.5.5)WB 120 Sn()WB 27 Sn( Mapping for )SM(IDREF)ES()EA()EH( + + )0 P(The XML Schema )SM(IDREF)ES( built-in data type is mapped to the + )SM(xml_schema::idref)ES( C++ class. This class imple)HY(ments)YH( the + smart pointer C++ idiom:)EP( + + ) 56 44 PR(class idref: public ncname +{ +public: + idref \201const C* s\202; + idref \201const C* s, std::size_t n\202; + idref \201std::size_t n, C c\202; + idref \201const std::basic_string<C>&\202; + idref \201const std::basic_string<C>&, + std::size_t pos, + std::size_t n = npos\202; + +public: + idref \201const idref&\202; + +public: + virtual idref* + _clone \201\202 const; + +public: + idref& + operator= \201C c\202; + + idref& + operator= \201const C* s\202; + + idref& + operator= \201const std::basic_string<C>&\202 + + idref& + operator= \201const idref&\202; +)WR( +public: + const type* + operator-> \201\202 const; + + type* + operator-> \201\202; + + const type& + operator* \201\202 const; + + type& + operator* \201\202; + + const type* + get \201\202 const; + + type* + get \201\202; + + // Conversion to bool. + // +public: + typedef void \201idref::*bool_convertible\202\201\202; + operator bool_convertible \201\202 const; +};)RP( + + )0 P(The object, )SM(idref)ES( instance refers to, is the imme)HY(di)HY(ate)YH( + container of the match)HY(ing)YH( )SM(id)ES( instance. For example, + with the follow)HY(ing)YH( instance docu)HY(ment)YH( and schema: + )EP( + + + ) 22 49 PR(<!-- test.xml --> +<root> + <object id="obj-1" text="hello"/> + <reference>obj-1</reference> +</root> + +<!-- test.xsd --> +<schema> + <complexType name="object_type"> + <attribute name="id" type="ID"/> + <attribute name="text" type="string"/> + </complexType> + + <complexType name="root_type"> + <sequence> + <element name="object" type="object_type"/> + <element name="reference" type="IDREF"/> + </sequence> + </complexType> + + <element name="root" type="root_type"/> +</schema>)RP( + + )0 P(The )SM(ref)ES( instance in the code below will refer to + an object of type )SM(object_type)ES(:)EP( + + ) 4 53 PR(root_type& root = ...; +xml_schema::idref& ref \201root.reference \201\202\202; +object_type& obj \201dynamic_cast<object_type&> \201*ref\202\202; +cout << obj.text \201\202 << endl;)RP( + + )0 P(The smart pointer inter)HY(face)YH( of the )SM(idref)ES( class always + returns a pointer or refer)HY(ence)YH( to )SM(xml_schema::type)ES(. + This means that you will need to manu)HY(ally)YH( cast such pointer or + refer)HY(ence)YH( to its real \201dynamic\202 type before you can use it \201unless + all you need is the base inter)HY(face)YH( provided by + )SM(xml_schema::type)ES(\202. As a special exten)HY(sion)YH( to the XML + Schema language, the mapping supports static typing of )SM(idref)ES( + refer)HY(ences)YH( by employ)HY(ing)YH( the )SM(refType)ES( exten)HY(sion)YH( attribute. + The follow)HY(ing)YH( example illus)HY(trates)YH( this mech)HY(a)HY(nism)YH(: + )EP( + + ) 11 72 PR(<!-- test.xsd --> +<schema + xmlns:xse="http://www.codesynthesis.com/xmlns/xml-schema-extension"> + + ... + + <element name="reference" type="IDREF" xse:refType="object_type"/> + + ... + +</schema>)RP( + + )0 P(With this modi)HY(fi)HY(ca)HY(tion)YH( we do not need to do manual casting anymore: + )EP( + + ) 4 51 PR(root_type& root = ...; +root_type::reference_type& ref \201root.reference \201\202\202; +object_type& obj \201*ref\202; +cout << ref->text \201\202 << endl;)RP( + + + )0 3 24 H(2.5.6)WB 121 Sn()WB 28 Sn( Mapping for )SM(base64Binary)ES( and + )SM(hexBi)HY(nary)YH()ES()EA()EH( + + )0 P(The XML Schema )SM(base64Binary)ES( and )SM(hexBi)HY(nary)YH()ES( + built-in data types are mapped to the + )SM(xml_schema::base64_binary)ES( and + )SM(xml_schema::hex_binary)ES( C++ classes, respec)HY(tively)YH(. The + )SM(base64_binary)ES( and )SM(hex_binary)ES( classes + support a simple buffer abstrac)HY(tion)YH( by inher)HY(it)HY(ing)YH( from the + )SM(xml_schema::buffer)ES( class: + )EP( + + ) 64 58 PR(class bounds: public virtual exception +{ +public: + virtual const char* + what \201\202 const throw \201\202; +}; + +class buffer +{ +public: + typedef std::size_t size_t; + +public: + buffer \201size_t size = 0\202; + buffer \201size_t size, size_t capacity\202; + buffer \201const void* data, size_t size\202; + buffer \201const void* data, size_t size, size_t capacity\202; + buffer \201void* data, + size_t size, + size_t capacity, + bool assume_ownership\202; + +public: + buffer \201const buffer&\202; + + buffer& + operator= \201const buffer&\202; + + void + swap \201buffer&\202; +)WR( +public: + size_t + capacity \201\202 const; + + bool + capacity \201size_t\202; + +public: + size_t + size \201\202 const; + + bool + size \201size_t\202; + +public: + const char* + data \201\202 const; + + char* + data \201\202; + + const char* + begin \201\202 const; + + char* + begin \201\202; + + const char* + end \201\202 const; +)WR( + char* + end \201\202; +};)RP( + + )0 P(The last over)HY(loaded)YH( construc)HY(tor)YH( reuses an exist)HY(ing)YH( data buffer instead + of making a copy. If the )SM(assume_owner)HY(ship)YH()ES( argu)HY(ment)YH( is + )SM(true)ES(, the instance assumes owner)HY(ship)YH( of the + memory block pointed to by the )SM(data)ES( argu)HY(ment)YH( and will + even)HY(tu)HY(ally)YH( release it by calling )SM(oper)HY(a)HY(tor)YH( delete)ES(. The + )SM(capac)HY(ity)YH()ES( and )SM(size)ES( modi)HY(fier)YH( func)HY(tions)YH( return + )SM(true)ES( if the under)HY(ly)HY(ing)YH( buffer has moved. + )EP( + + )0 P(The )SM(bounds)ES( excep)HY(tion)YH( is thrown if the construc)HY(tor)YH( + argu)HY(ments)YH( violate the )SM(\201size\240<=\240capac)HY(ity)YH(\202)ES( + constraint.)EP( + + )0 P(The )SM(base64_binary)ES( and )SM(hex_binary)ES( classes + support the )SM(buffer)ES( inter)HY(face)YH( and perform auto)HY(matic)YH( + decod)HY(ing)YH(/encod)HY(ing)YH( from/to the Base64 and Hex formats, respec)HY(tively)YH(: + )EP( + + ) 25 65 PR(class base64_binary: public simple_type, public buffer +{ +public: + base64_binary \201size_t size = 0\202; + base64_binary \201size_t size, size_t capacity\202; + base64_binary \201const void* data, size_t size\202; + base64_binary \201const void* data, size_t size, size_t capacity\202; + base64_binary \201void* data, + size_t size, + size_t capacity, + bool assume_ownership\202; + +public: + base64_binary \201const base64_binary&\202; + + base64_binary& + operator= \201const base64_binary&\202; + + virtual base64_binary* + _clone \201\202 const; + +public: + std::basic_string<C> + encode \201\202 const; +};)RP( + + ) 25 62 PR(class hex_binary: public simple_type, public buffer +{ +public: + hex_binary \201size_t size = 0\202; + hex_binary \201size_t size, size_t capacity\202; + hex_binary \201const void* data, size_t size\202; + hex_binary \201const void* data, size_t size, size_t capacity\202; + hex_binary \201void* data, + size_t size, + size_t capacity, + bool assume_ownership\202; + +public: + hex_binary \201const hex_binary&\202; + + hex_binary& + operator= \201const hex_binary&\202; + + virtual hex_binary* + _clone \201\202 const; + +public: + std::basic_string<C> + encode \201\202 const; +};)RP( + + + )0 2 25 H(2.5.7)WB 122 Sn()WB 29 Sn( Time Zone Repre)HY(sen)HY(ta)HY(tion)YH()EA()EH( + + )0 P(The )SM(date)ES(, )SM(date)HY(Time)YH()ES(, )SM(gDay)ES(, + )SM(gMonth)ES(, )SM(gMon)HY(th)HY(Day)YH()ES(, )SM(gYear)ES(, + )SM(gYear)HY(Month)YH()ES(, and )SM(time)ES( XML Schema built-in + types all include an optional time zone compo)HY(nent)YH(. The follow)HY(ing)YH( + )SM(xml_schema::time_zone)ES( base class is used to repre)HY(sent)YH( + this infor)HY(ma)HY(tion)YH(:)EP( + + ) 30 48 PR(class time_zone +{ +public: + time_zone \201\202; + time_zone \201short hours, short minutes\202; + + bool + zone_present \201\202 const; + + void + zone_reset \201\202; + + short + zone_hours \201\202 const; + + void + zone_hours \201short\202; + + short + zone_minutes \201\202 const; + + void + zone_minutes \201short\202; +}; + +bool +operator== \201const time_zone&, const time_zone&\202; + +bool +operator!= \201const time_zone&, const time_zone&\202;)RP( + + )0 P(The )SM(zone_present\201\202)ES( acces)HY(sor)YH( func)HY(tion)YH( returns )SM(true)ES( + if the time zone is spec)HY(i)HY(fied)YH(. The )SM(zone_reset\201\202)ES( modi)HY(fier)YH( + func)HY(tion)YH( resets the time zone object to the )EM(not spec)HY(i)HY(fied)YH()ES( + state. If the time zone offset is nega)HY(tive)YH( then both hours and + minutes compo)HY(nents)YH( are repre)HY(sented)YH( as nega)HY(tive)YH( inte)HY(gers)YH(.)EP( + + + )0 2 26 H(2.5.8)WB 123 Sn()WB 30 Sn( Mapping for )SM(date)ES()EA()EH( + + )0 P(The XML Schema )SM(date)ES( built-in data type is mapped to the + )SM(xml_schema::date)ES( C++ class which repre)HY(sents)YH( a year, a day, + and a month with an optional time zone. Its inter)HY(face)YH( is presented + below. For more infor)HY(ma)HY(tion)YH( on the base )SM(xml_schema::time_zone)ES( + class refer to )0 29 1 A(Section 2.5.7, "Time Zone + Repre)HY(sen)HY(ta)HY(tion)YH(")29 0 TN TL()Ec /AF f D(.)EP( + + ) 41 60 PR(class date: public simple_type, public time_zone +{ +public: + date \201int year, unsigned short month, unsigned short day\202; + date \201int year, unsigned short month, unsigned short day, + short zone_hours, short zone_minutes\202; + +public: + date \201const date&\202; + + date& + operator= \201const date&\202; + + virtual date* + _clone \201\202 const; + +public: + int + year \201\202 const; + + void + year \201int\202; + + unsigned short + month \201\202 const; + + void + month \201unsigned short\202; + + unsigned short + day \201\202 const;)WR( + + void + day \201unsigned short\202; +}; + +bool +operator== \201const date&, const date&\202; + +bool +operator!= \201const date&, const date&\202;)RP( + + )0 2 27 H(2.5.9)WB 124 Sn()WB 31 Sn( Mapping for )SM(date)HY(Time)YH()ES()EA()EH( + + )0 P(The XML Schema )SM(date)HY(Time)YH()ES( built-in data type is mapped to the + )SM(xml_schema::date_time)ES( C++ class which repre)HY(sents)YH( a year, a month, + a day, hours, minutes, and seconds with an optional time zone. Its inter)HY(face)YH( + is presented below. For more infor)HY(ma)HY(tion)YH( on the base + )SM(xml_schema::time_zone)ES( class refer to )0 29 1 A(Section + 2.5.7, "Time Zone Repre)HY(sen)HY(ta)HY(tion)YH(")29 0 TN TL()Ec /AF f D(.)EP( + + ) 62 67 PR(class date_time: public simple_type, public time_zone +{ +public: + date_time \201int year, unsigned short month, unsigned short day, + unsigned short hours, unsigned short minutes, + double seconds\202; + + date_time \201int year, unsigned short month, unsigned short day, + unsigned short hours, unsigned short minutes, + double seconds, short zone_hours, short zone_minutes\202; +public: + date_time \201const date_time&\202; + + date_time& + operator= \201const date_time&\202; + + virtual date_time* + _clone \201\202 const; + +public: + int + year \201\202 const; + + void + year \201int\202; + + unsigned short + month \201\202 const; + + void + month \201unsigned short\202;)WR( + + unsigned short + day \201\202 const; + + void + day \201unsigned short\202; + + unsigned short + hours \201\202 const; + + void + hours \201unsigned short\202; + + unsigned short + minutes \201\202 const; + + void + minutes \201unsigned short\202; + + double + seconds \201\202 const; + + void + seconds \201double\202; +}; + +bool +operator== \201const date_time&, const date_time&\202; + +bool)WR( +operator!= \201const date_time&, const date_time&\202;)RP( + + + )0 2 28 H(2.5.10)WB 125 Sn()WB 32 Sn( Mapping for )SM(dura)HY(tion)YH()ES()EA()EH( + + )0 P(The XML Schema )SM(dura)HY(tion)YH()ES( built-in data type is mapped to the + )SM(xml_schema::dura)HY(tion)YH()ES( C++ class which repre)HY(sents)YH( a poten)HY(tially)YH( + nega)HY(tive)YH( dura)HY(tion)YH( in the form of years, months, days, hours, minutes, + and seconds. Its inter)HY(face)YH( is presented below.)EP( + + ) 64 71 PR(class duration: public simple_type +{ +public: + duration \201bool negative, + unsigned int years, unsigned int months, unsigned int days, + unsigned int hours, unsigned int minutes, double seconds\202; +public: + duration \201const duration&\202; + + duration& + operator= \201const duration&\202; + + virtual duration* + _clone \201\202 const; + +public: + bool + negative \201\202 const; + + void + negative \201bool\202; + + unsigned int + years \201\202 const; + + void + years \201unsigned int\202; + + unsigned int + months \201\202 const; +)WR( + void + months \201unsigned int\202; + + unsigned int + days \201\202 const; + + void + days \201unsigned int\202; + + unsigned int + hours \201\202 const; + + void + hours \201unsigned int\202; + + unsigned int + minutes \201\202 const; + + void + minutes \201unsigned int\202; + + double + seconds \201\202 const; + + void + seconds \201double\202; +}; + +bool +operator== \201const duration&, const duration&\202;)WR( + +bool +operator!= \201const duration&, const duration&\202;)RP( + + + )0 2 29 H(2.5.11)WB 126 Sn()WB 33 Sn( Mapping for )SM(gDay)ES()EA()EH( + + )0 P(The XML Schema )SM(gDay)ES( built-in data type is mapped to the + )SM(xml_schema::gday)ES( C++ class which repre)HY(sents)YH( a day of the + month with an optional time zone. Its inter)HY(face)YH( is presented below. + For more infor)HY(ma)HY(tion)YH( on the base )SM(xml_schema::time_zone)ES( + class refer to )0 29 1 A(Section 2.5.7, "Time Zone + Repre)HY(sen)HY(ta)HY(tion)YH(")29 0 TN TL()Ec /AF f D(.)EP( + + ) 29 66 PR(class gday: public simple_type, public time_zone +{ +public: + explicit + gday \201unsigned short day\202; + gday \201unsigned short day, short zone_hours, short zone_minutes\202; + +public: + gday \201const gday&\202; + + gday& + operator= \201const gday&\202; + + virtual gday* + _clone \201\202 const; + +public: + unsigned short + day \201\202 const; + + void + day \201unsigned short\202; +}; + +bool +operator== \201const gday&, const gday&\202; + +bool +operator!= \201const gday&, const gday&\202;)RP( + + + )0 2 30 H(2.5.12)WB 127 Sn()WB 34 Sn( Mapping for )SM(gMonth)ES()EA()EH( + + )0 P(The XML Schema )SM(gMonth)ES( built-in data type is mapped to the + )SM(xml_schema::gmonth)ES( C++ class which repre)HY(sents)YH( a month of the + year with an optional time zone. Its inter)HY(face)YH( is presented below. + For more infor)HY(ma)HY(tion)YH( on the base )SM(xml_schema::time_zone)ES( + class refer to )0 29 1 A(Section 2.5.7, "Time Zone + Repre)HY(sen)HY(ta)HY(tion)YH(")29 0 TN TL()Ec /AF f D(.)EP( + + ) 30 50 PR(class gmonth: public simple_type, public time_zone +{ +public: + explicit + gmonth \201unsigned short month\202; + gmonth \201unsigned short month, + short zone_hours, short zone_minutes\202; + +public: + gmonth \201const gmonth&\202; + + gmonth& + operator= \201const gmonth&\202; + + virtual gmonth* + _clone \201\202 const; + +public: + unsigned short + month \201\202 const; + + void + month \201unsigned short\202; +}; + +bool +operator== \201const gmonth&, const gmonth&\202; + +bool +operator!= \201const gmonth&, const gmonth&\202;)RP( + + + )0 2 31 H(2.5.13)WB 128 Sn()WB 35 Sn( Mapping for )SM(gMon)HY(th)HY(Day)YH()ES()EA()EH( + + )0 P(The XML Schema )SM(gMon)HY(th)HY(Day)YH()ES( built-in data type is mapped to the + )SM(xml_schema::gmonth_day)ES( C++ class which repre)HY(sents)YH( a day and + a month of the year with an optional time zone. Its inter)HY(face)YH( is presented + below. For more infor)HY(ma)HY(tion)YH( on the base )SM(xml_schema::time_zone)ES( + class refer to )0 29 1 A(Section 2.5.7, "Time Zone + Repre)HY(sen)HY(ta)HY(tion)YH(")29 0 TN TL()Ec /AF f D(.)EP( + + ) 35 56 PR(class gmonth_day: public simple_type, public time_zone +{ +public: + gmonth_day \201unsigned short month, unsigned short day\202; + gmonth_day \201unsigned short month, unsigned short day, + short zone_hours, short zone_minutes\202; + +public: + gmonth_day \201const gmonth_day&\202; + + gmonth_day& + operator= \201const gmonth_day&\202; + + virtual gmonth_day* + _clone \201\202 const; + +public: + unsigned short + month \201\202 const; + + void + month \201unsigned short\202; + + unsigned short + day \201\202 const; + + void + day \201unsigned short\202; +}; + +bool)WR( +operator== \201const gmonth_day&, const gmonth_day&\202; + +bool +operator!= \201const gmonth_day&, const gmonth_day&\202;)RP( + + + )0 2 32 H(2.5.14)WB 129 Sn()WB 36 Sn( Mapping for )SM(gYear)ES()EA()EH( + + )0 P(The XML Schema )SM(gYear)ES( built-in data type is mapped to the + )SM(xml_schema::gyear)ES( C++ class which repre)HY(sents)YH( a year with + an optional time zone. Its inter)HY(face)YH( is presented below. For more + infor)HY(ma)HY(tion)YH( on the base )SM(xml_schema::time_zone)ES( class refer + to )0 29 1 A(Section 2.5.7, "Time Zone Repre)HY(sen)HY(ta)HY(tion)YH(")29 0 TN TL()Ec /AF f D(.)EP( + + ) 29 57 PR(class gyear: public simple_type, public time_zone +{ +public: + explicit + gyear \201int year\202; + gyear \201int year, short zone_hours, short zone_minutes\202; + +public: + gyear \201const gyear&\202; + + gyear& + operator= \201const gyear&\202; + + virtual gyear* + _clone \201\202 const; + +public: + int + year \201\202 const; + + void + year \201int\202; +}; + +bool +operator== \201const gyear&, const gyear&\202; + +bool +operator!= \201const gyear&, const gyear&\202;)RP( + + + )0 2 33 H(2.5.15)WB 130 Sn()WB 37 Sn( Mapping for )SM(gYear)HY(Month)YH()ES()EA()EH( + + )0 P(The XML Schema )SM(gYear)HY(Month)YH()ES( built-in data type is mapped to + the )SM(xml_schema::gyear_month)ES( C++ class which repre)HY(sents)YH( + a year and a month with an optional time zone. Its inter)HY(face)YH( is presented + below. For more infor)HY(ma)HY(tion)YH( on the base )SM(xml_schema::time_zone)ES( + class refer to )0 29 1 A(Section 2.5.7, "Time Zone + Repre)HY(sen)HY(ta)HY(tion)YH(")29 0 TN TL()Ec /AF f D(.)EP( + + ) 34 55 PR(class gyear_month: public simple_type, public time_zone +{ +public: + gyear_month \201int year, unsigned short month\202; + gyear_month \201int year, unsigned short month, + short zone_hours, short zone_minutes\202; +public: + gyear_month \201const gyear_month&\202; + + gyear_month& + operator= \201const gyear_month&\202; + + virtual gyear_month* + _clone \201\202 const; + +public: + int + year \201\202 const; + + void + year \201int\202; + + unsigned short + month \201\202 const; + + void + month \201unsigned short\202; +}; + +bool +operator== \201const gyear_month&, const gyear_month&\202;)WR( + +bool +operator!= \201const gyear_month&, const gyear_month&\202;)RP( + + + )0 2 34 H(2.5.16)WB 131 Sn()WB 38 Sn( Mapping for )SM(time)ES()EA()EH( + + )0 P(The XML Schema )SM(time)ES( built-in data type is mapped to + the )SM(xml_schema::time)ES( C++ class which repre)HY(sents)YH( hours, + minutes, and seconds with an optional time zone. Its inter)HY(face)YH( is + presented below. For more infor)HY(ma)HY(tion)YH( on the base + )SM(xml_schema::time_zone)ES( class refer to + )0 29 1 A(Section 2.5.7, "Time Zone Repre)HY(sen)HY(ta)HY(tion)YH(")29 0 TN TL()Ec /AF f D(.)EP( + + ) 41 70 PR(class time: public simple_type, public time_zone +{ +public: + time \201unsigned short hours, unsigned short minutes, double seconds\202; + time \201unsigned short hours, unsigned short minutes, double seconds, + short zone_hours, short zone_minutes\202; + +public: + time \201const time&\202; + + time& + operator= \201const time&\202; + + virtual time* + _clone \201\202 const; + +public: + unsigned short + hours \201\202 const; + + void + hours \201unsigned short\202; + + unsigned short + minutes \201\202 const; + + void + minutes \201unsigned short\202; + + double + seconds \201\202 const;)WR( + + void + seconds \201double\202; +}; + +bool +operator== \201const time&, const time&\202; + +bool +operator!= \201const time&, const time&\202;)RP( + + + + + )0 2 35 H(2.6)WB 132 Sn()WB 39 Sn( Mapping for Simple Types)EA()EH( + + )0 P(An XML Schema simple type is mapped to a C++ class with the same + name as the simple type. The class defines a public copy construc)HY(tor)YH(, + a public copy assign)HY(ment)YH( oper)HY(a)HY(tor)YH(, and a public virtual + )SM(_clone)ES( func)HY(tion)YH(. The )SM(_clone)ES( func)HY(tion)YH( is + declared )SM(const)ES(, does not take any argu)HY(ments)YH(, and returns + a pointer to a complete copy of the instance allo)HY(cated)YH( in the free + store. The )SM(_clone)ES( func)HY(tion)YH( shall be used to make copies + when static type and dynamic type of the instance may differ \201see + )0 56 1 A(Section 2.11, "Mapping for )SM(xsi:type)ES( + and Substi)HY(tu)HY(tion)YH( Groups")56 0 TN TL()Ec /AF f D(\202. For instance:)EP( + + ) 3 26 PR(<simpleType name="object"> + ... +</simpleType>)RP( + + )0 P(is mapped to:)EP( + + ) 16 28 PR(class object: ... +{ +public: + object \201const object&\202; + +public: + object& + operator= \201const object&\202; + +public: + virtual object* + _clone \201\202 const; + + ... + +};)RP( + + )0 P(The base class spec)HY(i)HY(fi)HY(ca)HY(tion)YH( and the rest of the class defi)HY(ni)HY(tion)YH( + depend on the type of deriva)HY(tion)YH( used to define the simple type. )EP( + + + )0 3 36 H(2.6.1)WB 133 Sn()WB 40 Sn( Mapping for Deriva)HY(tion)YH( by Restric)HY(tion)YH()EA()EH( + + )0 P(XML Schema deriva)HY(tion)YH( by restric)HY(tion)YH( is mapped to C++ public + inher)HY(i)HY(tance)YH(. The base type of the restric)HY(tion)YH( becomes the base + type for the result)HY(ing)YH( C++ class. In addi)HY(tion)YH( to the members described + in )0 39 1 A(Section 2.6, "Mapping for Simple Types")39 0 TN TL()Ec /AF f D(, the + result)HY(ing)YH( C++ class defines a public construc)HY(tor)YH( with the base type + as its single argu)HY(ment)YH(. For instance:)EP( + + ) 5 27 PR(<simpleType name="object"> + <restriction base="base"> + ... + </restriction> +</simpleType>)RP( + + )0 P(is mapped to:)EP( + + ) 14 28 PR(class object: public base +{ +public: + object \201const base&\202; + object \201const object&\202; + +public: + object& + operator= \201const object&\202; + +public: + virtual object* + _clone \201\202 const; +};)RP( + + + )0 3 37 H(2.6.2)WB 134 Sn()WB 41 Sn( Mapping for Enumer)HY(a)HY(tions)YH()EA()EH( + +)0 P(XML Schema restric)HY(tion)YH( by enumer)HY(a)HY(tion)YH( is mapped to a C++ class + with seman)HY(tics)YH( similar to C++ )SM(enum)ES(. Each XML Schema + enumer)HY(a)HY(tion)YH( element is mapped to a C++ enumer)HY(a)HY(tor)YH( with the + name derived from the )SM(value)ES( attribute and defined + in the class scope. In addi)HY(tion)YH( to the members + described in )0 39 1 A(Section 2.6, "Mapping for Simple Types")39 0 TN TL()Ec /AF f D(, + the result)HY(ing)YH( C++ class defines a public construc)HY(tor)YH( that can be called + with one of the enumer)HY(a)HY(tors)YH( as its single argu)HY(ment)YH(, a public construc)HY(tor)YH( + that can be called with enumer)HY(a)HY(tion)YH('s base value as its single + argu)HY(ment)YH(, a public assign)HY(ment)YH( oper)HY(a)HY(tor)YH( that can be used to assign the + value of one of the enumer)HY(a)HY(tors)YH(, and a public implicit conver)HY(sion)YH( + oper)HY(a)HY(tor)YH( to the under)HY(ly)HY(ing)YH( C++ enum type.)EP( + +)0 P(Further)HY(more)YH(, for string-based enumer)HY(a)HY(tion)YH( types, the result)HY(ing)YH( C++ + class defines a public construc)HY(tor)YH( with a single argu)HY(ment)YH( of type + )SM(const C*)ES( and a public construc)HY(tor)YH( with a single + argu)HY(ment)YH( of type )SM(const std::basic_string<C>&)ES(. + For instance:)EP( + + ) 7 32 PR(<simpleType name="color"> + <restriction base="string"> + <enumeration value="red"/> + <enumeration value="green"/> + <enumeration value="blue"/> + </restriction> +</simpleType>)RP( + + )0 P(is mapped to:)EP( + + ) 31 38 PR(class color: public xml_schema::string +{ +public: + enum value + { + red, + green, + blue + }; + +public: + color \201value\202; + color \201const C*\202; + color \201const std::basic_string<C>&\202; + color \201const xml_schema::string&\202; + color \201const color&\202; + +public: + color& + operator= \201value\202; + + color& + operator= \201const color&\202; + +public: + virtual color* + _clone \201\202 const; + +public: + operator value \201\202 const; +};)WR()RP( + + )0 3 38 H(2.6.3)WB 135 Sn()WB 42 Sn( Mapping for Deriva)HY(tion)YH( by List)EA()EH( + + )0 P(XML Schema deriva)HY(tion)YH( by list is mapped to C++ public + inher)HY(i)HY(tance)YH( from )SM(xml_schema::simple_type)ES( + \201)0 25 1 A(Section 2.5.3, "Mapping for + )SM(anySim)HY(ple)HY(Type)YH()ES(")25 0 TN TL()Ec /AF f D(\202 and a suit)HY(able)YH( sequence type. + The list item type becomes the element type of the sequence. + In addi)HY(tion)YH( to the members described in )0 39 1 A(Section 2.6, + "Mapping for Simple Types")39 0 TN TL()Ec /AF f D(, the result)HY(ing)YH( C++ class defines + a public default construc)HY(tor)YH(, a public construc)HY(tor)YH( + with the first argu)HY(ment)YH( of type )SM(size_type)ES( and + the second argu)HY(ment)YH( of list item type that creates + a list object with the spec)HY(i)HY(fied)YH( number of copies of the spec)HY(i)HY(fied)YH( + element value, and a public construc)HY(tor)YH( with the two argu)HY(ments)YH( + of an input iter)HY(a)HY(tor)YH( type that creates a list object from an + iter)HY(a)HY(tor)YH( range. For instance: + )EP( + + ) 3 28 PR(<simpleType name="int_list"> + <list itemType="int"/> +</simpleType>)RP( + + )0 P(is mapped to:)EP( + + ) 19 42 PR(class int_list: public simple_type, + public sequence<int> +{ +public: + int_list \201\202; + int_list \201size_type n, int x\202; + + template <typename I> + int_list \201const I& begin, const I& end\202; + int_list \201const int_list&\202; + +public: + int_list& + operator= \201const int_list&\202; + +public: + virtual int_list* + _clone \201\202 const; +};)RP( + + )0 P(The )SM(sequence)ES( class template is defined in an + imple)HY(men)HY(ta)HY(tion)YH(-specific names)HY(pace)YH(. It conforms to the + sequence inter)HY(face)YH( as defined by the ISO/ANSI Stan)HY(dard)YH( for + C++ \201ISO/IEC 14882:1998, Section 23.1.1, "Sequences"\202. + Prac)HY(ti)HY(cally)YH(, this means that you can treat such a sequence + as if it was )SM(std::vector)ES(. One notable exten)HY(sion)YH( + to the stan)HY(dard)YH( inter)HY(face)YH( that is avail)HY(able)YH( only for + sequences of non-funda)HY(men)HY(tal)YH( C++ types is the addi)HY(tion)YH( of + the over)HY(loaded)YH( )SM(push_back)ES( and )SM(insert)ES( + member func)HY(tions)YH( which instead of the constant refer)HY(ence)YH( + to the element type accept auto)HY(matic)YH( pointer \201)SM(std::auto_ptr)ES( + or )SM(std::unique_ptr)ES(, depend)HY(ing)YH( on the C++ stan)HY(dard)YH( + selected\202 to the element type. These func)HY(tions)YH( assume owner)HY(ship)YH( + of the pointed to object and reset the passed auto)HY(matic)YH( pointer. + )EP( + + )0 3 39 H(2.6.4)WB 136 Sn()WB 43 Sn( Mapping for Deriva)HY(tion)YH( by Union)EA()EH( + + )0 P(XML Schema deriva)HY(tion)YH( by union is mapped to C++ public + inher)HY(i)HY(tance)YH( from )SM(xml_schema::simple_type)ES( + \201)0 25 1 A(Section 2.5.3, "Mapping for + )SM(anySim)HY(ple)HY(Type)YH()ES(")25 0 TN TL()Ec /AF f D(\202 and )SM(std::basic_string<C>)ES(. + In addi)HY(tion)YH( to the members described in )0 39 1 A(Section 2.6, + "Mapping for Simple Types")39 0 TN TL()Ec /AF f D(, the result)HY(ing)YH( C++ class defines a + public construc)HY(tor)YH( with a single argu)HY(ment)YH( of type )SM(const C*)ES( + and a public construc)HY(tor)YH( with a single argu)HY(ment)YH( of type + )SM(const std::basic_string<C>&)ES(. For instance: + )EP( + + ) 3 47 PR(<simpleType name="int_string_union"> + <xsd:union memberTypes="xsd:int xsd:string"/> +</simpleType>)RP( + + )0 P(is mapped to:)EP( + + ) 16 51 PR(class int_string_union: public simple_type, + public std::basic_string<C> +{ +public: + int_string_union \201const C*\202; + int_string_union \201const std::basic_string<C>&\202; + int_string_union \201const int_string_union&\202; + +public: + int_string_union& + operator= \201const int_string_union&\202; + +public: + virtual int_string_union* + _clone \201\202 const; +};)RP( + + )0 2 40 H(2.7)WB 137 Sn()WB 44 Sn( Mapping for Complex Types)EA()EH( + + )0 P(An XML Schema complex type is mapped to a C++ class with the same + name as the complex type. The class defines a public copy construc)HY(tor)YH(, + a public copy assign)HY(ment)YH( oper)HY(a)HY(tor)YH(, and a public virtual + )SM(_clone)ES( func)HY(tion)YH(. The )SM(_clone)ES( func)HY(tion)YH( is + declared )SM(const)ES(, does not take any argu)HY(ments)YH(, and returns + a pointer to a complete copy of the instance allo)HY(cated)YH( in the free + store. The )SM(_clone)ES( func)HY(tion)YH( shall be used to make copies + when static type and dynamic type of the instance may differ \201see + )0 56 1 A(Section 2.11, "Mapping for )SM(xsi:type)ES( + and Substi)HY(tu)HY(tion)YH( Groups")56 0 TN TL()Ec /AF f D(\202.)EP( + + )0 P(Addi)HY(tion)HY(ally)YH(, the result)HY(ing)YH( C++ class + defines two public construc)HY(tors)YH( that take an initial)HY(izer)YH( for each + member of the complex type and all its base types that belongs to + the One cardi)HY(nal)HY(ity)YH( class \201see )0 47 1 A(Section 2.8, "Mapping + for Local Elements and Attributes")47 0 TN TL()Ec /AF f D(\202. In the first construc)HY(tor)YH(, + the argu)HY(ments)YH( are passed as constant refer)HY(ences)YH( and the newly created + instance is initial)HY(ized)YH( with copies of the passed objects. In the + second construc)HY(tor)YH(, argu)HY(ments)YH( that are complex types \201that is, + they them)HY(selves)YH( contain elements or attributes\202 are passed as + either )SM(std::auto_ptr)ES( \201C++98\202 or )SM(std::unique_ptr)ES( + \201C++11\202, depend)HY(ing)YH( on the C++ stan)HY(dard)YH( selected. In this case the newly + created instance is directly initial)HY(ized)YH( with and assumes owner)HY(ship)YH( + of the pointed to objects and the )SM(std::[auto|unique]_ptr)ES( + argu)HY(ments)YH( are reset to )SM(0)ES(. For instance:)EP( + + ) 15 66 PR(<complexType name="complex"> + <sequence> + <element name="a" type="int"/> + <element name="b" type="string"/> + </sequence> +</complexType> + +<complexType name="object"> + <sequence> + <element name="s-one" type="boolean"/> + <element name="c-one" type="complex"/> + <element name="optional" type="int" minOccurs="0"/> + <element name="sequence" type="string" maxOccurs="unbounded"/> + </sequence> +</complexType>)RP( + + )0 P(is mapped to:)EP( + + ) 36 68 PR(class complex: public xml_schema::type +{ +public: + object \201const int& a, const xml_schema::string& b\202; + object \201const complex&\202; + +public: + object& + operator= \201const complex&\202; + +public: + virtual complex* + _clone \201\202 const; + + ... + +}; + +class object: public xml_schema::type +{ +public: + object \201const bool& s_one, const complex& c_one\202; + object \201const bool& s_one, std::[auto|unique]_ptr<complex> c_one\202; + object \201const object&\202; + +public: + object& + operator= \201const object&\202; + +public: + virtual object*)WR( + _clone \201\202 const; + + ... + +};)RP( + + )0 P(Notice that the gener)HY(ated)YH( )SM(complex)ES( class does not + have the second \201)SM(std::[auto|unique]_ptr)ES(\202 version of the + construc)HY(tor)YH( since all its required members are of simple types.)EP( + + )0 P(If an XML Schema complex type has an ulti)HY(mate)YH( base which is an XML + Schema simple type then the result)HY(ing)YH( C++ class also defines a public + construc)HY(tor)YH( that takes an initial)HY(izer)YH( for the base type as well as + for each member of the complex type and all its base types that + belongs to the One cardi)HY(nal)HY(ity)YH( class. For instance:)EP( + + ) 7 61 PR(<complexType name="object"> + <simpleContent> + <extension base="date"> + <attribute name="lang" type="language" use="required"/> + </extension> + </simpleContent> +</complexType>)RP( + + )0 P(is mapped to:)EP( + + ) 11 44 PR(class object: public xml_schema::string +{ +public: + object \201const xml_schema::language& lang\202; + + object \201const xml_schema::date& base, + const xml_schema::language& lang\202; + + ... + +};)RP( + + )0 P(Further)HY(more)YH(, for string-based XML Schema complex types, the result)HY(ing)YH( C++ + class also defines two public construc)HY(tors)YH( with the first argu)HY(ments)YH( + of type )SM(const C*)ES( and )SM(std::basic_string<C>&)ES(, + respec)HY(tively)YH(, followed by argu)HY(ments)YH( for each member of the complex + type and all its base types that belongs to the One cardi)HY(nal)HY(ity)YH( + class. For enumer)HY(a)HY(tion)YH(-based complex types the result)HY(ing)YH( C++ + class also defines a public construc)HY(tor)YH( with the first argu)HY(ments)YH( + of the under)HY(ly)HY(ing)YH( enum type followed by argu)HY(ments)YH( for each member + of the complex type and all its base types that belongs to the One + cardi)HY(nal)HY(ity)YH( class. For instance:)EP( + + ) 15 61 PR(<simpleType name="color"> + <restriction base="string"> + <enumeration value="red"/> + <enumeration value="green"/> + <enumeration value="blue"/> + </restriction> +</simpleType> + +<complexType name="object"> + <simpleContent> + <extension base="color"> + <attribute name="lang" type="language" use="required"/> + </extension> + </simpleContent> +</complexType>)RP( + + )0 P(is mapped to:)EP( + + ) 37 44 PR(class color: public xml_schema::string +{ +public: + enum value + { + red, + green, + blue + }; + +public: + color \201value\202; + color \201const C*\202; + color \201const std::basic_string<C>&\202; + + ... + +}; + +class object: color +{ +public: + object \201const color& base, + const xml_schema::language& lang\202; + + object \201const color::value& base, + const xml_schema::language& lang\202; + + object \201const C* base, + const xml_schema::language& lang\202; +)WR( + object \201const std::basic_string<C>& base, + const xml_schema::language& lang\202; + + ... + +};)RP( + + )0 P(Addi)HY(tional)YH( construc)HY(tors)YH( can be requested with the + )SM(--gener)HY(ate)YH(-default-ctor)ES( and + )SM(--gener)HY(ate)YH(-from-base-ctor)ES( options. See the + )R8 2 A(XSD + Compiler Command Line Manual)EA( for details.)EP( + + )0 P(If an XML Schema complex type is not explic)HY(itly)YH( derived from any type, + the result)HY(ing)YH( C++ class is derived from )SM(xml_schema::type)ES(. + In cases where an XML Schema complex type is defined using deriva)HY(tion)YH( + by exten)HY(sion)YH( or restric)HY(tion)YH(, the result)HY(ing)YH( C++ base class spec)HY(i)HY(fi)HY(ca)HY(tion)YH( + depends on the type of deriva)HY(tion)YH( and is described in the subse)HY(quent)YH( + sections. + )EP( + + )0 P(The mapping for elements and attributes that are defined in a complex + type is described in )0 47 1 A(Section 2.8, "Mapping for Local + Elements and Attributes")47 0 TN TL()Ec /AF f D(. + )EP( + + )0 3 41 H(2.7.1)WB 138 Sn()WB 45 Sn( Mapping for Deriva)HY(tion)YH( by Exten)HY(sion)YH()EA()EH( + + )0 P(XML Schema deriva)HY(tion)YH( by exten)HY(sion)YH( is mapped to C++ public + inher)HY(i)HY(tance)YH(. The base type of the exten)HY(sion)YH( becomes the base + type for the result)HY(ing)YH( C++ class. + )EP( + + )0 3 42 H(2.7.2)WB 139 Sn()WB 46 Sn( Mapping for Deriva)HY(tion)YH( by Restric)HY(tion)YH()EA()EH( + + )0 P(XML Schema deriva)HY(tion)YH( by restric)HY(tion)YH( is mapped to C++ public + inher)HY(i)HY(tance)YH(. The base type of the restric)HY(tion)YH( becomes the base + type for the result)HY(ing)YH( C++ class. XML Schema elements and + attributes defined within restric)HY(tion)YH( do not result in any + defi)HY(ni)HY(tions)YH( in the result)HY(ing)YH( C++ class. Instead, corre)HY(spond)HY(ing)YH( + \201unre)HY(stricted)YH(\202 defi)HY(ni)HY(tions)YH( are inher)HY(ited)YH( from the base class. + In the future versions of this mapping, such elements and + attributes may result in redef)HY(i)HY(ni)HY(tions)YH( of acces)HY(sors)YH( and + modi)HY(fiers)YH( to reflect their restricted seman)HY(tics)YH(. + )EP( + + + + )0 2 43 H(2.8)WB 140 Sn()WB 47 Sn( Mapping for Local Elements and Attributes)EA()EH( + + )0 P(XML Schema element and attribute defi)HY(ni)HY(tions)YH( are called local + if they appear within a complex type defi)HY(ni)HY(tion)YH(, an element group + defi)HY(ni)HY(tion)YH(, or an attribute group defi)HY(ni)HY(tions)YH(. + )EP( + + )0 P(Local XML Schema element and attribute defi)HY(ni)HY(tions)YH( have the same + C++ mapping. There)HY(fore)YH(, in this section, local elements and + attributes are collec)HY(tively)YH( called members. + )EP( + + )0 P(While there are many differ)HY(ent)YH( member cardi)HY(nal)HY(ity)YH( combi)HY(na)HY(tions)YH( + \201deter)HY(mined)YH( by the )SM(use)ES( attribute for attributes and + the )SM(minOc)HY(curs)YH()ES( and )SM(maxOc)HY(curs)YH()ES( attributes + for elements\202, the mapping divides all possi)HY(ble)YH( cardi)HY(nal)HY(ity)YH( + combi)HY(na)HY(tions)YH( into three cardi)HY(nal)HY(ity)YH( classes: + )EP( + + )0 DL( )0 DT()I(one)ES( + )DD(attributes: )SM(use == "required")ES( + )DD(attributes: )SM(use == "optional")ES( and has default or fixed value + )DD(elements: )SM(minOc)HY(curs)YH( == "1")ES( and )SM(maxOc)HY(curs)YH( == "1")ES( + + )0 DT()I(optional)ES( + )DD(attributes: )SM(use == "optional")ES( and doesn't have default or fixed value + )DD(elements: )SM(minOc)HY(curs)YH( == "0")ES( and )SM(maxOc)HY(curs)YH( == "1")ES( + + )0 DT()I(sequence)ES( + )DD(elements: )SM(maxOc)HY(curs)YH( > "1")ES( + )LD( + + )0 P(An optional attribute with a default or fixed value acquires this value + if the attribute hasn't been spec)HY(i)HY(fied)YH( in an instance docu)HY(ment)YH( \201see + )0 95 1 A(Appendix A, "Default and Fixed Values")95 0 TN TL()Ec /AF f D(\202. This + mapping places such optional attributes to the One cardi)HY(nal)HY(ity)YH( + class.)EP( + + )0 P(A member is mapped to a set of public type defi)HY(ni)HY(tions)YH( + \201)SM(typedef)ES(s\202 and a set of public acces)HY(sor)YH( and modi)HY(fier)YH( + func)HY(tions)YH(. Type defi)HY(ni)HY(tions)YH( have names derived from the member's + name. The acces)HY(sor)YH( and modi)HY(fier)YH( func)HY(tions)YH( have the same name as the + member. For example: + )EP( + + ) 5 42 PR(<complexType name="object"> + <sequence> + <element name="member" type="string"/> + </sequence> +</complexType>)RP( + + )0 P(is mapped to:)EP( + + ) 11 41 PR(class object: public xml_schema::type +{ +public: + typedef xml_schema::string member_type; + + const member_type& + member \201\202 const; + + ... + +};)RP( + + )0 P(In addi)HY(tion)YH(, if a member has a default or fixed value, a static + acces)HY(sor)YH( func)HY(tion)YH( is gener)HY(ated)YH( that returns this value. For + example:)EP( + +) 3 55 PR(<complexType name="object"> + <attribute name="data" type="string" default="test"/> +</complexType>)RP( + + )0 P(is mapped to:)EP( + + ) 14 39 PR(class object: public xml_schema::type +{ +public: + typedef xml_schema::string data_type; + + const data_type& + data \201\202 const; + + static const data_type& + data_default_value \201\202; + + ... + +};)RP( + + )0 P(Names and seman)HY(tics)YH( of type defi)HY(ni)HY(tions)YH( for the member as well + as signa)HY(tures)YH( of the acces)HY(sor)YH( and modi)HY(fier)YH( func)HY(tions)YH( depend on + the member's cardi)HY(nal)HY(ity)YH( class and are described in the follow)HY(ing)YH( + sub-sections. + )EP( + + + )0 3 44 H(2.8.1)WB 141 Sn()WB 48 Sn( Mapping for Members with the One Cardi)HY(nal)HY(ity)YH( Class)EA()EH( + + )0 P(For the One cardi)HY(nal)HY(ity)YH( class, the type defi)HY(ni)HY(tions)YH( consist of + an alias for the member's type with the name created by append)HY(ing)YH( + the )SM(_type)ES( suffix to the member's name. + )EP( + + )0 P(The acces)HY(sor)YH( func)HY(tions)YH( come in constant and non-constant versions. + The constant acces)HY(sor)YH( func)HY(tion)YH( returns a constant refer)HY(ence)YH( to the + member and can be used for read-only access. The non-constant + version returns an unre)HY(stricted)YH( refer)HY(ence)YH( to the member and can + be used for read-write access. + )EP( + + )0 P(The first modi)HY(fier)YH( func)HY(tion)YH( expects an argu)HY(ment)YH( of type refer)HY(ence)YH( to + constant of the member's type. It makes a deep copy of its argu)HY(ment)YH(. + Except for member's types that are mapped to funda)HY(men)HY(tal)YH( C++ types, + the second modi)HY(fier)YH( func)HY(tion)YH( is provided that expects an argu)HY(ment)YH( + of type auto)HY(matic)YH( pointer \201)SM(std::auto_ptr)ES( or + )SM(std::unique_ptr)ES(, depend)HY(ing)YH( on the C++ stan)HY(dard)YH( selected\202 + to the member's type. It assumes owner)HY(ship)YH( of the pointed to object + and resets the passed auto)HY(matic)YH( pointer. For instance:)EP( + + ) 5 42 PR(<complexType name="object"> + <sequence> + <element name="member" type="string"/> + </sequence> +</complexType>)RP( + + )0 P(is mapped to:)EP( + + ) 25 47 PR(class object: public xml_schema::type +{ +public: + // Type definitions. + // + typedef xml_schema::string member_type; + + // Accessors. + // + const member_type& + member \201\202 const; + + member_type& + member \201\202; + + // Modifiers. + // + void + member \201const member_type&\202; + + void + member \201std::[auto|unique]_ptr<member_type>\202; + ... + +};)RP( + + )0 P(In addi)HY(tion)YH(, if requested by spec)HY(i)HY(fy)HY(ing)YH( the )SM(--gener)HY(ate)YH(-detach)ES( + option and only for members of non-funda)HY(men)HY(tal)YH( C++ types, the mapping + provides a detach func)HY(tion)YH( that returns an auto)HY(matic)YH( pointer to the + member's type, for example:)EP( + + ) 10 37 PR(class object: public xml_schema::type +{ +public: + ... + + std::[auto|unique]_ptr<member_type> + detach_member \201\202; + ... + +};)RP( + + )0 P(This func)HY(tion)YH( detaches the value from the tree leaving the member + value unini)HY(tial)HY(ized)YH(. Access)HY(ing)YH( such an unini)HY(tial)HY(ized)YH( value prior to + re-initial)HY(iz)HY(ing)YH( it results in unde)HY(fined)YH( behav)HY(ior)YH(.)EP( + + )0 P(The follow)HY(ing)YH( code shows how one could use this mapping:)EP( + + ) 25 66 PR(void +f \201object& o\202 +{ + using xml_schema::string; + + string s \201o.member \201\202\202; // get + object::member_type& sr \201o.member \201\202\202; // get + + o.member \201"hello"\202; // set, deep copy + o.member \201\202 = "hello"; // set, deep copy + + // C++98 version. + // + std::auto_ptr<string> p \201new string \201"hello"\202\202; + o.member \201p\202; // set, assumes ownership + p = o.detach_member \201\202; // detach, member is uninitialized + o.member \201p\202; // re-attach + + // C++11 version. + // + std::unique_ptr<string> p \201new string \201"hello"\202\202; + o.member \201std::move \201p\202\202; // set, assumes ownership + p = o.detach_member \201\202; // detach, member is uninitialized + o.member \201std::move \201p\202\202; // re-attach +})RP( + + +)0 3 45 H(2.8.2)WB 142 Sn()WB 49 Sn( Mapping for Members with the Optional Cardi)HY(nal)HY(ity)YH( Class)EA()EH( + + )0 P(For the Optional cardi)HY(nal)HY(ity)YH( class, the type defi)HY(ni)HY(tions)YH( consist of + an alias for the member's type with the name created by append)HY(ing)YH( + the )SM(_type)ES( suffix to the member's name and an alias for + the container type with the name created by append)HY(ing)YH( the + )SM(_optional)ES( suffix to the member's name. + )EP( + + )0 P(Unlike acces)HY(sor)YH( func)HY(tions)YH( for the One cardi)HY(nal)HY(ity)YH( class, acces)HY(sor)YH( + func)HY(tions)YH( for the Optional cardi)HY(nal)HY(ity)YH( class return refer)HY(ences)YH( to + corre)HY(spond)HY(ing)YH( contain)HY(ers)YH( rather than directly to members. The + acces)HY(sor)YH( func)HY(tions)YH( come in constant and non-constant versions. + The constant acces)HY(sor)YH( func)HY(tion)YH( returns a constant refer)HY(ence)YH( to + the container and can be used for read-only access. The non-constant + version returns an unre)HY(stricted)YH( refer)HY(ence)YH( to the container + and can be used for read-write access. + )EP( + + )0 P(The modi)HY(fier)YH( func)HY(tions)YH( are over)HY(loaded)YH( for the member's + type and the container type. The first modi)HY(fier)YH( func)HY(tion)YH( + expects an argu)HY(ment)YH( of type refer)HY(ence)YH( to constant of the + member's type. It makes a deep copy of its argu)HY(ment)YH(. + Except for member's types that are mapped to funda)HY(men)HY(tal)YH( C++ types, + the second modi)HY(fier)YH( func)HY(tion)YH( is provided that expects an argu)HY(ment)YH( + of type auto)HY(matic)YH( pointer \201)SM(std::auto_ptr)ES( or + )SM(std::unique_ptr)ES(, depend)HY(ing)YH( on the C++ stan)HY(dard)YH( selected\202 + to the member's type. It assumes owner)HY(ship)YH( of the pointed to object + and resets the passed auto)HY(matic)YH( pointer. The last modi)HY(fier)YH( func)HY(tion)YH( + expects an argu)HY(ment)YH( of type refer)HY(ence)YH( to constant of the container + type. It makes a deep copy of its argu)HY(ment)YH(. For instance: + )EP( + + ) 5 56 PR(<complexType name="object"> + <sequence> + <element name="member" type="string" minOccurs="0"/> + </sequence> +</complexType>)RP( + + )0 P(is mapped to:)EP( + + ) 30 48 PR(class object: public xml_schema::type +{ +public: + // Type definitions. + // + typedef xml_schema::string member_type; + typedef optional<member_type> member_optional; + + // Accessors. + // + const member_optional& + member \201\202 const; + + member_optional& + member \201\202; + + // Modifiers. + // + void + member \201const member_type&\202; + + void + member \201std::[auto|unique]_ptr<member_type>\202; + + void + member \201const member_optional&\202; + + ... + +};)RP( + + + )0 P(The )SM(optional)ES( class template is defined in an + imple)HY(men)HY(ta)HY(tion)YH(-specific names)HY(pace)YH( and has the follow)HY(ing)YH( + inter)HY(face)YH(. The )SM([auto|unique]_ptr)ES(-based construc)HY(tor)YH( + and modi)HY(fier)YH( func)HY(tion)YH( are only avail)HY(able)YH( if the template + argu)HY(ment)YH( is not a funda)HY(men)HY(tal)YH( C++ type. + )EP( + + ) 97 52 PR(template <typename X> +class optional +{ +public: + optional \201\202; + + // Makes a deep copy. + // + explicit + optional \201const X&\202; + + // Assumes ownership. + // + explicit + optional \201std::[auto|unique]_ptr<X>\202; + + optional \201const optional&\202; + +public: + optional& + operator= \201const X&\202; + + optional& + operator= \201const optional&\202; + + // Pointer-like interface. + // +public: + const X* + operator-> \201\202 const; +)WR( + X* + operator-> \201\202; + + const X& + operator* \201\202 const; + + X& + operator* \201\202; + + typedef void \201optional::*bool_convertible\202 \201\202; + operator bool_convertible \201\202 const; + + // Get/set interface. + // +public: + bool + present \201\202 const; + + const X& + get \201\202 const; + + X& + get \201\202; + + // Makes a deep copy. + // + void + set \201const X&\202; + + // Assumes ownership.)WR( + // + void + set \201std::[auto|unique]_ptr<X>\202; + + // Detach and return the contained value. + // + std::[auto|unique]_ptr<X> + detach \201\202; + + void + reset \201\202; +}; + +template <typename X> +bool +operator== \201const optional<X>&, const optional<X>&\202; + +template <typename X> +bool +operator!= \201const optional<X>&, const optional<X>&\202; + +template <typename X> +bool +operator< \201const optional<X>&, const optional<X>&\202; + +template <typename X> +bool +operator> \201const optional<X>&, const optional<X>&\202; + +template <typename X>)WR( +bool +operator<= \201const optional<X>&, const optional<X>&\202; + +template <typename X> +bool +operator>= \201const optional<X>&, const optional<X>&\202;)RP( + + + )0 P(The follow)HY(ing)YH( code shows how one could use this mapping:)EP( + + ) 45 62 PR(void +f \201object& o\202 +{ + using xml_schema::string; + + if \201o.member \201\202.present \201\202\202 // test + { + string& s \201o.member \201\202.get \201\202\202; // get + o.member \201"hello"\202; // set, deep copy + o.member \201\202.set \201"hello"\202; // set, deep copy + o.member \201\202.reset \201\202; // reset + } + + // Same as above but using pointer notation: + // + if \201o.member \201\202\202 // test + { + string& s \201*o.member \201\202\202; // get + o.member \201"hello"\202; // set, deep copy + *o.member \201\202 = "hello"; // set, deep copy + o.member \201\202.reset \201\202; // reset + } + + // C++98 version. + // + std::auto_ptr<string> p \201new string \201"hello"\202\202; + o.member \201p\202; // set, assumes ownership + + p = new string \201"hello"\202; + o.member \201\202.set \201p\202; // set, assumes ownership +)WR( + p = o.member \201\202.detach \201\202; // detach, member is reset + o.member \201\202.set \201p\202; // re-attach + + // C++11 version. + // + std::unique_ptr<string> p \201new string \201"hello"\202\202; + o.member \201std::move \201p\202\202; // set, assumes ownership + + p.reset \201new string \201"hello"\202\202; + o.member \201\202.set \201std::move \201p\202\202; // set, assumes ownership + + p = o.member \201\202.detach \201\202; // detach, member is reset + o.member \201\202.set \201std::move \201p\202\202; // re-attach +})RP( + + + )0 3 46 H(2.8.3)WB 143 Sn()WB 50 Sn( Mapping for Members with the Sequence Cardi)HY(nal)HY(ity)YH( Class)EA()EH( + + )0 P(For the Sequence cardi)HY(nal)HY(ity)YH( class, the type defi)HY(ni)HY(tions)YH( consist of an + alias for the member's type with the name created by append)HY(ing)YH( + the )SM(_type)ES( suffix to the member's name, an alias of + the container type with the name created by append)HY(ing)YH( the + )SM(_sequence)ES( suffix to the member's name, an alias of + the iter)HY(a)HY(tor)YH( type with the name created by append)HY(ing)YH( the + )SM(_iter)HY(a)HY(tor)YH()ES( suffix to the member's name, and an alias + of the constant iter)HY(a)HY(tor)YH( type with the name created by append)HY(ing)YH( the + )SM(_const_iter)HY(a)HY(tor)YH()ES( suffix to the member's name. + )EP( + + )0 P(The acces)HY(sor)YH( func)HY(tions)YH( come in constant and non-constant versions. + The constant acces)HY(sor)YH( func)HY(tion)YH( returns a constant refer)HY(ence)YH( to the + container and can be used for read-only access. The non-constant + version returns an unre)HY(stricted)YH( refer)HY(ence)YH( to the container and can + be used for read-write access. + )EP( + + )0 P(The modi)HY(fier)YH( func)HY(tion)YH( expects an argu)HY(ment)YH( of type refer)HY(ence)YH( to + constant of the container type. The modi)HY(fier)YH( func)HY(tion)YH( + makes a deep copy of its argu)HY(ment)YH(. For instance: + )EP( + + + ) 5 64 PR(<complexType name="object"> + <sequence> + <element name="member" type="string" minOccurs="unbounded"/> + </sequence> +</complexType>)RP( + + )0 P(is mapped to:)EP( + + ) 26 64 PR(class object: public xml_schema::type +{ +public: + // Type definitions. + // + typedef xml_schema::string member_type; + typedef sequence<member_type> member_sequence; + typedef member_sequence::iterator member_iterator; + typedef member_sequence::const_iterator member_const_iterator; + + // Accessors. + // + const member_sequence& + member \201\202 const; + + member_sequence& + member \201\202; + + // Modifier. + // + void + member \201const member_sequence&\202; + + ... + +};)RP( + + )0 P(The )SM(sequence)ES( class template is defined in an + imple)HY(men)HY(ta)HY(tion)YH(-specific names)HY(pace)YH(. It conforms to the + sequence inter)HY(face)YH( as defined by the ISO/ANSI Stan)HY(dard)YH( for + C++ \201ISO/IEC 14882:1998, Section 23.1.1, "Sequences"\202. + Prac)HY(ti)HY(cally)YH(, this means that you can treat such a sequence + as if it was )SM(std::vector)ES(. Two notable exten)HY(sions)YH( + to the stan)HY(dard)YH( inter)HY(face)YH( that are avail)HY(able)YH( only for + sequences of non-funda)HY(men)HY(tal)YH( C++ types are the addi)HY(tion)YH( of + the over)HY(loaded)YH( )SM(push_back)ES( and )SM(insert)ES( + as well as the )SM(detach_back)ES( and )SM(detach)ES( + member func)HY(tions)YH(. The addi)HY(tional)YH( )SM(push_back)ES( and + )SM(insert)ES( func)HY(tions)YH( accept an auto)HY(matic)YH( pointer + \201)SM(std::auto_ptr)ES( or )SM(std::unique_ptr)ES(, + depend)HY(ing)YH( on the C++ stan)HY(dard)YH( selected\202 to the + element type instead of the constant refer)HY(ence)YH(. They assume + owner)HY(ship)YH( of the pointed to object and reset the passed + auto)HY(matic)YH( pointer. The )SM(detach_back)ES( and + )SM(detach)ES( func)HY(tions)YH( detach the element + value from the sequence container and, by default, remove + the element from the sequence. These addi)HY(tional)YH( func)HY(tions)YH( + have the follow)HY(ing)YH( signa)HY(tures)YH(:)EP( + + ) 22 55 PR(template <typename X> +class sequence +{ +public: + ... + + void + push_back \201std::[auto|unique]_ptr<X>\202 + + iterator + insert \201iterator position, std::[auto|unique]_ptr<X>\202 + + std::[auto|unique]_ptr<X> + detach_back \201bool pop = true\202; + + iterator + detach \201iterator position, + std::[auto|unique]_ptr<X>& result, + bool erase = true\202 + + ... +})RP( + + )0 P(The follow)HY(ing)YH( code shows how one could use this mapping:)EP( + + ) 39 66 PR(void +f \201object& o\202 +{ + using xml_schema::string; + + object::member_sequence& s \201o.member \201\202\202; + + // Iteration. + // + for \201object::member_iterator i \201s.begin \201\202\202; i != s.end \201\202; ++i\202 + { + string& value \201*i\202; + } + + // Modification. + // + s.push_back \201"hello"\202; // deep copy + + // C++98 version. + // + std::auto_ptr<string> p \201new string \201"hello"\202\202; + s.push_back \201p\202; // assumes ownership + p = s.detach_back \201\202; // detach and pop + s.push_back \201p\202; // re-append + + // C++11 version. + // + std::unique_ptr<string> p \201new string \201"hello"\202\202; + s.push_back \201std::move \201p\202\202; // assumes ownership + p = s.detach_back \201\202; // detach and pop + s.push_back \201std::move \201p\202\202; // re-append)WR( + + // Setting a new container. + // + object::member_sequence n; + n.push_back \201"one"\202; + n.push_back \201"two"\202; + o.member \201n\202; // deep copy +})RP( + + )0 3 47 H(2.8.4)WB 144 Sn()WB 51 Sn( Element Order)EA()EH( + + )0 P(C++/Tree is a "flat)HY(ten)HY(ing)YH(" mapping in a sense that many levels of + nested compos)HY(i)HY(tors)YH( \201)SM(choice)ES( and )SM(sequence)ES(\202, + all poten)HY(tially)YH( with their own cardi)HY(nal)HY(i)HY(ties)YH(, are in the end mapped + to a flat set of elements with one of the three cardi)HY(nal)HY(ity)YH( classes + discussed in the previ)HY(ous)YH( sections. While this results in a simple + and easy to use API for most types, in certain cases, the order of + elements in the actual XML docu)HY(ments)YH( is not preserved once parsed + into the object model. And some)HY(times)YH( such order has + appli)HY(ca)HY(tion)YH(-specific signif)HY(i)HY(cance)YH(. As an example, consider a schema + that defines a batch of bank trans)HY(ac)HY(tions)YH(:)EP( + + ) 20 48 PR(<complexType name="withdraw"> + <sequence> + <element name="account" type="unsignedInt"/> + <element name="amount" type="unsignedInt"/> + </sequence> +</complexType> + +<complexType name="deposit"> + <sequence> + <element name="account" type="unsignedInt"/> + <element name="amount" type="unsignedInt"/> + </sequence> +</complexType> + +<complexType name="batch"> + <choice minOccurs="0" maxOccurs="unbounded"> + <element name="withdraw" type="withdraw"/> + <element name="deposit" type="deposit"/> + </choice> +</complexType>)RP( + + )0 P(The batch can contain any number of trans)HY(ac)HY(tions)YH( in any order + but the order of trans)HY(ac)HY(tions)YH( in each actual batch is signif)HY(i)HY(cant)YH(. + For instance, consider what could happen if we reorder the + trans)HY(ac)HY(tions)YH( and apply all the with)HY(drawals)YH( before deposits.)EP( + + )0 P(For the )SM(batch)ES( schema type defined above the default + C++/Tree mapping will produce a C++ class that contains a pair of + sequence contain)HY(ers)YH(, one for each of the two elements. While this + will capture the content \201trans)HY(ac)HY(tions)YH(\202, the order of this content + as it appears in XML will be lost. Also, if we try to seri)HY(al)HY(ize)YH( the + batch we just loaded back to XML, all the with)HY(drawal)YH( trans)HY(ac)HY(tions)YH( + will appear before deposits.)EP( + + )0 P(To over)HY(come)YH( this limi)HY(ta)HY(tion)YH( of a flat)HY(ten)HY(ing)YH( mapping, C++/Tree + allows us to mark certain XML Schema types, for which content + order is impor)HY(tant)YH(, as ordered.)EP( + + )0 P(There are several command line options that control which + schema types are treated as ordered. To make an indi)HY(vid)HY(ual)YH( + type ordered, we use the )SM(--ordered-type)ES( option, + for example:)EP( + + ) 1 20 PR(--ordered-type batch)RP( + + )0 P(To auto)HY(mat)HY(i)HY(cally)YH( treat all the types that are derived from an ordered + type also ordered, we use the )SM(--ordered-type-derived)ES( + option. This is primar)HY(ily)YH( useful if you would like to iterate + over the complete hier)HY(ar)HY(chy)YH('s content using the content order + sequence \201discussed below\202.)EP( + + )0 P(Ordered types are also useful for handling mixed content. To + auto)HY(mat)HY(i)HY(cally)YH( mark all the types with mixed content as ordered + we use the )SM(--ordered-type-mixed)ES( option. For more + infor)HY(ma)HY(tion)YH( on handling mixed content see )0 63 1 A(Section + 2.13, "Mapping for Mixed Content Models")63 0 TN TL()Ec /AF f D(.)EP( + + )0 P(Finally, we can mark all the types in the schema we are + compil)HY(ing)YH( with the )SM(--ordered-type-all)ES( option. + You should only resort to this option if all the types in + your schema truly suffer from the loss of content + order since, as we will discuss shortly, ordered types + require extra effort to access and, espe)HY(cially)YH(, modify. + See the + )R8 2 A(XSD + Compiler Command Line Manual)EA( for more infor)HY(ma)HY(tion)YH( on + these options.)EP( + + )0 P(Once a type is marked ordered, C++/Tree alters its mapping + in several ways. Firstly, for each local element, element + wild)HY(card)YH( \201)0 61 1 A(Section 2.12.4, "Element Wild)HY(card)YH( + Order")61 0 TN TL()Ec /AF f D(\202, and mixed content text \201)0 63 1 A(Section + 2.13, "Mapping for Mixed Content Models")63 0 TN TL()Ec /AF f D(\202 in this type, a + content id constant is gener)HY(ated)YH(. Secondly, an addi)HY(tion)YH( sequence + is added to the class that captures the content order. Here + is how the mapping of our )SM(batch)ES( class changes + once we make it ordered:)EP( + + ) 57 78 PR(class batch: public xml_schema::type +{ +public: + // withdraw + // + typedef withdraw withdraw_type; + typedef sequence<withdraw_type> withdraw_sequence; + typedef withdraw_sequence::iterator withdraw_iterator; + typedef withdraw_sequence::const_iterator withdraw_const_iterator; + + static const std::size_t withdraw_id = 1; + + const withdraw_sequence& + withdraw \201\202 const; + + withdraw_sequence& + withdraw \201\202; + + void + withdraw \201const withdraw_sequence&\202; + + // deposit + // + typedef deposit deposit_type; + typedef sequence<deposit_type> deposit_sequence; + typedef deposit_sequence::iterator deposit_iterator; + typedef deposit_sequence::const_iterator deposit_const_iterator; + + static const std::size_t deposit_id = 2; + + const deposit_sequence&)WR( + deposit \201\202 const; + + deposit_sequence& + deposit \201\202; + + void + deposit \201const deposit_sequence&\202; + + // content_order + // + typedef xml_schema::content_order content_order_type; + typedef std::vector<content_order_type> content_order_sequence; + typedef content_order_sequence::iterator content_order_iterator; + typedef content_order_sequence::const_iterator content_order_const_iterator; + + const content_order_sequence& + content_order \201\202 const; + + content_order_sequence& + content_order \201\202; + + void + content_order \201const content_order_sequence&\202; + + ... +};)RP( + + )0 P(Notice the )SM(with)HY(draw)YH(_id)ES( and )SM(deposit_id)ES( + content ids as well as the extra )SM(content_order)ES( + sequence that does not corre)HY(spond)YH( to any element in the + schema defi)HY(ni)HY(tion)YH(. The other changes to the mapping for ordered + types has to do with XML parsing and seri)HY(al)HY(iza)HY(tion)YH( code. During + parsing the content order is captured in the )SM(content_order)ES( + sequence while during seri)HY(al)HY(iza)HY(tion)YH( this sequence is used to + deter)HY(mine)YH( the order in which content is seri)HY(al)HY(ized)YH(. The + )SM(content_order)ES( sequence is also copied during + copy construc)HY(tion)YH( and assigned during copy assign)HY(ment)YH(. It is also + taken into account during compar)HY(i)HY(son)YH(.)EP( + + )0 P(The entry type of the )SM(content_order)ES( sequence is the + )SM(xml_schema::content_order)ES( type that has the follow)HY(ing)YH( + inter)HY(face)YH(:)EP( + + ) 19 58 PR(namespace xml_schema +{ + struct content_order + { + content_order \201std::size_t id, std::size_t index = 0\202; + + std::size_t id; + std::size_t index; + }; + + bool + operator== \201const content_order&, const content_order&\202; + + bool + operator!= \201const content_order&, const content_order&\202; + + bool + operator< \201const content_order&, const content_order&\202; +})RP( + + )0 P(The )SM(content_order)ES( sequence describes the order of + content \201elements, includ)HY(ing)YH( wild)HY(cards)YH(, as well as mixed content + text\202. Each entry in this sequence consists of the content id + \201for example, )SM(with)HY(draw)YH(_id)ES( or )SM(deposit_id)ES( + in our case\202 as well as, for elements of the sequence cardi)HY(nal)HY(ity)YH( + class, an index into the corre)HY(spond)HY(ing)YH( sequence container \201the + index is unused for the one and optional cardi)HY(nal)HY(ity)YH( classes\202. + For example, in our case, if the content id is )SM(with)HY(draw)YH(_id)ES(, + then the index will point into the )SM(with)HY(draw)YH()ES( element + sequence.)EP( + + )0 P(With all this infor)HY(ma)HY(tion)YH( we can now examine how to iterate over + trans)HY(ac)HY(tion)YH( in the batch in content order:)EP( + + ) 26 73 PR(batch& b = ... + +for \201batch::content_order_const_iterator i \201b.content_order \201\202.begin \201\202\202; + i != b.content_order \201\202.end \201\202; + ++i\202 +{ + switch \201i->id\202 + { + case batch::withdraw_id: + { + const withdraw& t \201b.withdraw \201\202[i->index]\202; + cerr << t.account \201\202 << " withdraw " << t.amount \201\202 << endl; + break; + } + case batch::deposit_id: + { + const deposit& t \201b.deposit \201\202[i->index]\202; + cerr << t.account \201\202 << " deposit " << t.amount \201\202 << endl; + break; + } + default: + { + assert \201false\202; // Unknown content id. + } + } +})RP( + + )0 P(If we seri)HY(al)HY(ized)YH( our batch back to XML, we would also see that the + order of trans)HY(ac)HY(tions)YH( in the output is exactly the same as in the + input rather than all the with)HY(drawals)YH( first followed by all the + deposits.)EP( + + )0 P(The most complex aspect of working with ordered types is + modi)HY(fi)HY(ca)HY(tions)YH(. Now we not only need to change the content, + but also remem)HY(ber)YH( to update the order infor)HY(ma)HY(tion)YH( corre)HY(spond)HY(ing)YH( + to this change. As a first example, we add a deposit trans)HY(ac)HY(tion)YH( + to the batch:)EP( + + ) 8 64 PR(using xml_schema::content_order; + +batch::deposit_sequence& d \201b.deposit \201\202\202; +batch::withdraw_sequence& w \201b.withdraw \201\202\202; +batch::content_order_sequence& co \201b.content_order \201\202\202; + +d.push_back \201deposit \201123456789, 100000\202\202; +co.push_back \201content_order \201batch::deposit_id, d.size \201\202 - 1\202\202;)RP( + + )0 P(In the above example we first added the content \201deposit + trans)HY(ac)HY(tion)YH(\202 and then updated the content order infor)HY(ma)HY(tion)YH( + by adding an entry with )SM(deposit_id)ES( content + id and the index of the just added deposit trans)HY(ac)HY(tion)YH(.)EP( + + )0 P(Remov)HY(ing)YH( the last trans)HY(ac)HY(tion)YH( can be easy if we know which + trans)HY(ac)HY(tion)YH( \201deposit or with)HY(drawal)YH(\202 is last:)EP( + + ) 2 15 PR(d.pop_back \201\202; +co.pop_back \201\202;)RP( + + )0 P(If, however, we do not know which trans)HY(ac)HY(tion)YH( is last, then + things get a bit more compli)HY(cated)YH(:)EP( + + ) 15 24 PR(switch \201co.back \201\202.id\202 +{ +case batch::withdraw_id: + { + d.pop_back \201\202; + break; + } +case batch::deposit_id: + { + w.pop_back \201\202; + break; + } +} + +co.pop_back \201\202;)RP( + + )0 P(The follow)HY(ing)YH( example shows how to add a trans)HY(ac)HY(tion)YH( at the + begin)HY(ning)YH( of the batch:)EP( + + ) 3 62 PR(w.push_back \201withdraw \201123456789, 100000\202\202; +co.insert \201co.begin \201\202, + content_order \201batch::withdraw_id, w.size \201\202 - 1\202\202;)RP( + + )0 P(Note also that when we merely modify the content of one + of the elements in place, we do not need to update its + order since it doesn't change. For example, here is how + we can change the amount in the first with)HY(drawal)YH(:)EP( + + ) 1 20 PR(w[0].amount \20110000\202;)RP( + + )0 P(For the complete working code shown in this section refer to the + )SM(order/element)ES( example in the + )SM(exam)HY(ples)YH(/cxx/tree/)ES( direc)HY(tory)YH( in the XSD distri)HY(bu)HY(tion)YH(.)EP( + + )0 P(If both the base and derived types are ordered, then the + content order sequence is only added to the base and the content + ids are unique within the whole hier)HY(ar)HY(chy)YH(. In this case + the content order sequence for the derived type contains + order)HY(ing)YH( infor)HY(ma)HY(tion)YH( for both base and derived content.)EP( + + )0 P(In some appli)HY(ca)HY(tions)YH( we may need to perform more complex + content process)HY(ing)YH(. For example, in our case, we may need + to remove all the with)HY(drawal)YH( trans)HY(ac)HY(tions)YH(. The default + container, )SM(std::vector)ES(, is not partic)HY(u)HY(larly)YH( + suit)HY(able)YH( for such oper)HY(a)HY(tions)YH(. What may be required by + some appli)HY(ca)HY(tions)YH( is a multi-index container that not + only allows us to iterate in content order similar to + )SM(std::vector)ES( but also search by the content + id as well as the content id and index pair.)EP( + + )0 P(While C++/Tree does not provide this func)HY(tion)HY(al)HY(ity)YH( by + default, it allows us to specify a custom container + type for content order with the )SM(--order-container)ES( + command line option. The only require)HY(ment)YH( from the + gener)HY(ated)YH( code side for such a container is to provide + the )SM(vector)ES(-like )SM(push_back\201\202)ES(, + )SM(size\201\202)ES(, and const iter)HY(a)HY(tion)YH( inter)HY(faces)YH(.)EP( + + )0 P(As an example, here is how we can use the Boost Multi-Index + container for content order. First we create the + )SM(content-order-container.hxx)ES( header with the + follow)HY(ing)YH( defi)HY(ni)HY(tion)YH( \201in C++11, use the alias template + instead\202:)EP( + + ) 33 58 PR(#ifndef CONTENT_ORDER_CONTAINER +#define CONTENT_ORDER_CONTAINER + +#include <cstddef> // std::size_t + +#include <boost/multi_index_container.hpp> +#include <boost/multi_index/member.hpp> +#include <boost/multi_index/identity.hpp> +#include <boost/multi_index/ordered_index.hpp> +#include <boost/multi_index/random_access_index.hpp> + +struct by_id {}; +struct by_id_index {}; + +template <typename T> +struct content_order_container: + boost::multi_index::multi_index_container< + T, + boost::multi_index::indexed_by< + boost::multi_index::random_access<>, + boost::multi_index::ordered_unique< + boost::multi_index::tag<by_id_index>, + boost::multi_index::identity<T> + >, + boost::multi_index::ordered_non_unique< + boost::multi_index::tag<by_id>, + boost::multi_index::member<T, std::size_t, &T::id> + > + > + > +{};)WR( + +#endif)RP( + + )0 P(Next we add the follow)HY(ing)YH( two XSD compiler options to include + this header into every gener)HY(ated)YH( header file and to use the + custom container type \201see the XSD compiler command line manual + for more infor)HY(ma)HY(tion)YH( on shell quoting for the first option\202:)EP( + + ) 2 55 PR(--hxx-prologue '#include "content-order-container.hxx"' +--order-container content_order_container)RP( + + )0 P(With these changes we can now use the multi-index func)HY(tion)HY(al)HY(ity)YH(, + for example, to search for a specific content id:)EP( + + ) 13 65 PR(typedef batch::content_order_sequence::index<by_id>::type id_set; +typedef id_set::iterator id_iterator; + +const id_set& ids \201b.content_order \201\202.get<by_id> \201\202\202; + +std::pair<id_iterator, id_iterator> r \201 + ids.equal_range \201std::size_t \201batch::deposit_id\202\202; + +for \201id_iterator i \201r.first\202; i != r.second; ++i\202 +{ + const deposit& t \201b.deposit \201\202[i->index]\202; + cerr << t.account \201\202 << " deposit " << t.amount \201\202 << endl; +})RP( + + )0 2 48 H(2.9)WB 145 Sn()WB 52 Sn( Mapping for Global Elements)EA()EH( + + )0 P(An XML Schema element defi)HY(ni)HY(tion)YH( is called global if it appears + directly under the )SM(schema)ES( element. + A global element is a valid root of an instance docu)HY(ment)YH(. By + default, a global element is mapped to a set of over)HY(loaded)YH( + parsing and, option)HY(ally)YH(, seri)HY(al)HY(iza)HY(tion)YH( func)HY(tions)YH( with the + same name as the element. It is also possi)HY(ble)YH( to gener)HY(ate)YH( types + for root elements instead of parsing and seri)HY(al)HY(iza)HY(tion)YH( func)HY(tions)YH(. + This is primar)HY(ily)YH( useful to distin)HY(guish)YH( object models with the + same root type but with differ)HY(ent)YH( root elements. See + )0 53 1 A(Section 2.9.1, "Element Types")53 0 TN TL()Ec /AF f D( for details. + It is also possi)HY(ble)YH( to request the gener)HY(a)HY(tion)YH( of an element map + which allows uniform parsing and seri)HY(al)HY(iza)HY(tion)YH( of multi)HY(ple)YH( root + elements. See )0 54 1 A(Section 2.9.2, "Element Map")54 0 TN TL()Ec /AF f D( + for details. + )EP( + + )0 P(The parsing func)HY(tions)YH( read XML instance docu)HY(ments)YH( and return + corre)HY(spond)HY(ing)YH( object models as an auto)HY(matic)YH( pointer + \201)SM(std::auto_ptr)ES( or )SM(std::unique_ptr)ES(, + depend)HY(ing)YH( on the C++ stan)HY(dard)YH( selected\202. Their signa)HY(tures)YH( + have the follow)HY(ing)YH( pattern \201)SM(type)ES( denotes + element's type and )SM(name)ES( denotes element's + name\202: + )EP( + + ) 2 28 PR(std::[auto|unique]_ptr<type> +name \201....\202;)RP( + + )0 P(The process of parsing, includ)HY(ing)YH( the exact signa)HY(tures)YH( of the parsing + func)HY(tions)YH(, is the subject of )0 64 1 A(Chapter 3, "Parsing")64 0 TN TL()Ec /AF f D(. + )EP( + + )0 P(The seri)HY(al)HY(iza)HY(tion)YH( func)HY(tions)YH( write object models back to XML instance + docu)HY(ments)YH(. Their signa)HY(tures)YH( have the follow)HY(ing)YH( pattern: + )EP( + + ) 2 41 PR(void +name \201<stream type>&, const type&, ....\202;)RP( + + )0 P(The process of seri)HY(al)HY(iza)HY(tion)YH(, includ)HY(ing)YH( the exact signa)HY(tures)YH( of the + seri)HY(al)HY(iza)HY(tion)YH( func)HY(tions)YH(, is the subject of )0 81 1 A(Chapter 4, + "Seri)HY(al)HY(iza)HY(tion)YH(")81 0 TN TL()Ec /AF f D(. + )EP( + + + )0 3 49 H(2.9.1)WB 146 Sn()WB 53 Sn( Element Types)EA()EH( + + )0 P(The gener)HY(a)HY(tion)YH( of element types is requested with the + )SM(--gener)HY(ate)YH(-element-map)ES( option. With this option + each global element is mapped to a C++ class with the + same name as the element. Such a class is derived from + )SM(xml_schema::element_type)ES( and contains the same set + of type defi)HY(ni)HY(tions)YH(, construc)HY(tors)YH(, and member func)HY(tion)YH( as would a + type contain)HY(ing)YH( a single element with the One cardi)HY(nal)HY(ity)YH( class + named )SM("value")ES(. In addi)HY(tion)YH(, the element type also + contains a set of member func)HY(tions)YH( for access)HY(ing)YH( the element + name and names)HY(pace)YH( as well as its value in a uniform manner. + For example:)EP( + + ) 7 34 PR(<complexType name="type"> + <sequence> + ... + </sequence> +</complexType> + +<element name="root" type="type"/>)RP( + +)0 P(is mapped to:)EP( + + ) 62 59 PR(class type +{ + ... +}; + +class root: public xml_schema::element_type +{ +public: + // Element value. + // + typedef type value_type; + + const value_type& + value \201\202 const; + + value_type& + value \201\202; + + void + value \201const value_type&\202; + + void + value \201std::[auto|unique]_ptr<value_type>\202; + + // Constructors. + // + root \201const value_type&\202; + + root \201std::[auto|unique]_ptr<value_type>\202; + + root \201const xercesc::DOMElement&, xml_schema::flags = 0\202;)WR( + + root \201const root&, xml_schema::flags = 0\202; + + virtual root* + _clone \201xml_schema::flags = 0\202 const; + + // Element name and namespace. + // + static const std::string& + name \201\202; + + static const std::string& + namespace_ \201\202; + + virtual const std::string& + _name \201\202 const; + + virtual const std::string& + _namespace \201\202 const; + + // Element value as xml_schema::type. + // + virtual const xml_schema::type* + _value \201\202 const; + + virtual xml_schema::type* + _value \201\202; +}; + +void)WR( +operator<< \201xercesc::DOMElement&, const root&\202;)RP( + + )0 P(The )SM(xml_schema::element_type)ES( class is a common + base type for all element types and is defined as follows:)EP( + + ) 24 39 PR(namespace xml_schema +{ + class element_type + { + public: + virtual + ~element_type \201\202; + + virtual element_type* + _clone \201flags f = 0\202 const = 0; + + virtual const std::basic_string<C>& + _name \201\202 const = 0; + + virtual const std::basic_string<C>& + _namespace \201\202 const = 0; + + virtual xml_schema::type* + _value \201\202 = 0; + + virtual const xml_schema::type* + _value \201\202 const = 0; + }; +})RP( + + )0 P(The )SM(_value\201\202)ES( member func)HY(tion)YH( returns a pointer to + the element value or 0 if the element is of a funda)HY(men)HY(tal)YH( C++ + type and there)HY(fore)YH( is not derived from )SM(xml_schema::type)ES(. + )EP( + + )0 P(Unlike parsing and seri)HY(al)HY(iza)HY(tion)YH( func)HY(tions)YH(, element types + are only capable of parsing and seri)HY(al)HY(iz)HY(ing)YH( from/to a + )SM(DOMEle)HY(ment)YH()ES( object. This means that the appli)HY(ca)HY(tion)YH( + will need to perform its own XML-to-DOM parsing and DOM-to-XML + seri)HY(al)HY(iza)HY(tion)YH(. The follow)HY(ing)YH( section describes a mech)HY(a)HY(nism)YH( + provided by the mapping to uniformly parse and seri)HY(al)HY(ize)YH( + multi)HY(ple)YH( root elements.)EP( + + + )0 3 50 H(2.9.2)WB 147 Sn()WB 54 Sn( Element Map)EA()EH( + + )0 P(When element types are gener)HY(ated)YH( for root elements it is also + possi)HY(ble)YH( to request the gener)HY(a)HY(tion)YH( of an element map with the + )SM(--gener)HY(ate)YH(-element-map)ES( option. The element map + allows uniform parsing and seri)HY(al)HY(iza)HY(tion)YH( of multi)HY(ple)YH( root + elements via the common )SM(xml_schema::element_type)ES( + base type. The )SM(xml_schema::element_map)ES( class is + defined as follows:)EP( + + ) 12 59 PR(namespace xml_schema +{ + class element_map + { + public: + static std::[auto|unique]_ptr<xml_schema::element_type> + parse \201const xercesc::DOMElement&, flags = 0\202; + + static void + serialize \201xercesc::DOMElement&, const element_type&\202; + }; +})RP( + + )0 P(The )SM(parse\201\202)ES( func)HY(tion)YH( creates the corre)HY(spond)HY(ing)YH( + element type object based on the element name and names)HY(pace)YH( + and returns it as an auto)HY(matic)YH( pointer \201)SM(std::auto_ptr)ES( + or )SM(std::unique_ptr)ES(, depend)HY(ing)YH( on the C++ stan)HY(dard)YH( + selected\202 to )SM(xml_schema::element_type)ES(. + The )SM(seri)HY(al)HY(ize)YH(\201\202)ES( func)HY(tion)YH( seri)HY(al)HY(izes)YH( the passed element + object to )SM(DOMEle)HY(ment)YH()ES(. Note that in case of + )SM(seri)HY(al)HY(ize)YH(\201\202)ES(, the )SM(DOMEle)HY(ment)YH()ES( object + should have the correct name and names)HY(pace)YH(. If no element type is + avail)HY(able)YH( for an element, both func)HY(tions)YH( throw the + )SM(xml_schema::no_element_info)ES( excep)HY(tion)YH(:)EP( + + ) 14 66 PR(struct no_element_info: virtual exception +{ + no_element_info \201const std::basic_string<C>& element_name, + const std::basic_string<C>& element_namespace\202; + + const std::basic_string<C>& + element_name \201\202 const; + + const std::basic_string<C>& + element_namespace \201\202 const; + + virtual const char* + what \201\202 const throw \201\202; +};)RP( + + )0 P(The appli)HY(ca)HY(tion)YH( can discover the actual type of the element + object returned by )SM(parse\201\202)ES( either using + )SM(dynamic_cast)ES( or by compar)HY(ing)YH( element names and + names)HY(paces)YH(. The follow)HY(ing)YH( code frag)HY(ments)YH( illus)HY(trate)YH( how the + element map can be used:)EP( + + ) 18 50 PR(// Parsing. +// +DOMElement& e = ... // Parse XML to DOM. + +auto_ptr<xml_schema::element_type> r \201 + xml_schema::element_map::parse \201e\202\202; + +if \201root1 r1 = dynamic_cast<root1*> \201r.get \201\202\202\202 +{ + ... +} +else if \201r->_name == root2::name \201\202 && + r->_namespace \201\202 == root2::namespace_ \201\202\202 +{ + root2& r2 \201static_cast<root2&> \201*r\202\202; + + ... +})RP( + + ) 13 68 PR(// Serialization. +// +xml_schema::element_type& r = ... + +string name \201r._name \201\202\202; +string ns \201r._namespace \201\202\202; + +DOMDocument& doc = ... // Create a new DOMDocument with name and ns. +DOMElement& e \201*doc->getDocumentElement \201\202\202; + +xml_schema::element_map::serialize \201e, r\202; + +// Serialize DOMDocument to XML.)RP( + + + + )0 2 51 H(2.10)WB 148 Sn()WB 55 Sn( Mapping for Global Attributes)EA()EH( + + )0 P(An XML Schema attribute defi)HY(ni)HY(tion)YH( is called global if it appears + directly under the )SM(schema)ES( element. A global + attribute does not have any mapping. + )EP( + + + + )0 2 52 H(2.11)WB 149 Sn()WB 56 Sn( Mapping for )SM(xsi:type)ES( and Substi)HY(tu)HY(tion)YH( + Groups)EA()EH( + + )0 P(The mapping provides optional support for the XML Schema poly)HY(mor)HY(phism)YH( + features \201)SM(xsi:type)ES( and substi)HY(tu)HY(tion)YH( groups\202 which can + be requested with the )SM(--gener)HY(ate)YH(-poly)HY(mor)HY(phic)YH()ES( option. + When used, the dynamic type of a member may be differ)HY(ent)YH( from + its static type. Consider the follow)HY(ing)YH( schema defi)HY(ni)HY(tion)YH( and + instance docu)HY(ment)YH(: + )EP( + + ) 28 62 PR(<!-- test.xsd --> +<schema> + <complexType name="base"> + <attribute name="text" type="string"/> + </complexType> + + <complexType name="derived"> + <complexContent> + <extension base="base"> + <attribute name="extra-text" type="string"/> + </extension> + </complexContent> + </complexType> + + <complexType name="root_type"> + <sequence> + <element name="item" type="base" maxOccurs="unbounded"/> + </sequence> + </complexType> + + <element name="root" type="root_type"/> +</schema> + +<!-- test.xml --> +<root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <item text="hello"/> + <item text="hello" extra-text="world" xsi:type="derived"/> +</root>)RP( + + )0 P(In the result)HY(ing)YH( object model, the container for + the )SM(root::item)ES( member will have two elements: + the first element's type will be )SM(base)ES( while + the second element's \201dynamic\202 type will be + )SM(derived)ES(. This can be discov)HY(ered)YH( using the + )SM(dynamic_cast)ES( oper)HY(a)HY(tor)YH( as shown in the follow)HY(ing)YH( + example: + )EP( + + ) 17 56 PR(void +f \201root& r\202 +{ + for \201root::item_const_iterator i \201r.item \201\202.begin \201\202\202; + i != r.item \201\202.end \201\202 + ++i\202 + { + if \201derived* d = dynamic_cast<derived*> \201&\201*i\202\202\202 + { + // derived + } + else + { + // base + } + } +})RP( + + )0 P(The )SM(_clone)ES( virtual func)HY(tion)YH( should be used instead of + copy construc)HY(tors)YH( to make copies of members that might use + poly)HY(mor)HY(phism)YH(: + )EP( + + ) 10 56 PR(void +f \201root& r\202 +{ + for \201root::item_const_iterator i \201r.item \201\202.begin \201\202\202; + i != r.item \201\202.end \201\202 + ++i\202 + { + std::auto_ptr<base> c \201i->_clone \201\202\202; + } +})RP( + + )0 P(The mapping can often auto)HY(mat)HY(i)HY(cally)YH( deter)HY(mine)YH( which types are + poly)HY(mor)HY(phic)YH( based on the substi)HY(tu)HY(tion)YH( group decla)HY(ra)HY(tions)YH(. However, + if your XML vocab)HY(u)HY(lary)YH( is not using substi)HY(tu)HY(tion)YH( groups or if + substi)HY(tu)HY(tion)YH( groups are defined in a sepa)HY(rate)YH( schema, then you will + need to use the )SM(--poly)HY(mor)HY(phic)YH(-type)ES( option to specify + which types are poly)HY(mor)HY(phic)YH(. When using this option you only need + to specify the root of a poly)HY(mor)HY(phic)YH( type hier)HY(ar)HY(chy)YH( and the mapping + will assume that all the derived types are also poly)HY(mor)HY(phic)YH(. + Also note that you need to specify this option when compil)HY(ing)YH( every + schema file that refer)HY(ences)YH( the poly)HY(mor)HY(phic)YH( type. Consider the follow)HY(ing)YH( + two schemas as an example:)EP( + + ) 13 55 PR(<!-- base.xsd --> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> + + <xs:complexType name="base"> + <xs:sequence> + <xs:element name="b" type="xs:int"/> + </xs:sequence> + </xs:complexType> + + <!-- substitution group root --> + <xs:element name="base" type="base"/> + +</xs:schema>)RP( + + ) 18 70 PR(<!-- derived.xsd --> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> + + <include schemaLocation="base.xsd"/> + + <xs:complexType name="derived"> + <xs:complexContent> + <xs:extension base="base"> + <xs:sequence> + <xs:element name="d" type="xs:string"/> + </xs:sequence> + </xs:extension> + </xs:complexContent> + </xs:complexType> + + <xs:element name="derived" type="derived" substitutionGroup="base"/> + +</xs:schema>)RP( + + )0 P(In this example we need to specify ")SM(--poly)HY(mor)HY(phic)YH(-type base)ES(" + when compil)HY(ing)YH( both schemas because the substi)HY(tu)HY(tion)YH( group is declared + in a schema other than the one defin)HY(ing)YH( type )SM(base)ES(.)EP( + + )0 P(You can also indi)HY(cate)YH( that all types should be treated as poly)HY(mor)HY(phic)YH( + with the )SM(--poly)HY(mor)HY(phic)YH(-type-all)ES(. However, this may result + in slower gener)HY(ated)YH( code with a greater foot)HY(print)YH(.)EP( + + + + + + )0 2 53 H(2.12)WB 150 Sn()WB 57 Sn( Mapping for )SM(any)ES( and )SM(anyAt)HY(tribute)YH()ES()EA()EH( + + )0 P(For the XML Schema )SM(any)ES( and )SM(anyAt)HY(tribute)YH()ES( + wild)HY(cards)YH( an optional mapping can be requested with the + )SM(--gener)HY(ate)YH(-wild)HY(card)YH()ES( option. The mapping repre)HY(sents)YH( + the content matched by wild)HY(cards)YH( as DOM frag)HY(ments)YH(. Because the + DOM API is used to access such content, the Xerces-C++ runtime + should be initial)HY(ized)YH( by the appli)HY(ca)HY(tion)YH( prior to parsing and + should remain initial)HY(ized)YH( for the life)HY(time)YH( of objects with + the wild)HY(card)YH( content. For more infor)HY(ma)HY(tion)YH( on the Xerces-C++ + runtime initial)HY(iza)HY(tion)YH( see )0 65 1 A(Section 3.1, + "Initial)HY(iz)HY(ing)YH( the Xerces-C++ Runtime")65 0 TN TL()Ec /AF f D(. + )EP( + + )0 P(The mapping for )SM(any)ES( is similar to the mapping for + local elements \201see )0 47 1 A(Section 2.8, "Mapping for Local + Elements and Attributes")47 0 TN TL()Ec /AF f D(\202 except that the type used in the + wild)HY(card)YH( mapping is )SM(xercesc::DOMEle)HY(ment)YH()ES(. As with local + elements, the mapping divides all possi)HY(ble)YH( cardi)HY(nal)HY(ity)YH( combi)HY(na)HY(tions)YH( + into three cardi)HY(nal)HY(ity)YH( classes: )I(one)ES(, )I(optional)ES(, and + )I(sequence)ES(. + )EP( + + )0 P(The mapping for )SM(anyAt)HY(tribute)YH()ES( repre)HY(sents)YH( the attributes + matched by this wild)HY(card)YH( as a set of )SM(xercesc::DOMAttr)ES( + objects with a key being the attribute's name and names)HY(pace)YH(.)EP( + + )0 P(Similar to local elements and attributes, the )SM(any)ES( and + )SM(anyAt)HY(tribute)YH()ES( wild)HY(cards)YH( are mapped to a set of public type + defi)HY(ni)HY(tions)YH( \201type)HY(defs)YH(\202 and a set of public acces)HY(sor)YH( and modi)HY(fier)YH( + func)HY(tions)YH(. Type defi)HY(ni)HY(tions)YH( have names derived from )SM("any")ES( + for the )SM(any)ES( wild)HY(card)YH( and )SM("any_attribute")ES( + for the )SM(anyAt)HY(tribute)YH()ES( wild)HY(card)YH(. The acces)HY(sor)YH( and modi)HY(fier)YH( + func)HY(tions)YH( are named )SM("any")ES( for the )SM(any)ES( wild)HY(card)YH( + and )SM("any_attribute")ES( for the )SM(anyAt)HY(tribute)YH()ES( + wild)HY(card)YH(. Subse)HY(quent)YH( wild)HY(cards)YH( in the same type have escaped names + such as )SM("any1")ES( or )SM("any_attribute1")ES(. + )EP( + + )0 P(Because Xerces-C++ DOM nodes always belong to a )SM(DOMDoc)HY(u)HY(ment)YH()ES(, + each type with a wild)HY(card)YH( has an asso)HY(ci)HY(ated)YH( )SM(DOMDoc)HY(u)HY(ment)YH()ES( + object. The refer)HY(ence)YH( to this object can be obtained using the acces)HY(sor)YH( + func)HY(tion)YH( called )SM(dom_docu)HY(ment)YH()ES(. The access to the docu)HY(ment)YH( + object from the appli)HY(ca)HY(tion)YH( code may be neces)HY(sary)YH( to create or modify + the wild)HY(card)YH( content. For example: + )EP( + + ) 6 37 PR(<complexType name="object"> + <sequence> + <any namespace="##other"/> + </sequence> + <anyAttribute namespace="##other"/> +</complexType>)RP( + + )0 P(is mapped to:)EP( + + ) 37 73 PR(class object: public xml_schema::type +{ +public: + // any + // + const xercesc::DOMElement& + any \201\202 const; + + void + any \201const xercesc::DOMElement&\202; + + ... + + // any_attribute + // + typedef attribute_set any_attribute_set; + typedef any_attribute_set::iterator any_attribute_iterator; + typedef any_attribute_set::const_iterator any_attribute_const_iterator; + + const any_attribute_set& + any_attribute \201\202 const; + + any_attribute_set& + any_attribute \201\202; + + ... + + // DOMDocument object for wildcard content. + // + const xercesc::DOMDocument& + dom_document \201\202 const;)WR( + + xercesc::DOMDocument& + dom_document \201\202; + + ... +};)RP( + + + )0 P(Names and seman)HY(tics)YH( of type defi)HY(ni)HY(tions)YH( for the wild)HY(cards)YH( as well + as signa)HY(tures)YH( of the acces)HY(sor)YH( and modi)HY(fier)YH( func)HY(tions)YH( depend on the + wild)HY(card)YH( type as well as the cardi)HY(nal)HY(ity)YH( class for the )SM(any)ES( + wild)HY(card)YH(. They are described in the follow)HY(ing)YH( sub-sections. + )EP( + + + )0 3 54 H(2.12.1)WB 151 Sn()WB 58 Sn( Mapping for )SM(any)ES( with the One Cardi)HY(nal)HY(ity)YH( Class)EA()EH( + + )0 P(For )SM(any)ES( with the One cardi)HY(nal)HY(ity)YH( class, + there are no type defi)HY(ni)HY(tions)YH(. The acces)HY(sor)YH( func)HY(tions)YH( come in + constant and non-constant versions. The constant acces)HY(sor)YH( func)HY(tion)YH( + returns a constant refer)HY(ence)YH( to )SM(xercesc::DOMEle)HY(ment)YH()ES( and + can be used for read-only access. The non-constant version returns + an unre)HY(stricted)YH( refer)HY(ence)YH( to )SM(xercesc::DOMEle)HY(ment)YH()ES( and can + be used for read-write access. + )EP( + + )0 P(The first modi)HY(fier)YH( func)HY(tion)YH( expects an argu)HY(ment)YH( of type refer)HY(ence)YH( + to constant )SM(xercesc::DOMEle)HY(ment)YH()ES( and makes a deep copy + of its argu)HY(ment)YH(. The second modi)HY(fier)YH( func)HY(tion)YH( expects an argu)HY(ment)YH( of + type pointer to )SM(xercesc::DOMEle)HY(ment)YH()ES(. This modi)HY(fier)YH( + func)HY(tion)YH( assumes owner)HY(ship)YH( of its argu)HY(ment)YH( and expects the element + object to be created using the DOM docu)HY(ment)YH( asso)HY(ci)HY(ated)YH( with this + instance. For example: + )EP( + + ) 5 30 PR(<complexType name="object"> + <sequence> + <any namespace="##other"/> + </sequence> +</complexType>)RP( + + )0 P(is mapped to:)EP( + + ) 22 37 PR(class object: public xml_schema::type +{ +public: + // Accessors. + // + const xercesc::DOMElement& + any \201\202 const; + + xercesc::DOMElement& + any \201\202; + + // Modifiers. + // + void + any \201const xercesc::DOMElement&\202; + + void + any \201xercesc::DOMElement*\202; + + ... + +};)RP( + + + )0 P(The follow)HY(ing)YH( code shows how one could use this mapping:)EP( + + ) 10 66 PR(void +f \201object& o, const xercesc::DOMElement& e\202 +{ + using namespace xercesc; + + DOMElement& e1 \201o.any \201\202\202; // get + o.any \201e\202 // set, deep copy + DOMDocument& doc \201o.dom_document \201\202\202; + o.any \201doc.createElement \201...\202\202; // set, assumes ownership +})RP( + + )0 3 55 H(2.12.2)WB 152 Sn()WB 59 Sn( Mapping for )SM(any)ES( with the Optional Cardi)HY(nal)HY(ity)YH( Class)EA()EH( + + )0 P(For )SM(any)ES( with the Optional cardi)HY(nal)HY(ity)YH( class, the type + defi)HY(ni)HY(tions)YH( consist of an alias for the container type with name + )SM(any_optional)ES( \201or )SM(any1_optional)ES(, etc., for + subse)HY(quent)YH( wild)HY(cards)YH( in the type defi)HY(ni)HY(tion)YH(\202. + )EP( + + )0 P(Unlike acces)HY(sor)YH( func)HY(tions)YH( for the One cardi)HY(nal)HY(ity)YH( class, acces)HY(sor)YH( + func)HY(tions)YH( for the Optional cardi)HY(nal)HY(ity)YH( class return refer)HY(ences)YH( to + corre)HY(spond)HY(ing)YH( contain)HY(ers)YH( rather than directly to )SM(DOMEle)HY(ment)YH()ES(. + The acces)HY(sor)YH( func)HY(tions)YH( come in constant and non-constant versions. + The constant acces)HY(sor)YH( func)HY(tion)YH( returns a constant refer)HY(ence)YH( to + the container and can be used for read-only access. The non-constant + version returns an unre)HY(stricted)YH( refer)HY(ence)YH( to the container + and can be used for read-write access. + )EP( + + )0 P(The modi)HY(fier)YH( func)HY(tions)YH( are over)HY(loaded)YH( for )SM(xercesc::DOMEle)HY(ment)YH()ES( + and the container type. The first modi)HY(fier)YH( func)HY(tion)YH( expects an argu)HY(ment)YH( of + type refer)HY(ence)YH( to constant )SM(xercesc::DOMEle)HY(ment)YH()ES( and + makes a deep copy of its argu)HY(ment)YH(. The second modi)HY(fier)YH( func)HY(tion)YH( + expects an argu)HY(ment)YH( of type pointer to )SM(xercesc::DOMEle)HY(ment)YH()ES(. + This modi)HY(fier)YH( func)HY(tion)YH( assumes owner)HY(ship)YH( of its argu)HY(ment)YH( and expects + the element object to be created using the DOM docu)HY(ment)YH( asso)HY(ci)HY(ated)YH( + with this instance. The third modi)HY(fier)YH( func)HY(tion)YH( expects an argu)HY(ment)YH( + of type refer)HY(ence)YH( to constant of the container type and makes a + deep copy of its argu)HY(ment)YH(. For instance: + )EP( + + ) 5 44 PR(<complexType name="object"> + <sequence> + <any namespace="##other" minOccurs="0"/> + </sequence> +</complexType>)RP( + + )0 P(is mapped to:)EP( + + ) 29 40 PR(class object: public xml_schema::type +{ +public: + // Type definitions. + // + typedef element_optional any_optional; + + // Accessors. + // + const any_optional& + any \201\202 const; + + any_optional& + any \201\202; + + // Modifiers. + // + void + any \201const xercesc::DOMElement&\202; + + void + any \201xercesc::DOMElement*\202; + + void + any \201const any_optional&\202; + + ... + +};)RP( + + + )0 P(The )SM(element_optional)ES( container is a + special)HY(iza)HY(tion)YH( of the )SM(optional)ES( class template described + in )0 49 1 A(Section 2.8.2, "Mapping for Members with the Optional + Cardi)HY(nal)HY(ity)YH( Class")49 0 TN TL()Ec /AF f D(. Its inter)HY(face)YH( is presented below: + )EP( + + ) 72 71 PR(class element_optional +{ +public: + explicit + element_optional \201xercesc::DOMDocument&\202; + + // Makes a deep copy. + // + element_optional \201const xercesc::DOMElement&, xercesc::DOMDocument&\202; + + // Assumes ownership. + // + element_optional \201xercesc::DOMElement*, xercesc::DOMDocument&\202; + + element_optional \201const element_optional&, xercesc::DOMDocument&\202; + +public: + element_optional& + operator= \201const xercesc::DOMElement&\202; + + element_optional& + operator= \201const element_optional&\202; + + // Pointer-like interface. + // +public: + const xercesc::DOMElement* + operator-> \201\202 const; + + xercesc::DOMElement* + operator-> \201\202;)WR( + + const xercesc::DOMElement& + operator* \201\202 const; + + xercesc::DOMElement& + operator* \201\202; + + typedef void \201element_optional::*bool_convertible\202 \201\202; + operator bool_convertible \201\202 const; + + // Get/set interface. + // +public: + bool + present \201\202 const; + + const xercesc::DOMElement& + get \201\202 const; + + xercesc::DOMElement& + get \201\202; + + // Makes a deep copy. + // + void + set \201const xercesc::DOMElement&\202; + + // Assumes ownership. + // + void)WR( + set \201xercesc::DOMElement*\202; + + void + reset \201\202; +}; + +bool +operator== \201const element_optional&, const element_optional&\202; + +bool +operator!= \201const element_optional&, const element_optional&\202;)RP( + + + )0 P(The follow)HY(ing)YH( code shows how one could use this mapping:)EP( + + ) 25 69 PR(void +f \201object& o, const xercesc::DOMElement& e\202 +{ + using namespace xercesc; + + DOMDocument& doc \201o.dom_document \201\202\202; + + if \201o.any \201\202.present \201\202\202 // test + { + DOMElement& e1 \201o.any \201\202.get \201\202\202; // get + o.any \201\202.set \201e\202; // set, deep copy + o.any \201\202.set \201doc.createElement \201...\202\202; // set, assumes ownership + o.any \201\202.reset \201\202; // reset + } + + // Same as above but using pointer notation: + // + if \201o.member \201\202\202 // test + { + DOMElement& e1 \201*o.any \201\202\202; // get + o.any \201e\202; // set, deep copy + o.any \201doc.createElement \201...\202\202; // set, assumes ownership + o.any \201\202.reset \201\202; // reset + } +})RP( + + + + )0 3 56 H(2.12.3)WB 153 Sn()WB 60 Sn( Mapping for )SM(any)ES( with the Sequence Cardi)HY(nal)HY(ity)YH( Class)EA()EH( + + )0 P(For )SM(any)ES( with the Sequence cardi)HY(nal)HY(ity)YH( class, the type + defi)HY(ni)HY(tions)YH( consist of an alias of the container type with name + )SM(any_sequence)ES( \201or )SM(any1_sequence)ES(, etc., for + subse)HY(quent)YH( wild)HY(cards)YH( in the type defi)HY(ni)HY(tion)YH(\202, an alias of the iter)HY(a)HY(tor)YH( + type with name )SM(any_iter)HY(a)HY(tor)YH()ES( \201or )SM(any1_iter)HY(a)HY(tor)YH()ES(, + etc., for subse)HY(quent)YH( wild)HY(cards)YH( in the type defi)HY(ni)HY(tion)YH(\202, and an alias + of the constant iter)HY(a)HY(tor)YH( type with name )SM(any_const_iter)HY(a)HY(tor)YH()ES( + \201or )SM(any1_const_iter)HY(a)HY(tor)YH()ES(, etc., for subse)HY(quent)YH( wild)HY(cards)YH( + in the type defi)HY(ni)HY(tion)YH(\202. + )EP( + + )0 P(The acces)HY(sor)YH( func)HY(tions)YH( come in constant and non-constant versions. + The constant acces)HY(sor)YH( func)HY(tion)YH( returns a constant refer)HY(ence)YH( to the + container and can be used for read-only access. The non-constant + version returns an unre)HY(stricted)YH( refer)HY(ence)YH( to the container and can + be used for read-write access. + )EP( + + )0 P(The modi)HY(fier)YH( func)HY(tion)YH( expects an argu)HY(ment)YH( of type refer)HY(ence)YH( to + constant of the container type. The modi)HY(fier)YH( func)HY(tion)YH( makes + a deep copy of its argu)HY(ment)YH(. For instance: + )EP( + + + ) 5 52 PR(<complexType name="object"> + <sequence> + <any namespace="##other" minOccurs="unbounded"/> + </sequence> +</complexType>)RP( + + )0 P(is mapped to:)EP( + + ) 25 58 PR(class object: public xml_schema::type +{ +public: + // Type definitions. + // + typedef element_sequence any_sequence; + typedef any_sequence::iterator any_iterator; + typedef any_sequence::const_iterator any_const_iterator; + + // Accessors. + // + const any_sequence& + any \201\202 const; + + any_sequence& + any \201\202; + + // Modifier. + // + void + any \201const any_sequence&\202; + + ... + +};)RP( + + )0 P(The )SM(element_sequence)ES( container is a + special)HY(iza)HY(tion)YH( of the )SM(sequence)ES( class template described + in )0 50 1 A(Section 2.8.3, "Mapping for Members with the + Sequence Cardi)HY(nal)HY(ity)YH( Class")50 0 TN TL()Ec /AF f D(. Its inter)HY(face)YH( is similar to + the sequence inter)HY(face)YH( as defined by the ISO/ANSI Stan)HY(dard)YH( for + C++ \201ISO/IEC 14882:1998, Section 23.1.1, "Sequences"\202 and is + presented below: + )EP( + + ) 178 70 PR(class element_sequence +{ +public: + typedef xercesc::DOMElement value_type; + typedef xercesc::DOMElement* pointer; + typedef const xercesc::DOMElement* const_pointer; + typedef xercesc::DOMElement& reference; + typedef const xercesc::DOMElement& const_reference; + + typedef <implementation-defined> iterator; + typedef <implementation-defined> const_iterator; + typedef <implementation-defined> reverse_iterator; + typedef <implementation-defined> const_reverse_iterator; + + typedef <implementation-defined> size_type; + typedef <implementation-defined> difference_type; + typedef <implementation-defined> allocator_type; + +public: + explicit + element_sequence \201xercesc::DOMDocument&\202; + + // DOMElement cannot be default-constructed. + // + // explicit + // element_sequence \201size_type n\202; + + element_sequence \201size_type n, + const xercesc::DOMElement&, + xercesc::DOMDocument&\202; +)WR( + template <typename I> + element_sequence \201const I& begin, + const I& end, + xercesc::DOMDocument&\202; + + element_sequence \201const element_sequence&, xercesc::DOMDocument&\202; + + element_sequence& + operator= \201const element_sequence&\202; + +public: + void + assign \201size_type n, const xercesc::DOMElement&\202; + + template <typename I> + void + assign \201const I& begin, const I& end\202; + +public: + // This version of resize can only be used to shrink the + // sequence because DOMElement cannot be default-constructed. + // + void + resize \201size_type\202; + + void + resize \201size_type, const xercesc::DOMElement&\202; + +public: + size_type)WR( + size \201\202 const; + + size_type + max_size \201\202 const; + + size_type + capacity \201\202 const; + + bool + empty \201\202 const; + + void + reserve \201size_type\202; + + void + clear \201\202; + +public: + const_iterator + begin \201\202 const; + + const_iterator + end \201\202 const; + + iterator + begin \201\202; + + iterator + end \201\202; +)WR( + const_reverse_iterator + rbegin \201\202 const; + + const_reverse_iterator + rend \201\202 const + + reverse_iterator + rbegin \201\202; + + reverse_iterator + rend \201\202; + +public: + xercesc::DOMElement& + operator[] \201size_type\202; + + const xercesc::DOMElement& + operator[] \201size_type\202 const; + + xercesc::DOMElement& + at \201size_type\202; + + const xercesc::DOMElement& + at \201size_type\202 const; + + xercesc::DOMElement& + front \201\202; + + const xercesc::DOMElement& + front \201\202 const;)WR( + + xercesc::DOMElement& + back \201\202; + + const xercesc::DOMElement& + back \201\202 const; + +public: + // Makes a deep copy. + // + void + push_back \201const xercesc::DOMElement&\202; + + // Assumes ownership. + // + void + push_back \201xercesc::DOMElement*\202; + + void + pop_back \201\202; + + // Makes a deep copy. + // + iterator + insert \201iterator position, const xercesc::DOMElement&\202; + + // Assumes ownership. + // + iterator + insert \201iterator position, xercesc::DOMElement*\202;)WR( + + void + insert \201iterator position, size_type n, const xercesc::DOMElement&\202; + + template <typename I> + void + insert \201iterator position, const I& begin, const I& end\202; + + iterator + erase \201iterator position\202; + + iterator + erase \201iterator begin, iterator end\202; + +public: + // Note that the DOMDocument object of the two sequences being + // swapped should be the same. + // + void + swap \201sequence& x\202; +}; + +inline bool +operator== \201const element_sequence&, const element_sequence&\202; + +inline bool +operator!= \201const element_sequence&, const element_sequence&\202;)RP( + + + )0 P(The follow)HY(ing)YH( code shows how one could use this mapping:)EP( + + ) 20 63 PR(void +f \201object& o, const xercesc::DOMElement& e\202 +{ + using namespace xercesc; + + object::any_sequence& s \201o.any \201\202\202; + + // Iteration. + // + for \201object::any_iterator i \201s.begin \201\202\202; i != s.end \201\202; ++i\202 + { + DOMElement& e \201*i\202; + } + + // Modification. + // + s.push_back \201e\202; // deep copy + DOMDocument& doc \201o.dom_document \201\202\202; + s.push_back \201doc.createElement \201...\202\202; // assumes ownership +})RP( + + )0 3 57 H(2.12.4)WB 154 Sn()WB 61 Sn( Element Wild)HY(card)YH( Order)EA()EH( + + )0 P(Similar to elements, element wild)HY(cards)YH( in ordered types + \201)0 51 1 A(Section 2.8.4, "Element Order")51 0 TN TL()Ec /AF f D(\202 are assigned + content ids and are included in the content order sequence. + Contin)HY(u)HY(ing)YH( with the bank trans)HY(ac)HY(tions)YH( example started in Section + 2.8.4, we can extend the batch by allow)HY(ing)YH( custom trans)HY(ac)HY(tions)YH(:)EP( + + ) 7 52 PR(<complexType name="batch"> + <choice minOccurs="0" maxOccurs="unbounded"> + <element name="withdraw" type="withdraw"/> + <element name="deposit" type="deposit"/> + <any namespace="##other" processContents="lax"/> + </choice> +</complexType>)RP( + + )0 P(This will lead to the follow)HY(ing)YH( changes in the gener)HY(ated)YH( + )SM(batch)ES( C++ class:)EP( + + ) 24 58 PR(class batch: public xml_schema::type +{ +public: + ... + + // any + // + typedef element_sequence any_sequence; + typedef any_sequence::iterator any_iterator; + typedef any_sequence::const_iterator any_const_iterator; + + static const std::size_t any_id = 3UL; + + const any_sequence& + any \201\202 const; + + any_sequence& + any \201\202; + + void + any \201const any_sequence&\202; + + ... +};)RP( + + )0 P(With this change we also need to update the iter)HY(a)HY(tion)YH( code to handle + the new content id:)EP( + + ) 18 73 PR(for \201batch::content_order_const_iterator i \201b.content_order \201\202.begin \201\202\202; + i != b.content_order \201\202.end \201\202; + ++i\202 +{ + switch \201i->id\202 + { + ... + + case batch::any_id: + { + const DOMElement& e \201b.any \201\202[i->index]\202; + ... + break; + } + + ... + } +})RP( + + )0 P(For the complete working code that shows the use of wild)HY(cards)YH( in + ordered types refer to the )SM(order/element)ES( example in + the )SM(exam)HY(ples)YH(/cxx/tree/)ES( direc)HY(tory)YH( in the XSD + distri)HY(bu)HY(tion)YH(.)EP( + + )0 3 58 H(2.12.5)WB 155 Sn()WB 62 Sn( Mapping for )SM(anyAt)HY(tribute)YH()ES()EA()EH( + + )0 P(For )SM(anyAt)HY(tribute)YH()ES( the type defi)HY(ni)HY(tions)YH( consist of an alias + of the container type with name )SM(any_attribute_set)ES( + \201or )SM(any1_attribute_set)ES(, etc., for subse)HY(quent)YH( wild)HY(cards)YH( + in the type defi)HY(ni)HY(tion)YH(\202, an alias of the iter)HY(a)HY(tor)YH( type with name + )SM(any_attribute_iter)HY(a)HY(tor)YH()ES( \201or )SM(any1_attribute_iter)HY(a)HY(tor)YH()ES(, + etc., for subse)HY(quent)YH( wild)HY(cards)YH( in the type defi)HY(ni)HY(tion)YH(\202, and an alias + of the constant iter)HY(a)HY(tor)YH( type with name )SM(any_attribute_const_iter)HY(a)HY(tor)YH()ES( + \201or )SM(any1_attribute_const_iter)HY(a)HY(tor)YH()ES(, etc., for subse)HY(quent)YH( + wild)HY(cards)YH( in the type defi)HY(ni)HY(tion)YH(\202. + )EP( + + )0 P(The acces)HY(sor)YH( func)HY(tions)YH( come in constant and non-constant versions. + The constant acces)HY(sor)YH( func)HY(tion)YH( returns a constant refer)HY(ence)YH( to the + container and can be used for read-only access. The non-constant + version returns an unre)HY(stricted)YH( refer)HY(ence)YH( to the container and can + be used for read-write access. + )EP( + + )0 P(The modi)HY(fier)YH( func)HY(tion)YH( expects an argu)HY(ment)YH( of type refer)HY(ence)YH( to + constant of the container type. The modi)HY(fier)YH( func)HY(tion)YH( makes + a deep copy of its argu)HY(ment)YH(. For instance: + )EP( + + + ) 6 37 PR(<complexType name="object"> + <sequence> + ... + </sequence> + <anyAttribute namespace="##other"/> +</complexType>)RP( + + )0 P(is mapped to:)EP( + + ) 25 73 PR(class object: public xml_schema::type +{ +public: + // Type definitions. + // + typedef attribute_set any_attribute_set; + typedef any_attribute_set::iterator any_attribute_iterator; + typedef any_attribute_set::const_iterator any_attribute_const_iterator; + + // Accessors. + // + const any_attribute_set& + any_attribute \201\202 const; + + any_attribute_set& + any_attribute \201\202; + + // Modifier. + // + void + any_attribute \201const any_attribute_set&\202; + + ... + +};)RP( + + )0 P(The )SM(attribute_set)ES( class is an asso)HY(cia)HY(tive)YH( container + similar to the )SM(std::set)ES( class template as defined by + the ISO/ANSI Stan)HY(dard)YH( for C++ \201ISO/IEC 14882:1998, Section 23.3.3, + "Class template set"\202 with the key being the attribute's name + and names)HY(pace)YH(. Unlike )SM(std::set)ES(, )SM(attribute_set)ES( + allows search)HY(ing)YH( using names and names)HY(paces)YH( instead of + )SM(xercesc::DOMAttr)ES( objects. It is defined in an + imple)HY(men)HY(ta)HY(tion)YH(-specific names)HY(pace)YH( and its inter)HY(face)YH( is presented + below: + )EP( + + ) 166 70 PR(class attribute_set +{ +public: + typedef xercesc::DOMAttr key_type; + typedef xercesc::DOMAttr value_type; + typedef xercesc::DOMAttr* pointer; + typedef const xercesc::DOMAttr* const_pointer; + typedef xercesc::DOMAttr& reference; + typedef const xercesc::DOMAttr& const_reference; + + typedef <implementation-defined> iterator; + typedef <implementation-defined> const_iterator; + typedef <implementation-defined> reverse_iterator; + typedef <implementation-defined> const_reverse_iterator; + + typedef <implementation-defined> size_type; + typedef <implementation-defined> difference_type; + typedef <implementation-defined> allocator_type; + +public: + attribute_set \201xercesc::DOMDocument&\202; + + template <typename I> + attribute_set \201const I& begin, const I& end, xercesc::DOMDocument&\202; + + attribute_set \201const attribute_set&, xercesc::DOMDocument&\202; + + attribute_set& + operator= \201const attribute_set&\202; + +public:)WR( + const_iterator + begin \201\202 const; + + const_iterator + end \201\202 const; + + iterator + begin \201\202; + + iterator + end \201\202; + + const_reverse_iterator + rbegin \201\202 const; + + const_reverse_iterator + rend \201\202 const; + + reverse_iterator + rbegin \201\202; + + reverse_iterator + rend \201\202; + +public: + size_type + size \201\202 const; + + size_type + max_size \201\202 const;)WR( + + bool + empty \201\202 const; + + void + clear \201\202; + +public: + // Makes a deep copy. + // + std::pair<iterator, bool> + insert \201const xercesc::DOMAttr&\202; + + // Assumes ownership. + // + std::pair<iterator, bool> + insert \201xercesc::DOMAttr*\202; + + // Makes a deep copy. + // + iterator + insert \201iterator position, const xercesc::DOMAttr&\202; + + // Assumes ownership. + // + iterator + insert \201iterator position, xercesc::DOMAttr*\202; + + template <typename I> + void)WR( + insert \201const I& begin, const I& end\202; + +public: + void + erase \201iterator position\202; + + size_type + erase \201const std::basic_string<C>& name\202; + + size_type + erase \201const std::basic_string<C>& namespace_, + const std::basic_string<C>& name\202; + + size_type + erase \201const XMLCh* name\202; + + size_type + erase \201const XMLCh* namespace_, const XMLCh* name\202; + + void + erase \201iterator begin, iterator end\202; + +public: + size_type + count \201const std::basic_string<C>& name\202 const; + + size_type + count \201const std::basic_string<C>& namespace_, + const std::basic_string<C>& name\202 const; +)WR( + size_type + count \201const XMLCh* name\202 const; + + size_type + count \201const XMLCh* namespace_, const XMLCh* name\202 const; + + iterator + find \201const std::basic_string<C>& name\202; + + iterator + find \201const std::basic_string<C>& namespace_, + const std::basic_string<C>& name\202; + + iterator + find \201const XMLCh* name\202; + + iterator + find \201const XMLCh* namespace_, const XMLCh* name\202; + + const_iterator + find \201const std::basic_string<C>& name\202 const; + + const_iterator + find \201const std::basic_string<C>& namespace_, + const std::basic_string<C>& name\202 const; + + const_iterator + find \201const XMLCh* name\202 const; + + const_iterator)WR( + find \201const XMLCh* namespace_, const XMLCh* name\202 const; + +public: + // Note that the DOMDocument object of the two sets being + // swapped should be the same. + // + void + swap \201attribute_set&\202; +}; + +bool +operator== \201const attribute_set&, const attribute_set&\202; + +bool +operator!= \201const attribute_set&, const attribute_set&\202;)RP( + + )0 P(The follow)HY(ing)YH( code shows how one could use this mapping:)EP( + + ) 25 73 PR(void +f \201object& o, const xercesc::DOMAttr& a\202 +{ + using namespace xercesc; + + object::any_attribute_set& s \201o.any_attribute \201\202\202; + + // Iteration. + // + for \201object::any_attribute_iterator i \201s.begin \201\202\202; i != s.end \201\202; ++i\202 + { + DOMAttr& a \201*i\202; + } + + // Modification. + // + s.insert \201a\202; // deep copy + DOMDocument& doc \201o.dom_document \201\202\202; + s.insert \201doc.createAttribute \201...\202\202; // assumes ownership + + // Searching. + // + object::any_attribute_iterator i \201s.find \201"name"\202\202; + i = s.find \201"http://www.w3.org/XML/1998/namespace", "lang"\202; +})RP( + + + + )0 2 59 H(2.13)WB 156 Sn()WB 63 Sn( Mapping for Mixed Content Models)EA()EH( + + )0 P(For XML Schema types with mixed content models C++/Tree provides + mapping support only if the type is marked as ordered + \201)0 51 1 A(Section 2.8.4, "Element Order")51 0 TN TL()Ec /AF f D(\202. Use the + )SM(--ordered-type-mixed)ES( XSD compiler option to + auto)HY(mat)HY(i)HY(cally)YH( mark all types with mixed content as ordered.)EP( + + )0 P(For an ordered type with mixed content, C++/Tree adds an extra + text content sequence that is used to store the text frag)HY(ments)YH(. + This text content sequence is also assigned the content id and + its entries are included in the content order sequence, just + like elements. As a result, it is possi)HY(ble)YH( to capture the order + between elements and text frag)HY(ments)YH(.)EP( + + )0 P(As an example, consider the follow)HY(ing)YH( schema that describes text + with embed)HY(ded)YH( links:)EP( + + ) 13 73 PR(<complexType name="anchor"> + <simpleContent> + <extension base="string"> + <attribute name="href" type="anyURI" use="required"/> + </extension> + </simpleContent> +</complexType> + +<complexType name="text" mixed="true"> + <sequence> + <element name="a" type="anchor" minOccurs="0" maxOccurs="unbounded"/> + </sequence> +</complexType>)RP( + + )0 P(The gener)HY(ated)YH( )SM(text)ES( C++ class will provide the follow)HY(ing)YH( + API \201assum)HY(ing)YH( it is marked as ordered\202:)EP( + + ) 57 78 PR(class text: public xml_schema::type +{ +public: + // a + // + typedef anchor a_type; + typedef sequence<a_type> a_sequence; + typedef a_sequence::iterator a_iterator; + typedef a_sequence::const_iterator a_const_iterator; + + static const std::size_t a_id = 1UL; + + const a_sequence& + a \201\202 const; + + a_sequence& + a \201\202; + + void + a \201const a_sequence&\202; + + // text_content + // + typedef xml_schema::string text_content_type; + typedef sequence<text_content_type> text_content_sequence; + typedef text_content_sequence::iterator text_content_iterator; + typedef text_content_sequence::const_iterator text_content_const_iterator; + + static const std::size_t text_content_id = 2UL; + + const text_content_sequence&)WR( + text_content \201\202 const; + + text_content_sequence& + text_content \201\202; + + void + text_content \201const text_content_sequence&\202; + + // content_order + // + typedef xml_schema::content_order content_order_type; + typedef std::vector<content_order_type> content_order_sequence; + typedef content_order_sequence::iterator content_order_iterator; + typedef content_order_sequence::const_iterator content_order_const_iterator; + + const content_order_sequence& + content_order \201\202 const; + + content_order_sequence& + content_order \201\202; + + void + content_order \201const content_order_sequence&\202; + + ... +};)RP( + + )0 P(Given this inter)HY(face)YH( we can iterate over both link elements + and text in content order. The follow)HY(ing)YH( code frag)HY(ment)YH( converts + our format to plain text with refer)HY(ences)YH(.)EP( + + ) 26 72 PR(const text& t = ... + +for \201text::content_order_const_iterator i \201t.content_order \201\202.begin \201\202\202; + i != t.content_order \201\202.end \201\202; + ++i\202 +{ + switch \201i->id\202 + { + case text::a_id: + { + const anchor& a \201t.a \201\202[i->index]\202; + cerr << a << "[" << a.href \201\202 << "]"; + break; + } + case text::text_content_id: + { + const xml_schema::string& s \201t.text_content \201\202[i->index]\202; + cerr << s; + break; + } + default: + { + assert \201false\202; // Unknown content id. + } + } +})RP( + + )0 P(For the complete working code that shows the use of mixed content + in ordered types refer to the )SM(order/mixed)ES( example in + the )SM(exam)HY(ples)YH(/cxx/tree/)ES( direc)HY(tory)YH( in the XSD + distri)HY(bu)HY(tion)YH(.)EP( + + + + + )0 1 60 H(3)WB 157 Sn()WB 64 Sn( Parsing)EA()EH( + + )0 P(This chapter covers various aspects of parsing XML instance + docu)HY(ments)YH( in order to obtain corre)HY(spond)HY(ing)YH( tree-like object + model. + )EP( + + )0 P(Each global XML Schema element in the form:)EP( + + ) 1 34 PR(<element name="name" type="type"/>)RP( + + )0 P(is mapped to 14 over)HY(loaded)YH( C++ func)HY(tions)YH( in the form:)EP( + + ) 96 65 PR(// Read from a URI or a local file. +// + +std::[auto|unique]_ptr<type> +name \201const std::basic_string<C>& uri, + xml_schema::flags = 0, + const xml_schema::properties& = xml_schema::properties \201\202\202; + +std::[auto|unique]_ptr<type> +name \201const std::basic_string<C>& uri, + xml_schema::error_handler&, + xml_schema::flags = 0, + const xml_schema::properties& = xml_schema::properties \201\202\202; + +std::[auto|unique]_ptr<type> +name \201const std::basic_string<C>& uri, + xercesc::DOMErrorHandler&, + xml_schema::flags = 0, + const xml_schema::properties& = xml_schema::properties \201\202\202; + + +// Read from std::istream. +// + +std::[auto|unique]_ptr<type> +name \201std::istream&, + xml_schema::flags = 0, + const xml_schema::properties& = xml_schema::properties \201\202\202; + +std::[auto|unique]_ptr<type> +name \201std::istream&,)WR( + xml_schema::error_handler&, + xml_schema::flags = 0, + const xml_schema::properties& = xml_schema::properties \201\202\202; + +std::[auto|unique]_ptr<type> +name \201std::istream&, + xercesc::DOMErrorHandler&, + xml_schema::flags = 0, + const xml_schema::properties& = xml_schema::properties \201\202\202; + + +std::[auto|unique]_ptr<type> +name \201std::istream&, + const std::basic_string<C>& id, + xml_schema::flags = 0, + const xml_schema::properties& = xml_schema::properties \201\202\202; + +std::[auto|unique]_ptr<type> +name \201std::istream&, + const std::basic_string<C>& id, + xml_schema::error_handler&, + xml_schema::flags = 0, + const xml_schema::properties& = xml_schema::properties \201\202\202; + +std::[auto|unique]_ptr<type> +name \201std::istream&, + const std::basic_string<C>& id, + xercesc::DOMErrorHandler&, + xml_schema::flags = 0, + const xml_schema::properties& = xml_schema::properties \201\202\202;)WR( + + +// Read from InputSource. +// + +std::[auto|unique]_ptr<type> +name \201xercesc::InputSource&, + xml_schema::flags = 0, + const xml_schema::properties& = xml_schema::properties \201\202\202; + +std::[auto|unique]_ptr<type> +name \201xercesc::InputSource&, + xml_schema::error_handler&, + xml_schema::flags = 0, + const xml_schema::properties& = xml_schema::properties \201\202\202; + +std::[auto|unique]_ptr<type> +name \201xercesc::InputSource&, + xercesc::DOMErrorHandler&, + xml_schema::flags = 0, + const xml_schema::properties& = xml_schema::properties \201\202\202; + + +// Read from DOM. +// + +std::[auto|unique]_ptr<type> +name \201const xercesc::DOMDocument&, + xml_schema::flags = 0, + const xml_schema::properties& = xml_schema::properties \201\202\202;)WR( + +std::[auto|unique]_ptr<type> +name \201xml_schema::dom::[auto|unique]_ptr<xercesc::DOMDocument>, + xml_schema::flags = 0, + const xml_schema::properties& = xml_schema::properties \201\202\202;)RP( + + )0 P(You can choose between reading an XML instance from a local file, + URI, )SM(std::istream)ES(, )SM(xercesc::Input)HY(Source)YH()ES(, + or a pre-parsed DOM instance in the form of + )SM(xercesc::DOMDoc)HY(u)HY(ment)YH()ES(. All the parsing func)HY(tions)YH( + return a dynam)HY(i)HY(cally)YH( allo)HY(cated)YH( object model as either + )SM(std::auto_ptr)ES( or )SM(std::unique_ptr)ES(, + depend)HY(ing)YH( on the C++ stan)HY(dard)YH( selected. Each of these parsing + func)HY(tions)YH( is discussed in more detail in the follow)HY(ing)YH( sections. + )EP( + + )0 2 61 H(3.1)WB 158 Sn()WB 65 Sn( Initial)HY(iz)HY(ing)YH( the Xerces-C++ Runtime)EA()EH( + + )0 P(Some parsing func)HY(tions)YH( expect you to initial)HY(ize)YH( the Xerces-C++ + runtime while others initial)HY(ize)YH( and termi)HY(nate)YH( it as part of their + work. The general rule is as follows: if a func)HY(tion)YH( has any argu)HY(ments)YH( + or return a value that is an instance of a Xerces-C++ type, then + this func)HY(tion)YH( expects you to initial)HY(ize)YH( the Xerces-C++ runtime. + Other)HY(wise)YH(, the func)HY(tion)YH( initial)HY(izes)YH( and termi)HY(nates)YH( the runtime for + you. Note that it is legal to have nested calls to the Xerces-C++ + initial)HY(ize)YH( and termi)HY(nate)YH( func)HY(tions)YH( as long as the calls are balanced. + )EP( + + )0 P(You can instruct parsing func)HY(tions)YH( that initial)HY(ize)YH( and termi)HY(nate)YH( + the runtime not to do so by passing the + )SM(xml_schema::flags::dont_initial)HY(ize)YH()ES( flag \201see + )0 66 1 A(Section 3.2, "Flags and Prop)HY(er)HY(ties)YH(")66 0 TN TL()Ec /AF f D(\202. + )EP( + + + )0 2 62 H(3.2)WB 159 Sn()WB 66 Sn( Flags and Prop)HY(er)HY(ties)YH()EA()EH( + + )0 P(Parsing flags and prop)HY(er)HY(ties)YH( are the last two argu)HY(ments)YH( of every + parsing func)HY(tion)YH(. They allow you to fine-tune the process of + instance vali)HY(da)HY(tion)YH( and parsing. Both argu)HY(ments)YH( are optional. + )EP( + + + )0 P(The follow)HY(ing)YH( flags are recog)HY(nized)YH( by the parsing func)HY(tions)YH(:)EP( + + )0 DL( )0 DT()SM(xml_schema::flags::keep_dom)ES( + )DD(Keep asso)HY(ci)HY(a)HY(tion)YH( between DOM nodes and the result)HY(ing)YH( + object model nodes. For more infor)HY(ma)HY(tion)YH( about DOM asso)HY(ci)HY(a)HY(tion)YH( + refer to )0 93 1 A(Section 5.1, "DOM Asso)HY(ci)HY(a)HY(tion)YH(")93 0 TN TL()Ec /AF f D(. + + )0 DT()SM(xml_schema::flags::own_dom)ES( + )DD(Assume owner)HY(ship)YH( of the DOM docu)HY(ment)YH( passed. This flag only + makes sense together with the )SM(keep_dom)ES( flag in + the call to the parsing func)HY(tion)YH( with the + )SM(xml_schema::dom::[auto|unique]_ptr<DOMDoc)HY(u)HY(ment)YH(>)ES( + argu)HY(ment)YH(. + + )0 DT()SM(xml_schema::flags::dont_vali)HY(date)YH()ES( + )DD(Do not vali)HY(date)YH( instance docu)HY(ments)YH( against schemas. + + )0 DT()SM(xml_schema::flags::dont_initial)HY(ize)YH()ES( + )DD(Do not initial)HY(ize)YH( the Xerces-C++ runtime. + )LD( + + )0 P(You can pass several flags by combin)HY(ing)YH( them using the bit-wise OR + oper)HY(a)HY(tor)YH(. For example:)EP( + + ) 4 61 PR(using xml_schema::flags; + +std::auto_ptr<type> r \201 + name \201"test.xml", flags::keep_dom | flags::dont_validate\202\202;)RP( + + )0 P(By default, vali)HY(da)HY(tion)YH( of instance docu)HY(ments)YH( is turned on even + though parsers gener)HY(ated)YH( by XSD do not assume instance + docu)HY(ments)YH( are valid. They include a number of checks that prevent + construc)HY(tion)YH( of incon)HY(sis)HY(tent)YH( object models. This, + however, does not mean that an instance docu)HY(ment)YH( that was + success)HY(fully)YH( parsed by the XSD-gener)HY(ated)YH( parsers is + valid per the corre)HY(spond)HY(ing)YH( schema. If an instance docu)HY(ment)YH( is not + "valid enough" for the gener)HY(ated)YH( parsers to construct consis)HY(tent)YH( + object model, one of the excep)HY(tions)YH( defined in + )SM(xml_schema)ES( names)HY(pace)YH( is thrown \201see + )0 67 1 A(Section 3.3, "Error Handling")67 0 TN TL()Ec /AF f D(\202. + )EP( + + )0 P(For more infor)HY(ma)HY(tion)YH( on the Xerces-C++ runtime initial)HY(iza)HY(tion)YH( + refer to )0 65 1 A(Section 3.1, "Initial)HY(iz)HY(ing)YH( the Xerces-C++ + Runtime")65 0 TN TL()Ec /AF f D(. + )EP( + + )0 P(The )SM(xml_schema::prop)HY(er)HY(ties)YH()ES( class allows you to + program)HY(mat)HY(i)HY(cally)YH( specify schema loca)HY(tions)YH( to be used instead + of those spec)HY(i)HY(fied)YH( with the )SM(xsi::schemaLo)HY(ca)HY(tion)YH()ES( + and )SM(xsi::noNames)HY(paceSchemaLo)HY(ca)HY(tion)YH()ES( attributes + in instance docu)HY(ments)YH(. The inter)HY(face)YH( of the )SM(prop)HY(er)HY(ties)YH()ES( + class is presented below: + )EP( + + ) 9 70 PR(class properties +{ +public: + void + schema_location \201const std::basic_string<C>& namespace_, + const std::basic_string<C>& location\202; + void + no_namespace_schema_location \201const std::basic_string<C>& location\202; +};)RP( + + )0 P(Note that all loca)HY(tions)YH( are rela)HY(tive)YH( to an instance docu)HY(ment)YH( unless + they are URIs. For example, if you want to use a local file as your + schema, then you will need to pass + )SM(file:///abso)HY(lute)YH(/path/to/your/schema)ES( as the loca)HY(tion)YH( + argu)HY(ment)YH(. + )EP( + + )0 2 63 H(3.3)WB 160 Sn()WB 67 Sn( Error Handling)EA()EH( + + )0 P(As discussed in )0 14 1 A(Section 2.2, "Error Handling")14 0 TN TL()Ec /AF f D(, + the mapping uses the C++ excep)HY(tion)YH( handling mech)HY(a)HY(nism)YH( as its primary + way of report)HY(ing)YH( error condi)HY(tions)YH(. However, to handle recov)HY(er)HY(able)YH( + parsing and vali)HY(da)HY(tion)YH( errors and warn)HY(ings)YH(, a call)HY(back)YH( inter)HY(face)YH( maybe + preferred by the appli)HY(ca)HY(tion)YH(.)EP( + + )0 P(To better under)HY(stand)YH( error handling and report)HY(ing)YH( strate)HY(gies)YH( employed + by the parsing func)HY(tions)YH(, it is useful to know that the + trans)HY(for)HY(ma)HY(tion)YH( of an XML instance docu)HY(ment)YH( to a stat)HY(i)HY(cally)YH(-typed + tree happens in two stages. The first stage, performed by Xerces-C++, + consists of parsing an XML docu)HY(ment)YH( into a DOM instance. For short, + we will call this stage the XML-DOM stage. Vali)HY(da)HY(tion)YH(, if not disabled, + happens during this stage. The second stage, + performed by the gener)HY(ated)YH( parsers, consist of parsing the DOM + instance into the stat)HY(i)HY(cally)YH(-typed tree. We will call this stage + the DOM-Tree stage. Addi)HY(tional)YH( checks are performed during this + stage in order to prevent construc)HY(tion)YH( of incon)HY(sis)HY(tent)YH( tree which + could other)HY(wise)YH( happen when vali)HY(da)HY(tion)YH( is disabled, for example.)EP( + + )0 P(All parsing func)HY(tions)YH( except the one that oper)HY(ates)YH( on a DOM instance + come in over)HY(loaded)YH( triples. The first func)HY(tion)YH( in such a triple + reports error condi)HY(tions)YH( exclu)HY(sively)YH( by throw)HY(ing)YH( excep)HY(tions)YH(. It + accu)HY(mu)HY(lates)YH( all the parsing and vali)HY(da)HY(tion)YH( errors of the XML-DOM + stage and throws them in a single instance of the + )SM(xml_schema::parsing)ES( excep)HY(tion)YH( \201described below\202. + The second and the third func)HY(tions)YH( in the triple use call)HY(back)YH( + inter)HY(faces)YH( to report parsing and vali)HY(da)HY(tion)YH( errors and warn)HY(ings)YH(. + The two call)HY(back)YH( inter)HY(faces)YH( are )SM(xml_schema::error_handler)ES( + and )SM(xercesc::DOMEr)HY(rorHan)HY(dler)YH()ES(. For more infor)HY(ma)HY(tion)YH( + on the )SM(xercesc::DOMEr)HY(rorHan)HY(dler)YH()ES( inter)HY(face)YH( refer to + the Xerces-C++ docu)HY(men)HY(ta)HY(tion)YH(. The )SM(xml_schema::error_handler)ES( + inter)HY(face)YH( is presented below: + )EP( + + ) 23 51 PR(class error_handler +{ +public: + struct severity + { + enum value + { + warning, + error, + fatal + }; + }; + + virtual bool + handle \201const std::basic_string<C>& id, + unsigned long line, + unsigned long column, + severity, + const std::basic_string<C>& message\202 = 0; + + virtual + ~error_handler \201\202; +};)RP( + + )0 P(The )SM(id)ES( argu)HY(ment)YH( of the )SM(error_handler::handle)ES( + func)HY(tion)YH( iden)HY(ti)HY(fies)YH( the resource being parsed \201e.g., a file name or + URI\202. + )EP( + + )0 P(By return)HY(ing)YH( )SM(true)ES( from the )SM(handle)ES( func)HY(tion)YH( + you instruct the parser to recover and continue parsing. Return)HY(ing)YH( + )SM(false)ES( results in termi)HY(na)HY(tion)YH( of the parsing process. + An error with the )SM(fatal)ES( sever)HY(ity)YH( level results in + termi)HY(na)HY(tion)YH( of the parsing process no matter what is returned from + the )SM(handle)ES( func)HY(tion)YH(. It is safe to throw an excep)HY(tion)YH( + from the )SM(handle)ES( func)HY(tion)YH(. + )EP( + + )0 P(The DOM-Tree stage reports error condi)HY(tions)YH( exclu)HY(sively)YH( by throw)HY(ing)YH( + excep)HY(tions)YH(. Indi)HY(vid)HY(ual)YH( excep)HY(tions)YH( thrown by the parsing func)HY(tions)YH( + are described in the follow)HY(ing)YH( sub-sections. + )EP( + + + )0 3 64 H(3.3.1)WB 161 Sn()WB 68 Sn( )SM(xml_schema::parsing)ES()EA()EH( + + ) 57 56 PR(struct severity +{ + enum value + { + warning, + error + }; + + severity \201value\202; + operator value \201\202 const; +}; + +struct error +{ + error \201severity, + const std::basic_string<C>& id, + unsigned long line, + unsigned long column, + const std::basic_string<C>& message\202; + + severity + severity \201\202 const; + + const std::basic_string<C>& + id \201\202 const; + + unsigned long + line \201\202 const; + + unsigned long + column \201\202 const;)WR( + + const std::basic_string<C>& + message \201\202 const; +}; + +std::basic_ostream<C>& +operator<< \201std::basic_ostream<C>&, const error&\202; + +struct diagnostics: std::vector<error> +{ +}; + +std::basic_ostream<C>& +operator<< \201std::basic_ostream<C>&, const diagnostics&\202; + +struct parsing: virtual exception +{ + parsing \201\202; + parsing \201const diagnostics&\202; + + const diagnostics& + diagnostics \201\202 const; + + virtual const char* + what \201\202 const throw \201\202; +};)RP( + + )0 P(The )SM(xml_schema::parsing)ES( excep)HY(tion)YH( is thrown if there + were parsing or vali)HY(da)HY(tion)YH( errors reported during the XML-DOM stage. + If no call)HY(back)YH( inter)HY(face)YH( was provided to the parsing func)HY(tion)YH(, the + excep)HY(tion)YH( contains a list of errors and warn)HY(ings)YH( acces)HY(si)HY(ble)YH( using + the )SM(diag)HY(nos)HY(tics)YH()ES( func)HY(tion)YH(. The usual condi)HY(tions)YH( when + this excep)HY(tion)YH( is thrown include malformed XML instances and, if + vali)HY(da)HY(tion)YH( is turned on, invalid instance docu)HY(ments)YH(. + )EP( + + )0 3 65 H(3.3.2)WB 162 Sn()WB 69 Sn( )SM(xml_schema::expected_element)ES()EA()EH( + + ) 16 60 PR(struct expected_element: virtual exception +{ + expected_element \201const std::basic_string<C>& name, + const std::basic_string<C>& namespace_\202; + + + const std::basic_string<C>& + name \201\202 const; + + const std::basic_string<C>& + namespace_ \201\202 const; + + + virtual const char* + what \201\202 const throw \201\202; +};)RP( + + )0 P(The )SM(xml_schema::expected_element)ES( excep)HY(tion)YH( is thrown + when an expected element is not encoun)HY(tered)YH( by the DOM-Tree stage. + The name and names)HY(pace)YH( of the expected element can be obtained using + the )SM(name)ES( and )SM(names)HY(pace)YH(_)ES( func)HY(tions)YH( respec)HY(tively)YH(. + )EP( + + + )0 3 66 H(3.3.3)WB 163 Sn()WB 70 Sn( )SM(xml_schema::unex)HY(pected)YH(_element)ES()EA()EH( + + ) 25 72 PR(struct unexpected_element: virtual exception +{ + unexpected_element \201const std::basic_string<C>& encountered_name, + const std::basic_string<C>& encountered_namespace, + const std::basic_string<C>& expected_name, + const std::basic_string<C>& expected_namespace\202 + + + const std::basic_string<C>& + encountered_name \201\202 const; + + const std::basic_string<C>& + encountered_namespace \201\202 const; + + + const std::basic_string<C>& + expected_name \201\202 const; + + const std::basic_string<C>& + expected_namespace \201\202 const; + + + virtual const char* + what \201\202 const throw \201\202; +};)RP( + + )0 P(The )SM(xml_schema::unex)HY(pected)YH(_element)ES( excep)HY(tion)YH( is thrown + when an unex)HY(pected)YH( element is encoun)HY(tered)YH( by the DOM-Tree stage. + The name and names)HY(pace)YH( of the encoun)HY(tered)YH( element can be obtained + using the )SM(encoun)HY(tered)YH(_name)ES( and + )SM(encoun)HY(tered)YH(_names)HY(pace)YH()ES( func)HY(tions)YH( respec)HY(tively)YH(. If an + element was expected instead of the encoun)HY(tered)YH( one, its name + and names)HY(pace)YH( can be obtained using the )SM(expected_name)ES( and + )SM(expected_names)HY(pace)YH()ES( func)HY(tions)YH( respec)HY(tively)YH(. Other)HY(wise)YH( + these func)HY(tions)YH( return empty strings. + )EP( + + )0 3 67 H(3.3.4)WB 164 Sn()WB 71 Sn( )SM(xml_schema::expected_attribute)ES()EA()EH( + + ) 16 62 PR(struct expected_attribute: virtual exception +{ + expected_attribute \201const std::basic_string<C>& name, + const std::basic_string<C>& namespace_\202; + + + const std::basic_string<C>& + name \201\202 const; + + const std::basic_string<C>& + namespace_ \201\202 const; + + + virtual const char* + what \201\202 const throw \201\202; +};)RP( + + )0 P(The )SM(xml_schema::expected_attribute)ES( excep)HY(tion)YH( is thrown + when an expected attribute is not encoun)HY(tered)YH( by the DOM-Tree stage. + The name and names)HY(pace)YH( of the expected attribute can be obtained using + the )SM(name)ES( and )SM(names)HY(pace)YH(_)ES( func)HY(tions)YH( respec)HY(tively)YH(. + )EP( + + + )0 3 68 H(3.3.5)WB 165 Sn()WB 72 Sn( )SM(xml_schema::unex)HY(pected)YH(_enumer)HY(a)HY(tor)YH()ES()EA()EH( + + ) 10 65 PR(struct unexpected_enumerator: virtual exception +{ + unexpected_enumerator \201const std::basic_string<C>& enumerator\202; + + const std::basic_string<C>& + enumerator \201\202 const; + + virtual const char* + what \201\202 const throw \201\202; +};)RP( + + )0 P(The )SM(xml_schema::unex)HY(pected)YH(_enumer)HY(a)HY(tor)YH()ES( excep)HY(tion)YH( is thrown + when an unex)HY(pected)YH( enumer)HY(a)HY(tor)YH( is encoun)HY(tered)YH( by the DOM-Tree stage. + The enumer)HY(a)HY(tor)YH( can be obtained using the )SM(enumer)HY(a)HY(tor)YH()ES( + func)HY(tions)YH(. + )EP( + + )0 3 69 H(3.3.6)WB 166 Sn()WB 73 Sn( )SM(xml_schema::expected_text_content)ES()EA()EH( + + ) 5 47 PR(struct expected_text_content: virtual exception +{ + virtual const char* + what \201\202 const throw \201\202; +};)RP( + + )0 P(The )SM(xml_schema::expected_text_content)ES( excep)HY(tion)YH( is thrown + when a content other than text is encoun)HY(tered)YH( and the text content was + expected by the DOM-Tree stage. + )EP( + + )0 3 70 H(3.3.7)WB 167 Sn()WB 74 Sn( )SM(xml_schema::no_type_info)ES()EA()EH( + + ) 14 60 PR(struct no_type_info: virtual exception +{ + no_type_info \201const std::basic_string<C>& type_name, + const std::basic_string<C>& type_namespace\202; + + const std::basic_string<C>& + type_name \201\202 const; + + const std::basic_string<C>& + type_namespace \201\202 const; + + virtual const char* + what \201\202 const throw \201\202; +};)RP( + + )0 P(The )SM(xml_schema::no_type_info)ES( excep)HY(tion)YH( is thrown + when there is no type infor)HY(ma)HY(tion)YH( asso)HY(ci)HY(ated)YH( with a type spec)HY(i)HY(fied)YH( + by the )SM(xsi:type)ES( attribute. This excep)HY(tion)YH( is thrown + by the DOM-Tree stage. The name and names)HY(pace)YH( of the type in ques)HY(tion)YH( + can be obtained using the )SM(type_name)ES( and + )SM(type_names)HY(pace)YH()ES( func)HY(tions)YH( respec)HY(tively)YH(. Usually, catch)HY(ing)YH( + this excep)HY(tion)YH( means that you haven't linked the code gener)HY(ated)YH( + from the schema defin)HY(ing)YH( the type in ques)HY(tion)YH( with your appli)HY(ca)HY(tion)YH( + or this schema has been compiled without the + )SM(--gener)HY(ate)YH(-poly)HY(mor)HY(phic)YH()ES( option. + )EP( + + + )0 3 71 H(3.3.8)WB 168 Sn()WB 75 Sn( )SM(xml_schema::not_derived)ES()EA()EH( + + ) 23 67 PR(struct not_derived: virtual exception +{ + not_derived \201const std::basic_string<C>& base_type_name, + const std::basic_string<C>& base_type_namespace, + const std::basic_string<C>& derived_type_name, + const std::basic_string<C>& derived_type_namespace\202; + + const std::basic_string<C>& + base_type_name \201\202 const; + + const std::basic_string<C>& + base_type_namespace \201\202 const; + + + const std::basic_string<C>& + derived_type_name \201\202 const; + + const std::basic_string<C>& + derived_type_namespace \201\202 const; + + virtual const char* + what \201\202 const throw \201\202; +};)RP( + + )0 P(The )SM(xml_schema::not_derived)ES( excep)HY(tion)YH( is thrown + when a type spec)HY(i)HY(fied)YH( by the )SM(xsi:type)ES( attribute is + not derived from the expected base type. This excep)HY(tion)YH( is thrown + by the DOM-Tree stage. The name and names)HY(pace)YH( of the expected + base type can be obtained using the )SM(base_type_name)ES( and + )SM(base_type_names)HY(pace)YH()ES( func)HY(tions)YH( respec)HY(tively)YH(. The name + and names)HY(pace)YH( of the offend)HY(ing)YH( type can be obtained using the + )SM(derived_type_name)ES( and + )SM(derived_type_names)HY(pace)YH()ES( func)HY(tions)YH( respec)HY(tively)YH(. + )EP( + + )0 3 72 H(3.3.9)WB 169 Sn()WB 76 Sn( )SM(xml_schema::no_prefix_mapping)ES()EA()EH( + + ) 10 57 PR(struct no_prefix_mapping: virtual exception +{ + no_prefix_mapping \201const std::basic_string<C>& prefix\202; + + const std::basic_string<C>& + prefix \201\202 const; + + virtual const char* + what \201\202 const throw \201\202; +};)RP( + + )0 P(The )SM(xml_schema::no_prefix_mapping)ES( excep)HY(tion)YH( is thrown + during the DOM-Tree stage if a names)HY(pace)YH( prefix is encoun)HY(tered)YH( for + which a prefix-names)HY(pace)YH( mapping hasn't been provided. The names)HY(pace)YH( + prefix in ques)HY(tion)YH( can be obtained using the )SM(prefix)ES( + func)HY(tion)YH(. + )EP( + + )0 2 73 H(3.4)WB 170 Sn()WB 77 Sn( Reading from a Local File or URI)EA()EH( + + )0 P(Using a local file or URI is the simplest way to parse an XML instance. + For example:)EP( + + ) 4 67 PR(using std::auto_ptr; + +auto_ptr<type> r1 \201name \201"test.xml"\202\202; +auto_ptr<type> r2 \201name \201"http://www.codesynthesis.com/test.xml"\202\202;)RP( + + )0 P(Or, in the C++11 mode:)EP( + + ) 4 69 PR(using std::unique_ptr; + +unique_ptr<type> r1 \201name \201"test.xml"\202\202; +unique_ptr<type> r2 \201name \201"http://www.codesynthesis.com/test.xml"\202\202;)RP( + + )0 2 74 H(3.5)WB 171 Sn()WB 78 Sn( Reading from )SM(std::istream)ES()EA()EH( + + )0 P(When using an )SM(std::istream)ES( instance, you may also + pass an optional resource id. This id is used to iden)HY(tify)YH( the + resource \201for example in error messages\202 as well as to resolve + rela)HY(tive)YH( paths. For instance:)EP( + + ) 12 48 PR(using std::auto_ptr; + +{ + std::ifstream ifs \201"test.xml"\202; + auto_ptr<type> r \201name \201ifs, "test.xml"\202\202; +} + +{ + std::string str \201"..."\202; // Some XML fragment. + std::istringstream iss \201str\202; + auto_ptr<type> r \201name \201iss\202\202; +})RP( + + )0 2 75 H(3.6)WB 172 Sn()WB 79 Sn( Reading from )SM(xercesc::Input)HY(Source)YH()ES()EA()EH( + + )0 P(Reading from a )SM(xercesc::Input)HY(Source)YH()ES( instance + is similar to the )SM(std::istream)ES( case except + the resource id is main)HY(tained)YH( by the )SM(Input)HY(Source)YH()ES( + object. For instance:)EP( + + ) 2 34 PR(xercesc::StdInInputSource is; +std::auto_ptr<type> r \201name \201is\202\202;)RP( + + )0 2 76 H(3.7)WB 173 Sn()WB 80 Sn( Reading from DOM)EA()EH( + + )0 P(Reading from a )SM(xercesc::DOMDoc)HY(u)HY(ment)YH()ES( instance allows + you to setup a custom XML-DOM stage. Things like DOM + parser reuse, schema pre-parsing, and schema caching can be achieved + with this approach. For more infor)HY(ma)HY(tion)YH( on how to obtain DOM + repre)HY(sen)HY(ta)HY(tion)YH( from an XML instance refer to the Xerces-C++ + docu)HY(men)HY(ta)HY(tion)YH(. In addi)HY(tion)YH(, the + )R7 2 A(C++/Tree Mapping + FAQ)EA( shows how to parse an XML instance to a Xerces-C++ + DOM docu)HY(ment)YH( using the XSD runtime util)HY(i)HY(ties)YH(. + )EP( + + )0 P(The last parsing func)HY(tion)YH( is useful when you would like to perform + your own XML-to-DOM parsing and as)HY(so)HY(ciate)YH( the result)HY(ing)YH( DOM docu)HY(ment)YH( + with the object model nodes. The auto)HY(matic)YH( )SM(DOMDoc)HY(u)HY(ment)YH()ES( + pointer is reset and the result)HY(ing)YH( object model assumes owner)HY(ship)YH( + of the DOM docu)HY(ment)YH( passed. For example:)EP( + + ) 18 72 PR(// C++98 version. +// +xml_schema::dom::auto_ptr<xercesc::DOMDocument> doc = ... + +std::auto_ptr<type> r \201 + name \201doc, xml_schema::flags::keep_dom | xml_schema::flags::own_dom\202\202; + +// At this point doc is reset to 0. + +// C++11 version. +// +xml_schema::dom::unique_ptr<xercesc::DOMDocument> doc = ... + +std::unique_ptr<type> r \201 + name \201std::move \201doc\202, + xml_schema::flags::keep_dom | xml_schema::flags::own_dom\202\202; + +// At this point doc is reset to 0.)RP( + + )0 1 77 H(4)WB 174 Sn()WB 81 Sn( Seri)HY(al)HY(iza)HY(tion)YH()EA()EH( + + )0 P(This chapter covers various aspects of seri)HY(al)HY(iz)HY(ing)YH( a + tree-like object model to DOM or XML. + In this regard, seri)HY(al)HY(iza)HY(tion)YH( is compli)HY(men)HY(tary)YH( to the reverse + process of parsing a DOM or XML instance into an object model + which is discussed in )0 64 1 A(Chapter 3, + "Parsing")64 0 TN TL()Ec /AF f D(. Note that the gener)HY(a)HY(tion)YH( of the seri)HY(al)HY(iza)HY(tion)YH( code + is optional and should be explic)HY(itly)YH( requested with the + )SM(--gener)HY(ate)YH(-seri)HY(al)HY(iza)HY(tion)YH()ES( option. See the + )R8 2 A(XSD + Compiler Command Line Manual)EA( for more infor)HY(ma)HY(tion)YH(. + )EP( + + )0 P(Each global XML Schema element in the form: + )EP( + + + ) 1 38 PR(<xsd:element name="name" type="type"/>)RP( + + )0 P(is mapped to 8 over)HY(loaded)YH( C++ func)HY(tions)YH( in the form:)EP( + + ) 70 56 PR(// Serialize to std::ostream. +// +void +name \201std::ostream&, + const type&, + const xml_schema::namespace_fomap& = + xml_schema::namespace_infomap \201\202, + const std::basic_string<C>& encoding = "UTF-8", + xml_schema::flags = 0\202; + +void +name \201std::ostream&, + const type&, + xml_schema::error_handler&, + const xml_schema::namespace_infomap& = + xml_schema::namespace_infomap \201\202, + const std::basic_string<C>& encoding = "UTF-8", + xml_schema::flags = 0\202; + +void +name \201std::ostream&, + const type&, + xercesc::DOMErrorHandler&, + const xml_schema::namespace_infomap& = + xml_schema::namespace_infomap \201\202, + const std::basic_string<C>& encoding = "UTF-8", + xml_schema::flags = 0\202; + + +// Serialize to XMLFormatTarget. +//)WR( +void +name \201xercesc::XMLFormatTarget&, + const type&, + const xml_schema::namespace_infomap& = + xml_schema::namespace_infomap \201\202, + const std::basic_string<C>& encoding = "UTF-8", + xml_schema::flags = 0\202; + +void +name \201xercesc::XMLFormatTarget&, + const type&, + xml_schema::error_handler&, + const xml_schema::namespace_infomap& = + xml_schema::namespace_infomap \201\202, + const std::basic_string<C>& encoding = "UTF-8", + xml_schema::flags = 0\202; + +void +name \201xercesc::XMLFormatTarget&, + const type&, + xercesc::DOMErrorHandler&, + const xml_schema::namespace_infomap& = + xml_schema::namespace_infomap \201\202, + const std::basic_string<C>& encoding = "UTF-8", + xml_schema::flags = 0\202; + + +// Serialize to DOM. +// +xml_schema::dom::[auto|unique]_ptr<xercesc::DOMDocument>)WR( +name \201const type&, + const xml_schema::namespace_infomap& + xml_schema::namespace_infomap \201\202, + xml_schema::flags = 0\202; + +void +name \201xercesc::DOMDocument&, + const type&, + xml_schema::flags = 0\202;)RP( + + )0 P(You can choose between writing XML to )SM(std::ostream)ES( or + )SM(xercesc::XMLFor)HY(mat)HY(Tar)HY(get)YH()ES( and creat)HY(ing)YH( a DOM instance + in the form of )SM(xercesc::DOMDoc)HY(u)HY(ment)YH()ES(. Seri)HY(al)HY(iza)HY(tion)YH( + to )SM(ostream)ES( or )SM(XMLFor)HY(mat)HY(Tar)HY(get)YH()ES( requires a + consid)HY(er)HY(ably)YH( less work while seri)HY(al)HY(iza)HY(tion)YH( to DOM provides + for greater flex)HY(i)HY(bil)HY(ity)YH(. Each of these seri)HY(al)HY(iza)HY(tion)YH( func)HY(tions)YH( + is discussed in more detail in the follow)HY(ing)YH( sections. + )EP( + + + )0 2 78 H(4.1)WB 175 Sn()WB 82 Sn( Initial)HY(iz)HY(ing)YH( the Xerces-C++ Runtime)EA()EH( + + )0 P(Some seri)HY(al)HY(iza)HY(tion)YH( func)HY(tions)YH( expect you to initial)HY(ize)YH( the Xerces-C++ + runtime while others initial)HY(ize)YH( and termi)HY(nate)YH( it as part of their + work. The general rule is as follows: if a func)HY(tion)YH( has any argu)HY(ments)YH( + or return a value that is an instance of a Xerces-C++ type, then + this func)HY(tion)YH( expects you to initial)HY(ize)YH( the Xerces-C++ runtime. + Other)HY(wise)YH(, the func)HY(tion)YH( initial)HY(izes)YH( and termi)HY(nates)YH( the runtime for + you. Note that it is legal to have nested calls to the Xerces-C++ + initial)HY(ize)YH( and termi)HY(nate)YH( func)HY(tions)YH( as long as the calls are balanced. + )EP( + + )0 P(You can instruct seri)HY(al)HY(iza)HY(tion)YH( func)HY(tions)YH( that initial)HY(ize)YH( and termi)HY(nate)YH( + the runtime not to do so by passing the + )SM(xml_schema::flags::dont_initial)HY(ize)YH()ES( flag \201see + )0 84 1 A(Section 4.3, "Flags")84 0 TN TL()Ec /AF f D(\202. + )EP( + + )0 2 79 H(4.2)WB 176 Sn()WB 83 Sn( Names)HY(pace)YH( Infomap and Char)HY(ac)HY(ter)YH( Encod)HY(ing)YH()EA()EH( + + )0 P(When a docu)HY(ment)YH( being seri)HY(al)HY(ized)YH( uses XML names)HY(paces)YH(, custom + prefix-names)HY(pace)YH( asso)HY(ci)HY(a)HY(tions)YH( can to be estab)HY(lished)YH(. If custom + prefix-names)HY(pace)YH( mapping is not provided then generic prefixes + \201)SM(p1)ES(, )SM(p2)ES(, etc\202 are auto)HY(mat)HY(i)HY(cally)YH( assigned + to names)HY(paces)YH( as needed. Also, if + you would like the result)HY(ing)YH( instance docu)HY(ment)YH( to contain the + )SM(schemaLo)HY(ca)HY(tion)YH()ES( or )SM(noNames)HY(paceSchemaLo)HY(ca)HY(tion)YH()ES( + attributes, you will need to provide names)HY(pace)YH(-schema asso)HY(ci)HY(a)HY(tions)YH(. + The )SM(xml_schema::names)HY(pace)YH(_infomap)ES( class is used + to capture this infor)HY(ma)HY(tion)YH(:)EP( + + ) 16 63 PR(struct namespace_info +{ + namespace_info \201\202; + namespace_info \201const std::basic_string<C>& name, + const std::basic_string<C>& schema\202; + + std::basic_string<C> name; + std::basic_string<C> schema; +}; + +// Map of namespace prefix to namespace_info. +// +struct namespace_infomap: public std::map<std::basic_string<C>, + namespace_info> +{ +};)RP( + + )0 P(Consider the follow)HY(ing)YH( asso)HY(ci)HY(a)HY(tions)YH( as an example:)EP( + + ) 4 52 PR(xml_schema::namespace_infomap map; + +map["t"].name = "http://www.codesynthesis.com/test"; +map["t"].schema = "test.xsd";)RP( + + )0 P(This map, if passed to one of the seri)HY(al)HY(iza)HY(tion)YH( func)HY(tions)YH(, + could result in the follow)HY(ing)YH( XML frag)HY(ment)YH(:)EP( + + ) 4 72 PR(<?xml version="1.0" ?> +<t:name xmlns:t="http://www.codesynthesis.com/test" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://www.codesynthesis.com/test test.xsd">)RP( + + )0 P(As you can see, the seri)HY(al)HY(iza)HY(tion)YH( func)HY(tion)YH( auto)HY(mat)HY(i)HY(cally)YH( added names)HY(pace)YH( + mapping for the )SM(xsi)ES( prefix. You can change this by + provid)HY(ing)YH( your own prefix:)EP( + + ) 6 62 PR(xml_schema::namespace_infomap map; + +map["xsn"].name = "http://www.w3.org/2001/XMLSchema-instance"; + +map["t"].name = "http://www.codesynthesis.com/test"; +map["t"].schema = "test.xsd";)RP( + + )0 P(This could result in the follow)HY(ing)YH( XML frag)HY(ment)YH(:)EP( + + ) 4 72 PR(<?xml version="1.0" ?> +<t:name xmlns:t="http://www.codesynthesis.com/test" + xmlns:xsn="http://www.w3.org/2001/XMLSchema-instance" + xsn:schemaLocation="http://www.codesynthesis.com/test test.xsd">)RP( + + )0 P(To specify the loca)HY(tion)YH( of a schema without a names)HY(pace)YH( you can use + an empty prefix as in the example below: )EP( + + ) 3 34 PR(xml_schema::namespace_infomap map; + +map[""].schema = "test.xsd";)RP( + + )0 P(This would result in the follow)HY(ing)YH( XML frag)HY(ment)YH(:)EP( + + ) 3 59 PR(<?xml version="1.0" ?> +<name xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="test.xsd">)RP( + + )0 P(To make a partic)HY(u)HY(lar)YH( names)HY(pace)YH( default you can use an empty + prefix, for example:)EP( + + ) 4 51 PR(xml_schema::namespace_infomap map; + +map[""].name = "http://www.codesynthesis.com/test"; +map[""].schema = "test.xsd";)RP( + + )0 P(This could result in the follow)HY(ing)YH( XML frag)HY(ment)YH(:)EP( + + ) 4 70 PR(<?xml version="1.0" ?> +<name xmlns="http://www.codesynthesis.com/test" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://www.codesynthesis.com/test test.xsd">)RP( + + + )0 P(Another bit of infor)HY(ma)HY(tion)YH( that you can pass to the seri)HY(al)HY(iza)HY(tion)YH( + func)HY(tions)YH( is the char)HY(ac)HY(ter)YH( encod)HY(ing)YH( method that you would like to use. + Common values for this argu)HY(ment)YH( are )SM("US-ASCII")ES(, + )SM("ISO8859-1")ES(, )SM("UTF-8")ES(, + )SM("UTF-16BE")ES(, )SM("UTF-16LE")ES(, + )SM("UCS-4BE")ES(, and )SM("UCS-4LE")ES(. The default + encod)HY(ing)YH( is )SM("UTF-8")ES(. For more infor)HY(ma)HY(tion)YH( on + encod)HY(ing)YH( methods see the + ")R11 2 A(Char)HY(ac)HY(ter)YH( + Encod)HY(ing)YH()EA(" article from Wikipedia. + )EP( + + )0 2 80 H(4.3)WB 177 Sn()WB 84 Sn( Flags)EA()EH( + + )0 P(Seri)HY(al)HY(iza)HY(tion)YH( flags are the last argu)HY(ment)YH( of every seri)HY(al)HY(iza)HY(tion)YH( + func)HY(tion)YH(. They allow you to fine-tune the process of seri)HY(al)HY(iza)HY(tion)YH(. + The flags argu)HY(ment)YH( is optional. + )EP( + + + )0 P(The follow)HY(ing)YH( flags are recog)HY(nized)YH( by the seri)HY(al)HY(iza)HY(tion)YH( + func)HY(tions)YH(:)EP( + + )0 DL( )0 DT()SM(xml_schema::flags::dont_initial)HY(ize)YH()ES( + )DD(Do not initial)HY(ize)YH( the Xerces-C++ runtime. + + )0 DT()SM(xml_schema::flags::dont_pretty_print)ES( + )DD(Do not add extra spaces or new lines that make the result)HY(ing)YH( XML + slightly bigger but easier to read. + + )0 DT()SM(xml_schema::flags::no_xml_decla)HY(ra)HY(tion)YH()ES( + )DD(Do not write XML decla)HY(ra)HY(tion)YH( \201<?xml ... ?>\202. + )LD( + + )0 P(You can pass several flags by combin)HY(ing)YH( them using the bit-wise OR + oper)HY(a)HY(tor)YH(. For example:)EP( + + ) 9 45 PR(std::auto_ptr<type> r = ... +std::ofstream ofs \201"test.xml"\202; +xml_schema::namespace_infomap map; +name \201ofs, + *r, + map, + "UTF-8", + xml_schema::flags::no_xml_declaration | + xml_schema::flags::dont_pretty_print\202;)RP( + + )0 P(For more infor)HY(ma)HY(tion)YH( on the Xerces-C++ runtime initial)HY(iza)HY(tion)YH( + refer to )0 82 1 A(Section 4.1, "Initial)HY(iz)HY(ing)YH( the Xerces-C++ + Runtime")82 0 TN TL()Ec /AF f D(. + )EP( + + )0 2 81 H(4.4)WB 178 Sn()WB 85 Sn( Error Handling)EA()EH( + + )0 P(As with the parsing func)HY(tions)YH( \201see )0 67 1 A(Section 3.3, + "Error Handling")67 0 TN TL()Ec /AF f D(\202, to better under)HY(stand)YH( error handling and + report)HY(ing)YH( strate)HY(gies)YH( employed by the seri)HY(al)HY(iza)HY(tion)YH( func)HY(tions)YH(, it + is useful to know that the trans)HY(for)HY(ma)HY(tion)YH( of a stat)HY(i)HY(cally)YH(-typed + tree to an XML instance docu)HY(ment)YH( happens in two stages. The first + stage, performed by the gener)HY(ated)YH( code, consist of build)HY(ing)YH( a DOM + instance from the stat)HY(i)HY(cally)YH(-typed tree . For short, we will call + this stage the Tree-DOM stage. The second stage, performed by + Xerces-C++, consists of seri)HY(al)HY(iz)HY(ing)YH( the DOM instance into the XML + docu)HY(ment)YH(. We will call this stage the DOM-XML stage. + )EP( + + )0 P(All seri)HY(al)HY(iza)HY(tion)YH( func)HY(tions)YH( except the two that seri)HY(al)HY(ize)YH( into + a DOM instance come in over)HY(loaded)YH( triples. The first func)HY(tion)YH( + in such a triple reports error condi)HY(tions)YH( exclu)HY(sively)YH( by throw)HY(ing)YH( + excep)HY(tions)YH(. It accu)HY(mu)HY(lates)YH( all the seri)HY(al)HY(iza)HY(tion)YH( errors of the + DOM-XML stage and throws them in a single instance of the + )SM(xml_schema::seri)HY(al)HY(iza)HY(tion)YH()ES( excep)HY(tion)YH( \201described below\202. + The second and the third func)HY(tions)YH( in the triple use call)HY(back)YH( + inter)HY(faces)YH( to report seri)HY(al)HY(iza)HY(tion)YH( errors and warn)HY(ings)YH(. The two + call)HY(back)YH( inter)HY(faces)YH( are )SM(xml_schema::error_handler)ES( and + )SM(xercesc::DOMEr)HY(rorHan)HY(dler)YH()ES(. The + )SM(xml_schema::error_handler)ES( inter)HY(face)YH( is described in + )0 67 1 A(Section 3.3, "Error Handling")67 0 TN TL()Ec /AF f D(. For more infor)HY(ma)HY(tion)YH( + on the )SM(xercesc::DOMEr)HY(rorHan)HY(dler)YH()ES( inter)HY(face)YH( refer to the + Xerces-C++ docu)HY(men)HY(ta)HY(tion)YH(. + )EP( + + )0 P(The Tree-DOM stage reports error condi)HY(tions)YH( exclu)HY(sively)YH( by throw)HY(ing)YH( + excep)HY(tions)YH(. Indi)HY(vid)HY(ual)YH( excep)HY(tions)YH( thrown by the seri)HY(al)HY(iza)HY(tion)YH( func)HY(tions)YH( + are described in the follow)HY(ing)YH( sub-sections. + )EP( + + )0 3 82 H(4.4.1)WB 179 Sn()WB 86 Sn( )SM(xml_schema::seri)HY(al)HY(iza)HY(tion)YH()ES()EA()EH( + + ) 11 39 PR(struct serialization: virtual exception +{ + serialization \201\202; + serialization \201const diagnostics&\202; + + const diagnostics& + diagnostics \201\202 const; + + virtual const char* + what \201\202 const throw \201\202; +};)RP( + + )0 P(The )SM(xml_schema::diag)HY(nos)HY(tics)YH()ES( class is described in + )0 68 1 A(Section 3.3.1, ")SM(xml_schema::parsing)ES(")68 0 TN TL()Ec /AF f D(. + The )SM(xml_schema::seri)HY(al)HY(iza)HY(tion)YH()ES( excep)HY(tion)YH( is thrown if + there were seri)HY(al)HY(iza)HY(tion)YH( errors reported during the DOM-XML stage. + If no call)HY(back)YH( inter)HY(face)YH( was provided to the seri)HY(al)HY(iza)HY(tion)YH( func)HY(tion)YH(, + the excep)HY(tion)YH( contains a list of errors and warn)HY(ings)YH( acces)HY(si)HY(ble)YH( using + the )SM(diag)HY(nos)HY(tics)YH()ES( func)HY(tion)YH(. + )EP( + + + )0 3 83 H(4.4.2)WB 180 Sn()WB 87 Sn( )SM(xml_schema::unex)HY(pected)YH(_element)ES()EA()EH( + + )0 P(The )SM(xml_schema::unex)HY(pected)YH(_element)ES( excep)HY(tion)YH( is + described in )0 70 1 A(Section 3.3.3, + ")SM(xml_schema::unex)HY(pected)YH(_element)ES(")70 0 TN TL()Ec /AF f D(. It is thrown + by the seri)HY(al)HY(iza)HY(tion)YH( func)HY(tions)YH( during the Tree-DOM stage if the + root element name of the provided DOM instance does not match with + the name of the element this seri)HY(al)HY(iza)HY(tion)YH( func)HY(tion)YH( is for. + )EP( + + )0 3 84 H(4.4.3)WB 181 Sn()WB 88 Sn( )SM(xml_schema::no_type_info)ES()EA()EH( + + )0 P(The )SM(xml_schema::no_type_info)ES( excep)HY(tion)YH( is + described in )0 74 1 A(Section 3.3.7, + ")SM(xml_schema::no_type_info)ES(")74 0 TN TL()Ec /AF f D(. It is thrown + by the seri)HY(al)HY(iza)HY(tion)YH( func)HY(tions)YH( during the Tree-DOM stage when there + is no type infor)HY(ma)HY(tion)YH( asso)HY(ci)HY(ated)YH( with a dynamic type of an + element. Usually, catch)HY(ing)YH( this excep)HY(tion)YH( means that you haven't + linked the code gener)HY(ated)YH( from the schema defin)HY(ing)YH( the type in + ques)HY(tion)YH( with your appli)HY(ca)HY(tion)YH( or this schema has been compiled + without the )SM(--gener)HY(ate)YH(-poly)HY(mor)HY(phic)YH()ES( option. + )EP( + + )0 2 85 H(4.5)WB 182 Sn()WB 89 Sn( Seri)HY(al)HY(iz)HY(ing)YH( to )SM(std::ostream)ES()EA()EH( + + )0 P(In order to seri)HY(al)HY(ize)YH( to )SM(std::ostream)ES( you will need + an object model, an output stream and, option)HY(ally)YH(, a names)HY(pace)YH( + infomap. For instance:)EP( + + ) 14 61 PR(// Obtain the object model. +// +std::auto_ptr<type> r = ... + +// Prepare namespace mapping and schema location information. +// +xml_schema::namespace_infomap map; + +map["t"].name = "http://www.codesynthesis.com/test"; +map["t"].schema = "test.xsd"; + +// Write it out. +// +name \201std::cout, *r, map\202;)RP( + + )0 P(Note that the output stream is treated as a binary stream. This + becomes impor)HY(tant)YH( when you use a char)HY(ac)HY(ter)YH( encod)HY(ing)YH( that is wider + than 8-bit )SM(char)ES(, for instance UTF-16 or UCS-4. For + example, things will most likely break if you try to seri)HY(al)HY(ize)YH( + to )SM(std::ostringstream)ES( with UTF-16 or UCS-4 as an + encod)HY(ing)YH(. This is due to the special value, + )SM('\2000')ES(, that will most likely occur as part of such + seri)HY(al)HY(iza)HY(tion)YH( and it won't have the special meaning assumed by + )SM(std::ostringstream)ES(. + )EP( + + + )0 2 86 H(4.6)WB 183 Sn()WB 90 Sn( Seri)HY(al)HY(iz)HY(ing)YH( to )SM(xercesc::XMLFor)HY(mat)HY(Tar)HY(get)YH()ES()EA()EH( + + )0 P(Seri)HY(al)HY(iz)HY(ing)YH( to an )SM(xercesc::XMLFor)HY(mat)HY(Tar)HY(get)YH()ES( instance + is similar the )SM(std::ostream)ES( case. For instance: + )EP( + + ) 38 63 PR(using std::auto_ptr; + +// Obtain the object model. +// +auto_ptr<type> r = ... + +// Prepare namespace mapping and schema location information. +// +xml_schema::namespace_infomap map; + +map["t"].name = "http://www.codesynthesis.com/test"; +map["t"].schema = "test.xsd"; + +using namespace xercesc; + +XMLPlatformUtils::Initialize \201\202; + +{ + // Choose a target. + // + auto_ptr<XMLFormatTarget> ft; + + if \201argc != 2\202 + { + ft = auto_ptr<XMLFormatTarget> \201new StdOutFormatTarget \201\202\202; + } + else + { + ft = auto_ptr<XMLFormatTarget> \201 + new LocalFileFormatTarget \201argv[1]\202\202; + })WR( + + // Write it out. + // + name \201*ft, *r, map\202; +} + +XMLPlatformUtils::Terminate \201\202;)RP( + + )0 P(Note that we had to initial)HY(ize)YH( the Xerces-C++ runtime before we + could call this seri)HY(al)HY(iza)HY(tion)YH( func)HY(tion)YH(.)EP( + + )0 2 87 H(4.7)WB 184 Sn()WB 91 Sn( Seri)HY(al)HY(iz)HY(ing)YH( to DOM)EA()EH( + + )0 P(The mapping provides two over)HY(loaded)YH( func)HY(tions)YH( that imple)HY(ment)YH( + seri)HY(al)HY(iza)HY(tion)YH( to a DOM instance. The first creates a DOM instance + for you and the second seri)HY(al)HY(izes)YH( to an exist)HY(ing)YH( DOM instance. + While seri)HY(al)HY(iz)HY(ing)YH( to a new DOM instance is similar to seri)HY(al)HY(iz)HY(ing)YH( + to )SM(std::ostream)ES( or )SM(xercesc::XMLFor)HY(mat)HY(Tar)HY(get)YH()ES(, + seri)HY(al)HY(iz)HY(ing)YH( to an exist)HY(ing)YH( DOM instance requires quite a bit of work + from your side. You will need to set all the custom names)HY(pace)YH( mapping + attributes as well as the )SM(schemaLo)HY(ca)HY(tion)YH()ES( and/or + )SM(noNames)HY(paceSchemaLo)HY(ca)HY(tion)YH()ES( attributes. The follow)HY(ing)YH( + listing should give you an idea about what needs to be done: + )EP( + + ) 24 67 PR(// Obtain the object model. +// +std::auto_ptr<type> r = ... + +using namespace xercesc; + +XMLPlatformUtils::Initialize \201\202; + +{ + // Create a DOM instance. Set custom namespace mapping and schema + // location attributes. + // + DOMDocument& doc = ... + + // Serialize to DOM. + // + name \201doc, *r\202; + + // Serialize the DOM document to XML. + // + ... +} + +XMLPlatformUtils::Terminate \201\202;)RP( + + )0 P(For more infor)HY(ma)HY(tion)YH( on how to create and seri)HY(al)HY(ize)YH( a DOM instance + refer to the Xerces-C++ docu)HY(men)HY(ta)HY(tion)YH(. In addi)HY(tion)YH(, the + )R7 2 A(C++/Tree Mapping + FAQ)EA( shows how to imple)HY(ment)YH( these oper)HY(a)HY(tions)YH( using the XSD + runtime util)HY(i)HY(ties)YH(. + )EP( + + )0 1 88 H(5)WB 185 Sn()WB 92 Sn( Addi)HY(tional)YH( Func)HY(tion)HY(al)HY(ity)YH()EA()EH( + + )0 P(The C++/Tree mapping provides a number of optional features + that can be useful in certain situ)HY(a)HY(tions)YH(. They are described + in the follow)HY(ing)YH( sections.)EP( + + )0 2 89 H(5.1)WB 186 Sn()WB 93 Sn( DOM Asso)HY(ci)HY(a)HY(tion)YH()EA()EH( + + )0 P(Normally, after parsing is complete, the DOM docu)HY(ment)YH( which + was used to extract the data is discarded. However, the parsing + func)HY(tions)YH( can be instructed to preserve the DOM docu)HY(ment)YH( + and create an asso)HY(ci)HY(a)HY(tion)YH( between the DOM nodes and object model + nodes. When there is an asso)HY(ci)HY(a)HY(tion)YH( between the DOM and + object model nodes, you can obtain the corre)HY(spond)HY(ing)YH( DOM element + or attribute node from an object model node as well as perform + the reverse tran)HY(si)HY(tion)YH(: obtain the corre)HY(spond)HY(ing)YH( object model + from a DOM element or attribute node.)EP( + + )0 P(Main)HY(tain)HY(ing)YH( DOM asso)HY(ci)HY(a)HY(tion)YH( is normally useful when the appli)HY(ca)HY(tion)YH( + needs access to XML constructs that are not preserved in the + object model, for example, XML comments. + Another useful aspect of DOM asso)HY(ci)HY(a)HY(tion)YH( is the ability of the + appli)HY(ca)HY(tion)YH( to navi)HY(gate)YH( the docu)HY(ment)YH( tree using the generic DOM + inter)HY(face)YH( \201for example, with the help of an XPath proces)HY(sor)YH(\202 + and then move back to the stat)HY(i)HY(cally)YH(-typed object model. Note + also that while you can change the under)HY(ly)HY(ing)YH( DOM docu)HY(ment)YH(, + these changes are not reflected in the object model and will + be ignored during seri)HY(al)HY(iza)HY(tion)YH(. If you need to not only access + but also modify some aspects of XML that are not preserved in + the object model, then type customiza)HY(tion)YH( with custom parsing + construc)HY(tors)YH( and seri)HY(al)HY(iza)HY(tion)YH( oper)HY(a)HY(tors)YH( should be used instead.)EP( + + )0 P(To request DOM asso)HY(ci)HY(a)HY(tion)YH( you will need to pass the + )SM(xml_schema::flags::keep_dom)ES( flag to one of the + parsing func)HY(tions)YH( \201see )0 66 1 A(Section 3.2, + "Flags and Prop)HY(er)HY(ties)YH(")66 0 TN TL()Ec /AF f D( for more infor)HY(ma)HY(tion)YH(\202. In this case the + DOM docu)HY(ment)YH( is retained and will be released when the object model + is deleted. Note that since DOM nodes "out-live" the parsing func)HY(tion)YH( + call, you need to initial)HY(ize)YH( the Xerces-C++ runtime before calling + one of the parsing func)HY(tions)YH( with the )SM(keep_dom)ES( flag and + termi)HY(nate)YH( it after the object model is destroyed \201see + )0 65 1 A(Section 3.1, "Initial)HY(iz)HY(ing)YH( the Xerces-C++ Runtime")65 0 TN TL()Ec /AF f D(\202.)EP( + + )0 P(If the )SM(keep_dom)ES( flag is passed + as the second argu)HY(ment)YH( to the copy construc)HY(tor)YH( and the copy + being made is of a complete tree, then the DOM asso)HY(ci)HY(a)HY(tion)YH( + is also main)HY(tained)YH( in the copy by cloning the under)HY(ly)HY(ing)YH( + DOM docu)HY(ment)YH( and reestab)HY(lish)HY(ing)YH( the asso)HY(ci)HY(a)HY(tions)YH(. For example:)EP( + + ) 22 48 PR(using namespace xercesc; + +XMLPlatformUtils::Initialize \201\202; + +{ + // Parse XML to object model. + // + std::auto_ptr<type> r \201root \201 + "root.xml", + xml_schema::flags::keep_dom | + xml_schema::flags::dont_initialize\202\202; + + // Copy without DOM association. + // + type copy1 \201*r\202; + + // Copy with DOM association. + // + type copy2 \201*r, xml_schema::flags::keep_dom\202; +} + +XMLPlatformUtils::Terminate \201\202;)RP( + + + )0 P(To obtain the corre)HY(spond)HY(ing)YH( DOM node from an object model node + you will need to call the )SM(_node)ES( acces)HY(sor)YH( func)HY(tion)YH( + which returns a pointer to )SM(DOMNode)ES(. You can then query + this DOM node's type and cast it to either )SM(DOMAttr*)ES( + or )SM(DOMEle)HY(ment)YH(*)ES(. To obtain the corre)HY(spond)HY(ing)YH( object + model node from a DOM node, the DOM user data API is used. The + )SM(xml_schema::dom::tree_node_key)ES( vari)HY(able)YH( contains + the key for object model nodes. The follow)HY(ing)YH( schema and code + frag)HY(ment)YH( show how to navi)HY(gate)YH( from DOM to object model nodes + and in the oppo)HY(site)YH( direc)HY(tion)YH(:)EP( + + ) 7 37 PR(<complexType name="object"> + <sequence> + <element name="a" type="string"/> + </sequence> +</complexType> + +<element name="root" type="object"/>)RP( + + ) 42 68 PR(using namespace xercesc; + +XMLPlatformUtils::Initialize \201\202; + +{ + // Parse XML to object model. + // + std::auto_ptr<type> r \201root \201 + "root.xml", + xml_schema::flags::keep_dom | + xml_schema::flags::dont_initialize\202\202; + + DOMNode* n = root->_node \201\202; + assert \201n->getNodeType \201\202 == DOMNode::ELEMENT_NODE\202; + DOMElement* re = static_cast<DOMElement*> \201n\202; + + // Get the 'a' element. Note that it is not necessarily the + // first child node of 'root' since there could be whitespace + // nodes before it. + // + DOMElement* ae; + + for \201n = re->getFirstChild \201\202; n != 0; n = n->getNextSibling \201\202\202 + { + if \201n->getNodeType \201\202 == DOMNode::ELEMENT_NODE\202 + { + ae = static_cast<DOMElement*> \201n\202; + break; + } + } +)WR( + // Get from the 'a' DOM element to xml_schema::string object model + // node. + // + xml_schema::type& t \201 + *reinterpret_cast<xml_schema::type*> \201 + ae->getUserData \201xml_schema::dom::tree_node_key\202\202\202; + + xml_schema::string& a \201dynamic_cast<xml_schema::string&> \201t\202\202; +} + +XMLPlatformUtils::Terminate \201\202;)RP( + + )0 P(The 'mixed' example which can be found in the XSD distri)HY(bu)HY(tion)YH( + shows how to handle the mixed content using DOM asso)HY(ci)HY(a)HY(tion)YH(.)EP( + + )0 2 90 H(5.2)WB 187 Sn()WB 94 Sn( Binary Seri)HY(al)HY(iza)HY(tion)YH()EA()EH( + + )0 P(Besides reading from and writing to XML, the C++/Tree mapping + also allows you to save the object model to and load it from a + number of prede)HY(fined)YH( as well as custom data repre)HY(sen)HY(ta)HY(tion)YH( + formats. The prede)HY(fined)YH( binary formats are CDR \201Common Data + Repre)HY(sen)HY(ta)HY(tion)YH(\202 and XDR \201eXter)HY(nal)YH( Data Repre)HY(sen)HY(ta)HY(tion)YH(\202. A + custom format can easily be supported by provid)HY(ing)YH( + inser)HY(tion)YH( and extrac)HY(tion)YH( oper)HY(a)HY(tors)YH( for basic types.)EP( + + )0 P(Binary seri)HY(al)HY(iza)HY(tion)YH( saves only the data without any meta + infor)HY(ma)HY(tion)YH( or markup. As a result, saving to and loading + from a binary repre)HY(sen)HY(ta)HY(tion)YH( can be an order of magni)HY(tude)YH( + faster than parsing and seri)HY(al)HY(iz)HY(ing)YH( the same data in XML. + Further)HY(more)YH(, the result)HY(ing)YH( repre)HY(sen)HY(ta)HY(tion)YH( is normally several + times smaller than the equiv)HY(a)HY(lent)YH( XML repre)HY(sen)HY(ta)HY(tion)YH(. These + prop)HY(er)HY(ties)YH( make binary seri)HY(al)HY(iza)HY(tion)YH( ideal for inter)HY(nal)YH( data + exchange and storage. A typical appli)HY(ca)HY(tion)YH( that uses this + facil)HY(ity)YH( stores the data and commu)HY(ni)HY(cates)YH( within the + system using a binary format and reads/writes the data + in XML when commu)HY(ni)HY(cat)HY(ing)YH( with the outside world.)EP( + + )0 P(In order to request the gener)HY(a)HY(tion)YH( of inser)HY(tion)YH( oper)HY(a)HY(tors)YH( and + extrac)HY(tion)YH( construc)HY(tors)YH( for a specific prede)HY(fined)YH( or custom + data repre)HY(sen)HY(ta)HY(tion)YH( stream, you will need to use the + )SM(--gener)HY(ate)YH(-inser)HY(tion)YH()ES( and )SM(--gener)HY(ate)YH(-extrac)HY(tion)YH()ES( + compiler options. See the + )R8 2 A(XSD + Compiler Command Line Manual)EA( for more infor)HY(ma)HY(tion)YH(.)EP( + + )0 P(Once the inser)HY(tion)YH( oper)HY(a)HY(tors)YH( and extrac)HY(tion)YH( construc)HY(tors)YH( are + gener)HY(ated)YH(, you can use the )SM(xml_schema::istream)ES( + and )SM(xml_schema::ostream)ES( wrapper stream templates + to save the object model to and load it from a specific format. + The follow)HY(ing)YH( code frag)HY(ment)YH( shows how to do this using ACE + \201Adap)HY(tive)YH( Commu)HY(ni)HY(ca)HY(tion)YH( Envi)HY(ron)HY(ment)YH(\202 CDR streams as an example:)EP( + + ) 8 37 PR(<complexType name="object"> + <sequence> + <element name="a" type="string"/> + <element name="b" type="int"/> + </sequence> +</complexType> + +<element name="root" type="object"/>)RP( + + ) 21 51 PR(// Parse XML to object model. +// +std::auto_ptr<type> r \201root \201"root.xml"\202\202; + +// Save to a CDR stream. +// +ACE_OutputCDR ace_ocdr; +xml_schema::ostream<ACE_OutputCDR> ocdr \201ace_ocdr\202; + +ocdr << *r; + +// Load from a CDR stream. +// +ACE_InputCDR ace_icdr \201buf, size\202; +xml_schema::istream<ACE_InputCDR> icdr \201ace_icdr\202; + +std::auto_ptr<object> copy \201new object \201icdr\202\202; + +// Serialize to XML. +// +root \201std::cout, *copy\202;)RP( + + )0 P(The XSD distri)HY(bu)HY(tion)YH( contains a number of exam)HY(ples)YH( that + show how to save the object model to and load it from + CDR, XDR, and a custom format.)EP( + + + + + )0 1 91 H(Appendix)WB 188 Sn()WB 95 Sn( A \236 Default and Fixed Values)EA()EH( + + )0 P(The follow)HY(ing)YH( table summa)HY(rizes)YH( the effect of default and fixed + values \201spec)HY(i)HY(fied)YH( with the )SM(default)ES( and )SM(fixed)ES( + attributes, respec)HY(tively)YH(\202 on attribute and element values. The + )SM(default)ES( and )SM(fixed)ES( attributes are mutu)HY(ally)YH( + exclu)HY(sive)YH(. It is also worth)HY(while)YH( to note that the fixed value seman)HY(tics)YH( + is a super)HY(set)YH( of the default value seman)HY(tics)YH(. + )EP( + + + )1 PT( + + )BR( +)BR( + + +)WB NL +/TE t D NP /OU t D TU PM 1 eq and{/Pn () D showpage}if end restore diff --git a/xsd/doc/cxx/tree/manual/index.xhtml b/xsd/doc/cxx/tree/manual/index.xhtml new file mode 100644 index 0000000..56213e0 --- /dev/null +++ b/xsd/doc/cxx/tree/manual/index.xhtml @@ -0,0 +1,6822 @@ +<?xml version="1.0" encoding="iso-8859-1"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> + +<head> + <title>C++/Tree Mapping User Manual</title> + + <meta name="copyright" content="© 2005-2014 Code Synthesis Tools CC"/> + <meta name="keywords" content="xsd,xml,schema,c++,mapping,data,binding,tree,serialization,guide,manual,examples"/> + <meta name="description" content="C++/Tree Mapping User Manual"/> + <meta name="revision" content="4.0.0"/> + + <link rel="stylesheet" type="text/css" href="../../../default.css" /> + +<style type="text/css"> + pre { + padding : 0 0 0 0em; + margin : 0em 0em 0em 0; + + font-size : 102% + } + + body { + min-width: 48em; + } + + h1 { + font-weight: bold; + font-size: 200%; + } + + h2 { + font-weight : bold; + font-size : 150%; + + padding-top : 0.8em; + } + + h3 { + font-size : 130%; + padding-top : 0.8em; + } + + /* Adjust indentation for three levels. */ + #container { + max-width: 48em; + } + + #content { + padding: 0 0.1em 0 4em; + /*background-color: red;*/ + } + + #content h1 { + margin-left: -2.06em; + } + + #content h2 { + margin-left: -1.33em; + } + + /* Title page */ + + #titlepage { + padding: 2em 0 1em 0; + border-bottom: 1px solid black; + } + + #titlepage #title { + font-weight: bold; + font-size: 200%; + text-align: center; + padding: 1em 0 2em 0; + } + + /* Lists */ + ul.list li { + padding-top : 0.3em; + padding-bottom : 0.3em; + } + + + /* Built-in table */ + #builtin { + margin: 2em 0 2em 0; + + border-collapse : collapse; + border : 1px solid; + border-color : #000000; + + font-size : 11px; + line-height : 14px; + } + + #builtin th, #builtin td { + border: 1px solid; + padding : 0.9em 0.9em 0.7em 0.9em; + } + + #builtin th { + background : #cde8f6; + } + + #builtin td { + text-align: left; + } + + + /* default-fixed */ + #default-fixed { + margin: 2em 0 2em 0; + + border-collapse : collapse; + border : 1px solid; + border-color : #000000; + + font-size : 11px; + line-height : 14px; + } + + #default-fixed th, #default-fixed td { + border: 1px solid; + padding : 0.9em 0.9em 0.7em 0.9em; + } + + #default-fixed th { + background : #cde8f6; + } + + #default-fixed td { + text-align: center; + } + + + /* */ + dl dt { + padding : 0.8em 0 0 0; + } + + + /* TOC */ + table.toc { + border-style : none; + border-collapse : separate; + border-spacing : 0; + + margin : 0.2em 0 0.2em 0; + padding : 0 0 0 0; + } + + table.toc tr { + padding : 0 0 0 0; + margin : 0 0 0 0; + } + + table.toc * td, table.toc * th { + border-style : none; + margin : 0 0 0 0; + vertical-align : top; + } + + table.toc * th { + font-weight : normal; + padding : 0em 0.1em 0em 0; + text-align : left; + white-space : nowrap; + } + + table.toc * table.toc th { + padding-left : 1em; + } + + table.toc * td { + padding : 0em 0 0em 0.7em; + text-align : left; + } +</style> + + +</head> + +<body> +<div id="container"> + <div id="content"> + + <div class="noprint"> + + <div id="titlepage"> + <div id="title">C++/Tree Mapping User Manual</div> + + <p>Copyright © 2005-2014 CODE SYNTHESIS TOOLS CC</p> + + <p>Permission is granted to copy, distribute and/or modify this + document under the terms of the + <a href="http://www.codesynthesis.com/licenses/fdl-1.2.txt">GNU Free + Documentation License, version 1.2</a>; with no Invariant Sections, + no Front-Cover Texts and no Back-Cover Texts. + </p> + + <p>This document is available in the following formats: + <a href="http://www.codesynthesis.com/projects/xsd/documentation/cxx/tree/manual/index.xhtml">XHTML</a>, + <a href="http://www.codesynthesis.com/projects/xsd/documentation/cxx/tree/manual/cxx-tree-manual.pdf">PDF</a>, and + <a href="http://www.codesynthesis.com/projects/xsd/documentation/cxx/tree/manual/cxx-tree-manual.ps">PostScript</a>.</p> + </div> + + <h1>Table of Contents</h1> + + <table class="toc"> + <tr> + <th></th><td><a href="#0">Preface</a> + <table class="toc"> + <tr><th></th><td><a href="#0.1">About This Document</a></td></tr> + <tr><th></th><td><a href="#0.2">More Information</a></td></tr> + </table> + </td> + </tr> + + <tr> + <th>1</th><td><a href="#1">Introduction</a></td> + </tr> + + <tr> + <th>2</th><td><a href="#2">C++/Tree Mapping</a> + <table class="toc"> + <tr> + <th>2.1</th><td><a href="#2.1">Preliminary Information</a> + <table class="toc"> + <tr><th>2.1.1</th><td><a href="#2.1.1">C++ Standard</a></td></tr> + <tr><th>2.1.2</th><td><a href="#2.1.2">Identifiers</a></td></tr> + <tr><th>2.1.3</th><td><a href="#2.1.3">Character Type and Encoding</a></td></tr> + <tr><th>2.1.4</th><td><a href="#2.1.4">XML Schema Namespace</a></td></tr> + <tr><th>2.1.5</th><td><a href="#2.1.5">Anonymous Types</a></td></tr> + </table> + </td> + </tr> + <tr> + <th>2.2</th><td><a href="#2.2">Error Handling</a> + <table class="toc"> + <tr><th>2.2.1</th><td><a href="#2.2.1"><code>xml_schema::duplicate_id</code></a></td></tr> + </table> + </td> + </tr> + <tr> + <th>2.3</th><td><a href="#2.3">Mapping for <code>import</code> and <code>include</code></a> + <table class="toc"> + <tr><th>2.3.1</th><td><a href="#2.3.1">Import</a></td></tr> + <tr><th>2.3.2</th><td><a href="#2.3.2">Inclusion with Target Namespace</a></td></tr> + <tr><th>2.3.3</th><td><a href="#2.3.3">Inclusion without Target Namespace</a></td></tr> + </table> + </td> + </tr> + <tr> + <th>2.4</th><td><a href="#2.4">Mapping for Namespaces</a></td> + </tr> + <tr> + <th>2.5</th><td><a href="#2.5">Mapping for Built-in Data Types</a> + <table class="toc"> + <tr><th>2.5.1</th><td><a href="#2.5.1">Inheritance from Built-in Data Types</a></td></tr> + <tr><th>2.5.2</th><td><a href="#2.5.2">Mapping for <code>anyType</code></a></td></tr> + <tr><th>2.5.3</th><td><a href="#2.5.3">Mapping for <code>anySimpleType</code></a></td></tr> + <tr><th>2.5.4</th><td><a href="#2.5.4">Mapping for <code>QName</code></a></td></tr> + <tr><th>2.5.5</th><td><a href="#2.5.5">Mapping for <code>IDREF</code></a></td></tr> + <tr><th>2.5.6</th><td><a href="#2.5.6">Mapping for <code>base64Binary</code> and <code>hexBinary</code></a></td></tr> + <tr><th>2.5.7</th><td><a href="#2.5.7">Time Zone Representation</a></td></tr> + <tr><th>2.5.8</th><td><a href="#2.5.8">Mapping for <code>date</code></a></td></tr> + <tr><th>2.5.9</th><td><a href="#2.5.9">Mapping for <code>dateTime</code></a></td></tr> + <tr><th>2.5.10</th><td><a href="#2.5.10">Mapping for <code>duration</code></a></td></tr> + <tr><th>2.5.11</th><td><a href="#2.5.11">Mapping for <code>gDay</code></a></td></tr> + <tr><th>2.5.12</th><td><a href="#2.5.12">Mapping for <code>gMonth</code></a></td></tr> + <tr><th>2.5.13</th><td><a href="#2.5.13">Mapping for <code>gMonthDay</code></a></td></tr> + <tr><th>2.5.14</th><td><a href="#2.5.14">Mapping for <code>gYear</code></a></td></tr> + <tr><th>2.5.15</th><td><a href="#2.5.15">Mapping for <code>gYearMonth</code></a></td></tr> + <tr><th>2.5.16</th><td><a href="#2.5.16">Mapping for <code>time</code></a></td></tr> + </table> + </td> + </tr> + <tr> + <th>2.6</th><td><a href="#2.6">Mapping for Simple Types</a> + <table class="toc"> + <tr><th>2.6.1</th><td><a href="#2.6.1">Mapping for Derivation by Restriction</a></td></tr> + <tr><th>2.6.2</th><td><a href="#2.6.2">Mapping for Enumerations</a></td></tr> + <tr><th>2.6.3</th><td><a href="#2.6.3">Mapping for Derivation by List</a></td></tr> + <tr><th>2.6.4</th><td><a href="#2.6.4">Mapping for Derivation by Union</a></td></tr> + </table> + </td> + </tr> + <tr> + <th>2.7</th><td><a href="#2.7">Mapping for Complex Types</a> + <table class="toc"> + <tr><th>2.7.1</th><td><a href="#2.7.1">Mapping for Derivation by Extension</a></td></tr> + <tr><th>2.7.2</th><td><a href="#2.7.2">Mapping for Derivation by Restriction</a></td></tr> + </table> + </td> + </tr> + <tr> + <th>2.8</th><td><a href="#2.8">Mapping for Local Elements and Attributes</a> + <table class="toc"> + <tr><th>2.8.1</th><td><a href="#2.8.1">Mapping for Members with the One Cardinality Class</a></td></tr> + <tr><th>2.8.2</th><td><a href="#2.8.2">Mapping for Members with the Optional Cardinality Class</a></td></tr> + <tr><th>2.8.3</th><td><a href="#2.8.3">Mapping for Members with the Sequence Cardinality Class</a></td></tr> + <tr><th>2.8.4</th><td><a href="#2.8.4">Element Order</a></td></tr> + </table> + </td> + </tr> + <tr> + <th>2.9</th><td><a href="#2.9">Mapping for Global Elements</a> + <table class="toc"> + <tr><th>2.9.1</th><td><a href="#2.9.1">Element Types</a></td></tr> + <tr><th>2.9.2</th><td><a href="#2.9.2">Element Map</a></td></tr> + </table> + </td> + </tr> + <tr> + <th>2.10</th><td><a href="#2.10">Mapping for Global Attributes</a></td> + </tr> + <tr> + <th>2.11</th><td><a href="#2.11">Mapping for <code>xsi:type</code> and Substitution Groups</a></td> + </tr> + <tr> + <th>2.12</th><td><a href="#2.12">Mapping for <code>any</code> and <code>anyAttribute</code></a> + <table class="toc"> + <tr><th>2.12.1</th><td><a href="#2.12.1">Mapping for <code>any</code> with the One Cardinality Class</a></td></tr> + <tr><th>2.12.2</th><td><a href="#2.12.2">Mapping for <code>any</code> with the Optional Cardinality Class</a></td></tr> + <tr><th>2.12.3</th><td><a href="#2.12.3">Mapping for <code>any</code> with the Sequence Cardinality Class</a></td></tr> + <tr><th>2.12.4</th><td><a href="#2.12.4">Element Wildcard Order</a></td></tr> + <tr><th>2.12.5</th><td><a href="#2.12.5">Mapping for <code>anyAttribute</code></a></td></tr> + </table> + </td> + </tr> + <tr> + <th>2.13</th><td><a href="#2.13">Mapping for Mixed Content Models</a></td> + </tr> + </table> + </td> + </tr> + + <tr> + <th>3</th><td><a href="#3">Parsing</a> + <table class="toc"> + <tr> + <th>3.1</th><td><a href="#3.1">Initializing the Xerces-C++ Runtime</a></td> + </tr> + <tr> + <th>3.2</th><td><a href="#3.2">Flags and Properties</a></td> + </tr> + <tr> + <th>3.3</th><td><a href="#3.3">Error Handling</a> + <table class="toc"> + <tr><th>3.3.1</th><td><a href="#3.3.1"><code>xml_schema::parsing</code></a></td></tr> + <tr><th>3.3.2</th><td><a href="#3.3.2"><code>xml_schema::expected_element</code></a></td></tr> + <tr><th>3.3.3</th><td><a href="#3.3.3"><code>xml_schema::unexpected_element</code></a></td></tr> + <tr><th>3.3.4</th><td><a href="#3.3.4"><code>xml_schema::expected_attribute</code></a></td></tr> + <tr><th>3.3.5</th><td><a href="#3.3.5"><code>xml_schema::unexpected_enumerator</code></a></td></tr> + <tr><th>3.3.6</th><td><a href="#3.3.6"><code>xml_schema::expected_text_content</code></a></td></tr> + <tr><th>3.3.7</th><td><a href="#3.3.7"><code>xml_schema::no_type_info</code></a></td></tr> + <tr><th>3.3.8</th><td><a href="#3.3.8"><code>xml_schema::not_derived</code></a></td></tr> + <tr><th>3.3.9</th><td><a href="#3.3.9"><code>xml_schema::not_prefix_mapping</code></a></td></tr> + </table> + </td> + </tr> + <tr> + <th>3.4</th><td><a href="#3.4">Reading from a Local File or URI</a></td> + </tr> + <tr> + <th>3.5</th><td><a href="#3.5">Reading from <code>std::istream</code></a></td> + </tr> + <tr> + <th>3.6</th><td><a href="#3.6">Reading from <code>xercesc::InputSource</code></a></td> + </tr> + <tr> + <th>3.7</th><td><a href="#3.7">Reading from DOM</a></td> + </tr> + </table> + </td> + </tr> + + <tr> + <th>4</th><td><a href="#4">Serialization</a> + <table class="toc"> + <tr> + <th>4.1</th><td><a href="#4.1">Initializing the Xerces-C++ Runtime</a></td> + </tr> + <tr> + <th>4.2</th><td><a href="#4.2">Namespace Infomap and Character Encoding</a></td> + </tr> + <tr> + <th>4.3</th><td><a href="#4.3">Flags</a></td> + </tr> + <tr> + <th>4.4</th><td><a href="#4.4">Error Handling</a> + <table class="toc"> + <tr><th>4.4.1</th><td><a href="#4.4.1"><code>xml_schema::serialization</code></a></td></tr> + <tr><th>4.4.2</th><td><a href="#4.4.2"><code>xml_schema::unexpected_element</code></a></td></tr> + <tr><th>4.4.3</th><td><a href="#4.4.3"><code>xml_schema::no_type_info</code></a></td></tr> + </table> + </td> + </tr> + <tr> + <th>4.5</th><td><a href="#4.5">Serializing to <code>std::ostream</code></a></td> + </tr> + <tr> + <th>4.6</th><td><a href="#4.6">Serializing to <code>xercesc::XMLFormatTarget</code></a></td> + </tr> + <tr> + <th>4.7</th><td><a href="#4.7">Serializing to DOM</a></td> + </tr> + </table> + </td> + </tr> + + <tr> + <th>5</th><td><a href="#5">Additional Functionality</a> + <table class="toc"> + <tr> + <th>5.1</th><td><a href="#5.1">DOM Association</a></td> + </tr> + <tr> + <th>5.2</th><td><a href="#5.2">Binary Serialization</a></td> + </tr> + </table> + </td> + </tr> + + <tr> + <th></th><td><a href="#A">Appendix A — Default and Fixed Values</a></td> + </tr> + + </table> + </div> + + <h1><a name="0">Preface</a></h1> + + <h2><a name="0.1">About This Document</a></h2> + + <p>This document describes the mapping of W3C XML Schema + to the C++ programming language as implemented by + <a href="http://www.codesynthesis.com/products/xsd">CodeSynthesis + XSD</a> - an XML Schema to C++ data binding compiler. The mapping + represents information stored in XML instance documents as a + statically-typed, tree-like in-memory data structure and is + called C++/Tree. + </p> + + <p>Revision 4.0.0<br/> <!-- Remember to change revision in other places --> + This revision of the manual describes the C++/Tree + mapping as implemented by CodeSynthesis XSD version 4.0.0. + </p> + + <p>This document is available in the following formats: + <a href="http://codesynthesis.com/projects/xsd/documentation/cxx/tree/manual/index.xhtml">XHTML</a>, + <a href="http://codesynthesis.com/projects/xsd/documentation/cxx/tree/manual/cxx-tree-manual.pdf">PDF</a>, and + <a href="http://codesynthesis.com/projects/xsd/documentation/cxx/tree/manual/cxx-tree-manual.ps">PostScript</a>.</p> + + <h2><a name="0.2">More Information</a></h2> + + <p>Beyond this manual, you may also find the following sources of + information useful:</p> + + <ul class="list"> + <li><a href="http://www.codesynthesis.com/projects/xsd/documentation/cxx/tree/guide/">C++/Tree + Mapping Getting Started Guide</a></li> + + <li><a href="http://wiki.codesynthesis.com/Tree/Customization_guide">C++/Tree + Mapping Customization Guide</a></li> + + <li><a href="http://wiki.codesynthesis.com/Tree/FAQ">C++/Tree + Mapping Frequently Asked Questions (FAQ)</a></li> + + <li><a href="http://www.codesynthesis.com/projects/xsd/documentation/xsd.xhtml">XSD + Compiler Command Line Manual</a></li> + + <li>The <code>examples/cxx/tree/</code> directory in the XSD + distribution contains a collection of examples and a README + file with an overview of each example.</li> + + <li>The <code>README</code> file in the XSD distribution explains + how to compile the examples on various platforms.</li> + + <li>The <a href="http://www.codesynthesis.com/mailman/listinfo/xsd-users">xsd-users</a> + mailing list is a place to ask questions. Furthermore the + <a href="http://www.codesynthesis.com/pipermail/xsd-users/">archives</a> + may already have answers to some of your questions.</li> + </ul> + + + <h1><a name="1">1 Introduction</a></h1> + + <p>C++/Tree is a W3C XML Schema to C++ mapping that represents the + data stored in XML as a statically-typed, vocabulary-specific + object model. Based on a formal description of an XML vocabulary + (schema), the C++/Tree mapping produces a tree-like data structure + suitable for in-memory processing as well as XML parsing and + serialization code.</p> + + <p>A typical application that processes XML documents usually + performs the following three steps: it first reads (parses) an XML + instance document to an object model, it then performs + some useful computations on that model which may involve + modification of the model, and finally it may write (serialize) + the modified object model back to XML. + </p> + + <p>The C++/Tree mapping consists of C++ types that represent the + given vocabulary (<a href="#2">Chapter 2, "C++/Tree Mapping"</a>), + a set of parsing functions that convert XML documents to + a tree-like in-memory data structure (<a href="#3">Chapter 3, + "Parsing"</a>), and a set of serialization functions that convert + the object model back to XML (<a href="#4">Chapter 4, + "Serialization"</a>). Furthermore, the mapping provides a number + of additional features, such as DOM association and binary + serialization, that can be useful in some applications + (<a href="#5">Chapter 5, "Additional Functionality"</a>). + </p> + + + <!-- Chapter 2 --> + + + <h1><a name="2">2 C++/Tree Mapping</a></h1> + + <h2><a name="2.1">2.1 Preliminary Information</a></h2> + + <h3><a name="2.1.1">2.1.1 C++ Standard</a></h3> + + <p>The C++/Tree mapping provides support for ISO/IEC C++ 1998/2003 (C++98) + and ISO/IEC C++ 2011 (C++11). To select the C++ standard for the + generated code we use the <code>--std</code> XSD compiler command + line option. While the majority of the examples in this manual use + C++98, support for the new functionality and library components + introduced in C++11 are discussed throughout the document.</p> + + <h3><a name="2.1.2">2.1.2 Identifiers</a></h3> + + <p>XML Schema names may happen to be reserved C++ keywords or contain + characters that are illegal in C++ identifiers. To avoid C++ compilation + problems, such names are changed (escaped) when mapped to C++. If an + XML Schema name is a C++ keyword, the "_" suffix is added to it. All + character of an XML Schema name that are not allowed in C++ identifiers + are replaced with "_". + </p> + + <p>For example, XML Schema name <code>try</code> will be mapped to + C++ identifier <code>try_</code>. Similarly, XML Schema name + <code>strange.na-me</code> will be mapped to C++ identifier + <code>strange_na_me</code>. + </p> + + <p>Furthermore, conflicts between type names and function names in the + same scope are resolved using name escaping. Such conflicts include + both a global element (which is mapped to a set of parsing and/or + serialization functions or element types, see <a href="#2.9">Section + 2.9, "Mapping for Global Elements"</a>) and a global type sharing the + same name as well as a local element or attribute inside a type having + the same name as the type itself.</p> + + <p>For example, if we had a global type <code>catalog</code> + and a global element with the same name then the type would be + mapped to a C++ class with name <code>catalog</code> while the + parsing functions corresponding to the global element would have + their names escaped as <code>catalog_</code>. + </p> + + <p>By default the mapping uses the so-called K&R (Kernighan and + Ritchie) identifier naming convention which is also used throughout + this manual. In this convention both type and function names are in + lower case and words are separated by underscores. If your application + code or schemas use a different notation, you may want to change the + naming convention used by the mapping for consistency. + The compiler supports a set of widely-used naming conventions + that you can select with the <code>--type-naming</code> and + <code>--function-naming</code> options. You can also further + refine one of the predefined conventions or create a completely + custom naming scheme by using the <code>--*-regex</code> options. + For more detailed information on these options refer to the NAMING + CONVENTION section in the <a href="http://www.codesynthesis.com/projects/xsd/documentation/xsd.xhtml">XSD + Compiler Command Line Manual</a>.</p> + + <h3><a name="2.1.3">2.1.3 Character Type and Encoding</a></h3> + + <p>The code that implements the mapping, depending on the + <code>--char-type</code> option, is generated using either + <code>char</code> or <code>wchar_t</code> as the character + type. In this document code samples use symbol <code>C</code> + to refer to the character type you have selected when translating + your schemas, for example <code>std::basic_string<C></code>. + </p> + + <p>Another aspect of the mapping that depends on the character type + is character encoding. For the <code>char</code> character type + the default encoding is UTF-8. Other supported encodings are + ISO-8859-1, Xerces-C++ Local Code Page (LPC), as well as + custom encodings and can be selected with the + <code>--char-encoding</code> command line option.</p> + + <p>For the <code>wchar_t</code> character type the encoding is + automatically selected between UTF-16 and UTF-32/UCS-4 depending + on the size of the <code>wchar_t</code> type. On some platforms + (for example, Windows with Visual C++ and AIX with IBM XL C++) + <code>wchar_t</code> is 2 bytes long. For these platforms the + encoding is UTF-16. On other platforms <code>wchar_t</code> is 4 bytes + long and UTF-32/UCS-4 is used.</p> + + <h3><a name="2.1.4">2.1.4 XML Schema Namespace</a></h3> + + <p>The mapping relies on some predefined types, classes, and functions + that are logically defined in the XML Schema namespace reserved for + the XML Schema language (<code>http://www.w3.org/2001/XMLSchema</code>). + By default, this namespace is mapped to C++ namespace + <code>xml_schema</code>. It is automatically accessible + from a C++ compilation unit that includes a header file generated + from an XML Schema definition. + </p> + + <p>Note that, if desired, the default mapping of this namespace can be + changed as described in <a href="#2.4">Section 2.4, "Mapping for + Namespaces"</a>. + </p> + + + <h3><a name="2.1.5">2.1.5 Anonymous Types</a></h3> + + <p>For the purpose of code generation, anonymous types defined in + XML Schema are automatically assigned names that are derived + from enclosing attributes and elements. Otherwise, such types + follows standard mapping rules for simple and complex type + definitions (see <a href="#2.6">Section 2.6, "Mapping for Simple Types"</a> + and <a href="#2.7">Section 2.7, "Mapping for Complex Types"</a>). + For example, in the following schema fragment: + </p> + + <pre class="xml"> +<element name="object"> + <complexType> + ... + </complexType> +</element> + </pre> + + <p>The anonymous type defined inside element <code>object</code> will + be given name <code>object</code>. The compiler has a number of + options that control the process of anonymous type naming. For more + information refer to the <a href="http://www.codesynthesis.com/projects/xsd/documentation/xsd.xhtml">XSD + Compiler Command Line Manual</a>.</p> + + + <h2><a name="2.2">2.2 Error Handling</a></h2> + + <p>The mapping uses the C++ exception handling mechanism as a primary way + of reporting error conditions. All exceptions that are specified in + this mapping derive from <code>xml_schema::exception</code> which + itself is derived from <code>std::exception</code>: + </p> + + <pre class="c++"> +struct exception: virtual std::exception +{ + friend + std::basic_ostream<C>& + operator<< (std::basic_ostream<C>& os, const exception& e) + { + e.print (os); + return os; + } + +protected: + virtual void + print (std::basic_ostream<C>&) const = 0; +}; + </pre> + + <p>The exception hierarchy supports "virtual" <code>operator<<</code> + which allows you to obtain diagnostics corresponding to the thrown + exception using the base exception interface. For example:</p> + + <pre class="c++"> +try +{ + ... +} +catch (const xml_schema::exception& e) +{ + cerr << e << endl; +} + </pre> + + <p>The following sub-sections describe exceptions thrown by the + types that constitute the object model. + <a href="#3.3">Section 3.3, "Error Handling"</a> of + <a href="#3">Chapter 3, "Parsing"</a> describes exceptions + and error handling mechanisms specific to the parsing functions. + <a href="#4.4">Section 4.4, "Error Handling"</a> of + <a href="#4">Chapter 4, "Serialization"</a> describes exceptions + and error handling mechanisms specific to the serialization functions. + </p> + + + <h3><a name="2.2.1">2.2.1 <code>xml_schema::duplicate_id</code></a></h3> + + <pre class="c++"> +struct duplicate_id: virtual exception +{ + duplicate_id (const std::basic_string<C>& id); + + const std::basic_string<C>& + id () const; + + virtual const char* + what () const throw (); +}; + </pre> + + <p>The <code>xml_schema::duplicate_id</code> is thrown when + a conflicting instance of <code>xml_schema::id</code> (see + <a href="#2.5">Section 2.5, "Mapping for Built-in Data Types"</a>) + is added to a tree. The offending ID value can be obtained using + the <code>id</code> function. + </p> + + <h2><a name="2.3">2.3 Mapping for <code>import</code> and <code>include</code></a></h2> + + <h3><a name="2.3.1">2.3.1 Import</a></h3> + + <p>The XML Schema <code>import</code> element is mapped to the C++ + Preprocessor <code>#include</code> directive. The value of + the <code>schemaLocation</code> attribute is used to derive + the name of the header file that appears in the <code>#include</code> + directive. For instance: + </p> + + <pre class="xml"> +<import namespace="http://www.codesynthesis.com/test" + schemaLocation="test.xsd"/> + </pre> + + <p>is mapped to:</p> + + <pre class="c++"> +#include "test.hxx" + </pre> + + <p>Note that you will need to compile imported schemas separately + in order to produce corresponding header files.</p> + + <h3><a name="2.3.2">2.3.2 Inclusion with Target Namespace</a></h3> + + <p>The XML Schema <code>include</code> element which refers to a schema + with a target namespace or appears in a schema without a target namespace + follows the same mapping rules as the <code>import</code> element, + see <a href="#2.3.1">Section 2.3.1, "Import"</a>. + </p> + + <h3><a name="2.3.3">2.3.3 Inclusion without Target Namespace</a></h3> + + <p>For the XML Schema <code>include</code> element which refers to a schema + without a target namespace and appears in a schema with a target + namespace (such inclusion sometimes called "chameleon inclusion"), + declarations and definitions from the included schema are generated + in-line in the namespace of the including schema as if they were + declared and defined there verbatim. For example, consider the + following two schemas: + </p> + + <pre class="xml"> +<-- common.xsd --> +<schema> + <complexType name="type"> + ... + </complexType> +</schema> + +<-- test.xsd --> +<schema targetNamespace="http://www.codesynthesis.com/test"> + <include schemaLocation="common.xsd"/> +</schema> + </pre> + + <p>The fragment of interest from the generated header file for + <code>text.xsd</code> would look like this:</p> + + <pre class="c++"> +// test.hxx +namespace test +{ + class type + { + ... + }; +} + </pre> + + <h2><a name="2.4">2.4 Mapping for Namespaces</a></h2> + + <p>An XML Schema namespace is mapped to one or more nested C++ + namespaces. XML Schema namespaces are identified by URIs. + By default, a namespace URI is mapped to a sequence of + C++ namespace names by removing the protocol and host parts + and splitting the rest into a sequence of names with '<code>/</code>' + as the name separator. For instance: + </p> + + <pre class="xml"> +<schema targetNamespace="http://www.codesynthesis.com/system/test"> + ... +</schema> + </pre> + + <p>is mapped to:</p> + + <pre class="c++"> +namespace system +{ + namespace test + { + ... + } +} + </pre> + + <p>The default mapping of namespace URIs to C++ namespace names can be + altered using the <code>--namespace-map</code> and + <code>--namespace-regex</code> options. See the + <a href="http://www.codesynthesis.com/projects/xsd/documentation/xsd.xhtml">XSD + Compiler Command Line Manual</a> for more information. + </p> + + <h2><a name="2.5">2.5 Mapping for Built-in Data Types</a></h2> + + <p>The mapping of XML Schema built-in data types to C++ types is + summarized in the table below.</p> + + <!-- border="1" is necessary for html2ps --> + <table id="builtin" border="1"> + <tr> + <th>XML Schema type</th> + <th>Alias in the <code>xml_schema</code> namespace</th> + <th>C++ type</th> + </tr> + + <tr> + <th colspan="3">anyType and anySimpleType types</th> + </tr> + <tr> + <td><code>anyType</code></td> + <td><code>type</code></td> + <td><a href="#2.5.2">Section 2.5.2, "Mapping for <code>anyType</code>"</a></td> + </tr> + <tr> + <td><code>anySimpleType</code></td> + <td><code>simple_type</code></td> + <td><a href="#2.5.3">Section 2.5.3, "Mapping for <code>anySimpleType</code>"</a></td> + </tr> + + <tr> + <th colspan="3">fixed-length integral types</th> + </tr> + <!-- 8-bit --> + <tr> + <td><code>byte</code></td> + <td><code>byte</code></td> + <td><code>signed char</code></td> + </tr> + <tr> + <td><code>unsignedByte</code></td> + <td><code>unsigned_byte</code></td> + <td><code>unsigned char</code></td> + </tr> + + <!-- 16-bit --> + <tr> + <td><code>short</code></td> + <td><code>short_</code></td> + <td><code>short</code></td> + </tr> + <tr> + <td><code>unsignedShort</code></td> + <td><code>unsigned_short</code></td> + <td><code>unsigned short</code></td> + </tr> + + <!-- 32-bit --> + <tr> + <td><code>int</code></td> + <td><code>int_</code></td> + <td><code>int</code></td> + </tr> + <tr> + <td><code>unsignedInt</code></td> + <td><code>unsigned_int</code></td> + <td><code>unsigned int</code></td> + </tr> + + <!-- 64-bit --> + <tr> + <td><code>long</code></td> + <td><code>long_</code></td> + <td><code>long long</code></td> + </tr> + <tr> + <td><code>unsignedLong</code></td> + <td><code>unsigned_long</code></td> + <td><code>unsigned long long</code></td> + </tr> + + <tr> + <th colspan="3">arbitrary-length integral types</th> + </tr> + <tr> + <td><code>integer</code></td> + <td><code>integer</code></td> + <td><code>long long</code></td> + </tr> + <tr> + <td><code>nonPositiveInteger</code></td> + <td><code>non_positive_integer</code></td> + <td><code>long long</code></td> + </tr> + <tr> + <td><code>nonNegativeInteger</code></td> + <td><code>non_negative_integer</code></td> + <td><code>unsigned long long</code></td> + </tr> + <tr> + <td><code>positiveInteger</code></td> + <td><code>positive_integer</code></td> + <td><code>unsigned long long</code></td> + </tr> + <tr> + <td><code>negativeInteger</code></td> + <td><code>negative_integer</code></td> + <td><code>long long</code></td> + </tr> + + <tr> + <th colspan="3">boolean types</th> + </tr> + <tr> + <td><code>boolean</code></td> + <td><code>boolean</code></td> + <td><code>bool</code></td> + </tr> + + <tr> + <th colspan="3">fixed-precision floating-point types</th> + </tr> + <tr> + <td><code>float</code></td> + <td><code>float_</code></td> + <td><code>float</code></td> + </tr> + <tr> + <td><code>double</code></td> + <td><code>double_</code></td> + <td><code>double</code></td> + </tr> + + <tr> + <th colspan="3">arbitrary-precision floating-point types</th> + </tr> + <tr> + <td><code>decimal</code></td> + <td><code>decimal</code></td> + <td><code>double</code></td> + </tr> + + <tr> + <th colspan="3">string types</th> + </tr> + <tr> + <td><code>string</code></td> + <td><code>string</code></td> + <td>type derived from <code>std::basic_string</code></td> + </tr> + <tr> + <td><code>normalizedString</code></td> + <td><code>normalized_string</code></td> + <td>type derived from <code>string</code></td> + </tr> + <tr> + <td><code>token</code></td> + <td><code>token</code></td> + <td>type derived from <code>normalized_string</code></td> + </tr> + <tr> + <td><code>Name</code></td> + <td><code>name</code></td> + <td>type derived from <code>token</code></td> + </tr> + <tr> + <td><code>NMTOKEN</code></td> + <td><code>nmtoken</code></td> + <td>type derived from <code>token</code></td> + </tr> + <tr> + <td><code>NMTOKENS</code></td> + <td><code>nmtokens</code></td> + <td>type derived from <code>sequence<nmtoken></code></td> + </tr> + <tr> + <td><code>NCName</code></td> + <td><code>ncname</code></td> + <td>type derived from <code>name</code></td> + </tr> + <tr> + <td><code>language</code></td> + <td><code>language</code></td> + <td>type derived from <code>token</code></td> + </tr> + + <tr> + <th colspan="3">qualified name</th> + </tr> + <tr> + <td><code>QName</code></td> + <td><code>qname</code></td> + <td><a href="#2.5.4">Section 2.5.4, "Mapping for <code>QName</code>"</a></td> + </tr> + + <tr> + <th colspan="3">ID/IDREF types</th> + </tr> + <tr> + <td><code>ID</code></td> + <td><code>id</code></td> + <td>type derived from <code>ncname</code></td> + </tr> + <tr> + <td><code>IDREF</code></td> + <td><code>idref</code></td> + <td><a href="#2.5.5">Section 2.5.5, "Mapping for <code>IDREF</code>"</a></td> + </tr> + <tr> + <td><code>IDREFS</code></td> + <td><code>idrefs</code></td> + <td>type derived from <code>sequence<idref></code></td> + </tr> + + <tr> + <th colspan="3">URI types</th> + </tr> + <tr> + <td><code>anyURI</code></td> + <td><code>uri</code></td> + <td>type derived from <code>std::basic_string</code></td> + </tr> + + <tr> + <th colspan="3">binary types</th> + </tr> + <tr> + <td><code>base64Binary</code></td> + <td><code>base64_binary</code></td> + <td rowspan="2"><a href="#2.5.6">Section 2.5.6, "Mapping for + <code>base64Binary</code> and <code>hexBinary</code>"</a></td> + </tr> + <tr> + <td><code>hexBinary</code></td> + <td><code>hex_binary</code></td> + </tr> + + <tr> + <th colspan="3">date/time types</th> + </tr> + <tr> + <td><code>date</code></td> + <td><code>date</code></td> + <td><a href="#2.5.8">Section 2.5.8, "Mapping for + <code>date</code>"</a></td> + </tr> + <tr> + <td><code>dateTime</code></td> + <td><code>date_time</code></td> + <td><a href="#2.5.9">Section 2.5.9, "Mapping for + <code>dateTime</code>"</a></td> + </tr> + <tr> + <td><code>duration</code></td> + <td><code>duration</code></td> + <td><a href="#2.5.10">Section 2.5.10, "Mapping for + <code>duration</code>"</a></td> + </tr> + <tr> + <td><code>gDay</code></td> + <td><code>gday</code></td> + <td><a href="#2.5.11">Section 2.5.11, "Mapping for + <code>gDay</code>"</a></td> + </tr> + <tr> + <td><code>gMonth</code></td> + <td><code>gmonth</code></td> + <td><a href="#2.5.12">Section 2.5.12, "Mapping for + <code>gMonth</code>"</a></td> + </tr> + <tr> + <td><code>gMonthDay</code></td> + <td><code>gmonth_day</code></td> + <td><a href="#2.5.13">Section 2.5.13, "Mapping for + <code>gMonthDay</code>"</a></td> + </tr> + <tr> + <td><code>gYear</code></td> + <td><code>gyear</code></td> + <td><a href="#2.5.14">Section 2.5.14, "Mapping for + <code>gYear</code>"</a></td> + </tr> + <tr> + <td><code>gYearMonth</code></td> + <td><code>gyear_month</code></td> + <td><a href="#2.5.15">Section 2.5.15, "Mapping for + <code>gYearMonth</code>"</a></td> + </tr> + <tr> + <td><code>time</code></td> + <td><code>time</code></td> + <td><a href="#2.5.16">Section 2.5.16, "Mapping for + <code>time</code>"</a></td> + </tr> + + <tr> + <th colspan="3">entity types</th> + </tr> + <tr> + <td><code>ENTITY</code></td> + <td><code>entity</code></td> + <td>type derived from <code>name</code></td> + </tr> + <tr> + <td><code>ENTITIES</code></td> + <td><code>entities</code></td> + <td>type derived from <code>sequence<entity></code></td> + </tr> + </table> + + <p>All XML Schema built-in types are mapped to C++ classes that are + derived from the <code>xml_schema::simple_type</code> class except + where the mapping is to a fundamental C++ type.</p> + + <p>The <code>sequence</code> class template is defined in an + implementation-specific namespace. It conforms to the + sequence interface as defined by the ISO/ANSI Standard for + C++ (ISO/IEC 14882:1998, Section 23.1.1, "Sequences"). + Practically, this means that you can treat such a sequence + as if it was <code>std::vector</code>. One notable extension + to the standard interface that is available only for + sequences of non-fundamental C++ types is the addition of + the overloaded <code>push_back</code> and <code>insert</code> + member functions which instead of the constant reference + to the element type accept automatic pointer (<code>std::auto_ptr</code> + or <code>std::unique_ptr</code>, depending on the C++ standard + selected) to the element type. These functions assume ownership + of the pointed to object and reset the passed automatic pointer. + </p> + + <h3><a name="2.5.1">2.5.1 Inheritance from Built-in Data Types</a></h3> + + <p>In cases where the mapping calls for an inheritance from a built-in + type which is mapped to a fundamental C++ type, a proxy type is + used instead of the fundamental C++ type (C++ does not allow + inheritance from fundamental types). For instance:</p> + + <pre class="xml"> +<simpleType name="my_int"> + <restriction base="int"/> +</simpleType> + </pre> + + <p>is mapped to:</p> + + <pre class="c++"> +class my_int: public fundamental_base<int> +{ + ... +}; + </pre> + + <p>The <code>fundamental_base</code> class template provides a close + emulation (though not exact) of a fundamental C++ type. + It is defined in an implementation-specific namespace and has the + following interface:</p> + + <pre class="c++"> +template <typename X> +class fundamental_base: public simple_type +{ +public: + fundamental_base (); + fundamental_base (X) + fundamental_base (const fundamental_base&) + +public: + fundamental_base& + operator= (const X&); + +public: + operator const X & () const; + operator X& (); + + template <typename Y> + operator Y () const; + + template <typename Y> + operator Y (); +}; + </pre> + + <h3><a name="2.5.2">2.5.2 Mapping for <code>anyType</code></a></h3> + + <p>The XML Schema <code>anyType</code> built-in data type is mapped to the + <code>xml_schema::type</code> C++ class:</p> + + <pre class="c++"> +class type +{ +public: + virtual + ~type (); + + type (); + type (const type&); + + type& + operator= (const type&); + + virtual type* + _clone () const; + + // anyType DOM content. + // +public: + typedef element_optional dom_content_optional; + + const dom_content_optional& + dom_content () const; + + dom_content_optional& + dom_content (); + + void + dom_content (const xercesc::DOMElement&); + + void + dom_content (xercesc::DOMElement*); + + void + dom_content (const dom_content_optional&); + + const xercesc::DOMDocument& + dom_content_document () const; + + xercesc::DOMDocument& + dom_content_document (); + + bool + null_content () const; + + // DOM association. + // +public: + const xercesc::DOMNode* + _node () const; + + xercesc::DOMNode* + _node (); +}; + </pre> + + <p>When <code>xml_schema::type</code> is used to create an instance + (as opposed to being a base of a derived type), it represents + the XML Schema <code>anyType</code> type. <code>anyType</code> + allows any attributes and any content in any order. In the + C++/Tree mapping this content can be represented as a DOM + fragment, similar to XML Schema wildcards (<a href="#2.12">Section + 2.12, "Mapping for <code>any</code> and + <code>anyAttribute</code>"</a>).</p> + + <p>To enable automatic extraction of <code>anyType</code> content + during parsing, the <code>--generate-any-type</code> option must be + specified. Because the DOM API is used to access such content, the + Xerces-C++ runtime should be initialized by the application prior to + parsing and should remain initialized for the lifetime of objects + with the DOM content. For more information on the Xerces-C++ runtime + initialization see <a href="#3.1">Section 3.1, "Initializing the + Xerces-C++ Runtime"</a>.</p> + + <p>The DOM content is stored as the optional DOM element container + and the DOM content accessors and modifiers presented above are + identical to those generated for an optional element wildcard. + Refer to <a href="#2.12.2">Section 2.12.2, "Mapping for <code>any</code> + with the Optional Cardinality Class"</a> for details on their + semantics.</p> + + <p>The <code>dom_content_document()</code> function returns the + DOM document used to store the raw XML content corresponding + to the <code>anyType</code> instance. It is equivalent to the + <code>dom_document()</code> function generated for types + with wildcards.</p> + + <p>The <code>null_content()</code> accessor is an optimization function + that allows us to check for the lack of content without actually + creating its empty representation, that is, empty DOM document for + <code>anyType</code> or empty string for <code>anySimpleType</code> + (see the following section for details on <code>anySimpleType</code>).</p> + + <p>For more information on DOM association refer to + <a href="#5.1">Section 5.1, "DOM Association"</a>.</p> + + <h3><a name="2.5.3">2.5.3 Mapping for <code>anySimpleType</code></a></h3> + + <p>The XML Schema <code>anySimpleType</code> built-in data type is mapped + to the <code>xml_schema::simple_type</code> C++ class:</p> + + <pre class="c++"> +class simple_type: public type +{ +public: + simple_type (); + simple_type (const C*); + simple_type (const std::basic_string<C>&); + + simple_type (const simple_type&); + + simple_type& + operator= (const simple_type&); + + virtual simple_type* + _clone () const; + + // anySimpleType text content. + // +public: + const std::basic_string<C>& + text_content () const; + + std::basic_string<C>& + text_content (); + + void + text_content (const std::basic_string<C>&); +}; + </pre> + + <p>When <code>xml_schema::simple_type</code> is used to create an instance + (as opposed to being a base of a derived type), it represents + the XML Schema <code>anySimpleType</code> type. <code>anySimpleType</code> + allows any simple content. In the C++/Tree mapping this content can + be represented as a string and accessed or modified with the + <code>text_content()</code> functions shown above.</p> + + <h3><a name="2.5.4">2.5.4 Mapping for <code>QName</code></a></h3> + + <p>The XML Schema <code>QName</code> built-in data type is mapped to the + <code>xml_schema::qname</code> C++ class:</p> + + <pre class="c++"> +class qname: public simple_type +{ +public: + qname (const ncname&); + qname (const uri&, const ncname&); + qname (const qname&); + +public: + qname& + operator= (const qname&); + +public: + virtual qname* + _clone () const; + +public: + bool + qualified () const; + + const uri& + namespace_ () const; + + const ncname& + name () const; +}; + </pre> + + <p>The <code>qualified</code> accessor function can be used to determine + if the name is qualified.</p> + + <h3><a name="2.5.5">2.5.5 Mapping for <code>IDREF</code></a></h3> + + <p>The XML Schema <code>IDREF</code> built-in data type is mapped to the + <code>xml_schema::idref</code> C++ class. This class implements the + smart pointer C++ idiom:</p> + + <pre class="c++"> +class idref: public ncname +{ +public: + idref (const C* s); + idref (const C* s, std::size_t n); + idref (std::size_t n, C c); + idref (const std::basic_string<C>&); + idref (const std::basic_string<C>&, + std::size_t pos, + std::size_t n = npos); + +public: + idref (const idref&); + +public: + virtual idref* + _clone () const; + +public: + idref& + operator= (C c); + + idref& + operator= (const C* s); + + idref& + operator= (const std::basic_string<C>&) + + idref& + operator= (const idref&); + +public: + const type* + operator-> () const; + + type* + operator-> (); + + const type& + operator* () const; + + type& + operator* (); + + const type* + get () const; + + type* + get (); + + // Conversion to bool. + // +public: + typedef void (idref::*bool_convertible)(); + operator bool_convertible () const; +}; + </pre> + + <p>The object, <code>idref</code> instance refers to, is the immediate + container of the matching <code>id</code> instance. For example, + with the following instance document and schema: + </p> + + + <pre class="xml"> +<!-- test.xml --> +<root> + <object id="obj-1" text="hello"/> + <reference>obj-1</reference> +</root> + +<!-- test.xsd --> +<schema> + <complexType name="object_type"> + <attribute name="id" type="ID"/> + <attribute name="text" type="string"/> + </complexType> + + <complexType name="root_type"> + <sequence> + <element name="object" type="object_type"/> + <element name="reference" type="IDREF"/> + </sequence> + </complexType> + + <element name="root" type="root_type"/> +</schema> + </pre> + + <p>The <code>ref</code> instance in the code below will refer to + an object of type <code>object_type</code>:</p> + + <pre class="c++"> +root_type& root = ...; +xml_schema::idref& ref (root.reference ()); +object_type& obj (dynamic_cast<object_type&> (*ref)); +cout << obj.text () << endl; + </pre> + + <p>The smart pointer interface of the <code>idref</code> class always + returns a pointer or reference to <code>xml_schema::type</code>. + This means that you will need to manually cast such pointer or + reference to its real (dynamic) type before you can use it (unless + all you need is the base interface provided by + <code>xml_schema::type</code>). As a special extension to the XML + Schema language, the mapping supports static typing of <code>idref</code> + references by employing the <code>refType</code> extension attribute. + The following example illustrates this mechanism: + </p> + + <pre class="xml"> +<!-- test.xsd --> +<schema + xmlns:xse="http://www.codesynthesis.com/xmlns/xml-schema-extension"> + + ... + + <element name="reference" type="IDREF" xse:refType="object_type"/> + + ... + +</schema> + </pre> + + <p>With this modification we do not need to do manual casting anymore: + </p> + + <pre class="c++"> +root_type& root = ...; +root_type::reference_type& ref (root.reference ()); +object_type& obj (*ref); +cout << ref->text () << endl; + </pre> + + + <h3><a name="2.5.6">2.5.6 Mapping for <code>base64Binary</code> and + <code>hexBinary</code></a></h3> + + <p>The XML Schema <code>base64Binary</code> and <code>hexBinary</code> + built-in data types are mapped to the + <code>xml_schema::base64_binary</code> and + <code>xml_schema::hex_binary</code> C++ classes, respectively. The + <code>base64_binary</code> and <code>hex_binary</code> classes + support a simple buffer abstraction by inheriting from the + <code>xml_schema::buffer</code> class: + </p> + + <pre class="c++"> +class bounds: public virtual exception +{ +public: + virtual const char* + what () const throw (); +}; + +class buffer +{ +public: + typedef std::size_t size_t; + +public: + buffer (size_t size = 0); + buffer (size_t size, size_t capacity); + buffer (const void* data, size_t size); + buffer (const void* data, size_t size, size_t capacity); + buffer (void* data, + size_t size, + size_t capacity, + bool assume_ownership); + +public: + buffer (const buffer&); + + buffer& + operator= (const buffer&); + + void + swap (buffer&); + +public: + size_t + capacity () const; + + bool + capacity (size_t); + +public: + size_t + size () const; + + bool + size (size_t); + +public: + const char* + data () const; + + char* + data (); + + const char* + begin () const; + + char* + begin (); + + const char* + end () const; + + char* + end (); +}; + </pre> + + <p>The last overloaded constructor reuses an existing data buffer instead + of making a copy. If the <code>assume_ownership</code> argument is + <code>true</code>, the instance assumes ownership of the + memory block pointed to by the <code>data</code> argument and will + eventually release it by calling <code>operator delete</code>. The + <code>capacity</code> and <code>size</code> modifier functions return + <code>true</code> if the underlying buffer has moved. + </p> + + <p>The <code>bounds</code> exception is thrown if the constructor + arguments violate the <code>(size <= capacity)</code> + constraint.</p> + + <p>The <code>base64_binary</code> and <code>hex_binary</code> classes + support the <code>buffer</code> interface and perform automatic + decoding/encoding from/to the Base64 and Hex formats, respectively: + </p> + + <pre class="c++"> +class base64_binary: public simple_type, public buffer +{ +public: + base64_binary (size_t size = 0); + base64_binary (size_t size, size_t capacity); + base64_binary (const void* data, size_t size); + base64_binary (const void* data, size_t size, size_t capacity); + base64_binary (void* data, + size_t size, + size_t capacity, + bool assume_ownership); + +public: + base64_binary (const base64_binary&); + + base64_binary& + operator= (const base64_binary&); + + virtual base64_binary* + _clone () const; + +public: + std::basic_string<C> + encode () const; +}; + </pre> + + <pre class="c++"> +class hex_binary: public simple_type, public buffer +{ +public: + hex_binary (size_t size = 0); + hex_binary (size_t size, size_t capacity); + hex_binary (const void* data, size_t size); + hex_binary (const void* data, size_t size, size_t capacity); + hex_binary (void* data, + size_t size, + size_t capacity, + bool assume_ownership); + +public: + hex_binary (const hex_binary&); + + hex_binary& + operator= (const hex_binary&); + + virtual hex_binary* + _clone () const; + +public: + std::basic_string<C> + encode () const; +}; + </pre> + + + <h2><a name="2.5.7">2.5.7 Time Zone Representation</a></h2> + + <p>The <code>date</code>, <code>dateTime</code>, <code>gDay</code>, + <code>gMonth</code>, <code>gMonthDay</code>, <code>gYear</code>, + <code>gYearMonth</code>, and <code>time</code> XML Schema built-in + types all include an optional time zone component. The following + <code>xml_schema::time_zone</code> base class is used to represent + this information:</p> + + <pre class="c++"> +class time_zone +{ +public: + time_zone (); + time_zone (short hours, short minutes); + + bool + zone_present () const; + + void + zone_reset (); + + short + zone_hours () const; + + void + zone_hours (short); + + short + zone_minutes () const; + + void + zone_minutes (short); +}; + +bool +operator== (const time_zone&, const time_zone&); + +bool +operator!= (const time_zone&, const time_zone&); + </pre> + + <p>The <code>zone_present()</code> accessor function returns <code>true</code> + if the time zone is specified. The <code>zone_reset()</code> modifier + function resets the time zone object to the <em>not specified</em> + state. If the time zone offset is negative then both hours and + minutes components are represented as negative integers.</p> + + + <h2><a name="2.5.8">2.5.8 Mapping for <code>date</code></a></h2> + + <p>The XML Schema <code>date</code> built-in data type is mapped to the + <code>xml_schema::date</code> C++ class which represents a year, a day, + and a month with an optional time zone. Its interface is presented + below. For more information on the base <code>xml_schema::time_zone</code> + class refer to <a href="#2.5.7">Section 2.5.7, "Time Zone + Representation"</a>.</p> + + <pre class="c++"> +class date: public simple_type, public time_zone +{ +public: + date (int year, unsigned short month, unsigned short day); + date (int year, unsigned short month, unsigned short day, + short zone_hours, short zone_minutes); + +public: + date (const date&); + + date& + operator= (const date&); + + virtual date* + _clone () const; + +public: + int + year () const; + + void + year (int); + + unsigned short + month () const; + + void + month (unsigned short); + + unsigned short + day () const; + + void + day (unsigned short); +}; + +bool +operator== (const date&, const date&); + +bool +operator!= (const date&, const date&); + </pre> + + <h2><a name="2.5.9">2.5.9 Mapping for <code>dateTime</code></a></h2> + + <p>The XML Schema <code>dateTime</code> built-in data type is mapped to the + <code>xml_schema::date_time</code> C++ class which represents a year, a month, + a day, hours, minutes, and seconds with an optional time zone. Its interface + is presented below. For more information on the base + <code>xml_schema::time_zone</code> class refer to <a href="#2.5.7">Section + 2.5.7, "Time Zone Representation"</a>.</p> + + <pre class="c++"> +class date_time: public simple_type, public time_zone +{ +public: + date_time (int year, unsigned short month, unsigned short day, + unsigned short hours, unsigned short minutes, + double seconds); + + date_time (int year, unsigned short month, unsigned short day, + unsigned short hours, unsigned short minutes, + double seconds, short zone_hours, short zone_minutes); +public: + date_time (const date_time&); + + date_time& + operator= (const date_time&); + + virtual date_time* + _clone () const; + +public: + int + year () const; + + void + year (int); + + unsigned short + month () const; + + void + month (unsigned short); + + unsigned short + day () const; + + void + day (unsigned short); + + unsigned short + hours () const; + + void + hours (unsigned short); + + unsigned short + minutes () const; + + void + minutes (unsigned short); + + double + seconds () const; + + void + seconds (double); +}; + +bool +operator== (const date_time&, const date_time&); + +bool +operator!= (const date_time&, const date_time&); + </pre> + + + <h2><a name="2.5.10">2.5.10 Mapping for <code>duration</code></a></h2> + + <p>The XML Schema <code>duration</code> built-in data type is mapped to the + <code>xml_schema::duration</code> C++ class which represents a potentially + negative duration in the form of years, months, days, hours, minutes, + and seconds. Its interface is presented below.</p> + + <pre class="c++"> +class duration: public simple_type +{ +public: + duration (bool negative, + unsigned int years, unsigned int months, unsigned int days, + unsigned int hours, unsigned int minutes, double seconds); +public: + duration (const duration&); + + duration& + operator= (const duration&); + + virtual duration* + _clone () const; + +public: + bool + negative () const; + + void + negative (bool); + + unsigned int + years () const; + + void + years (unsigned int); + + unsigned int + months () const; + + void + months (unsigned int); + + unsigned int + days () const; + + void + days (unsigned int); + + unsigned int + hours () const; + + void + hours (unsigned int); + + unsigned int + minutes () const; + + void + minutes (unsigned int); + + double + seconds () const; + + void + seconds (double); +}; + +bool +operator== (const duration&, const duration&); + +bool +operator!= (const duration&, const duration&); + </pre> + + + <h2><a name="2.5.11">2.5.11 Mapping for <code>gDay</code></a></h2> + + <p>The XML Schema <code>gDay</code> built-in data type is mapped to the + <code>xml_schema::gday</code> C++ class which represents a day of the + month with an optional time zone. Its interface is presented below. + For more information on the base <code>xml_schema::time_zone</code> + class refer to <a href="#2.5.7">Section 2.5.7, "Time Zone + Representation"</a>.</p> + + <pre class="c++"> +class gday: public simple_type, public time_zone +{ +public: + explicit + gday (unsigned short day); + gday (unsigned short day, short zone_hours, short zone_minutes); + +public: + gday (const gday&); + + gday& + operator= (const gday&); + + virtual gday* + _clone () const; + +public: + unsigned short + day () const; + + void + day (unsigned short); +}; + +bool +operator== (const gday&, const gday&); + +bool +operator!= (const gday&, const gday&); + </pre> + + + <h2><a name="2.5.12">2.5.12 Mapping for <code>gMonth</code></a></h2> + + <p>The XML Schema <code>gMonth</code> built-in data type is mapped to the + <code>xml_schema::gmonth</code> C++ class which represents a month of the + year with an optional time zone. Its interface is presented below. + For more information on the base <code>xml_schema::time_zone</code> + class refer to <a href="#2.5.7">Section 2.5.7, "Time Zone + Representation"</a>.</p> + + <pre class="c++"> +class gmonth: public simple_type, public time_zone +{ +public: + explicit + gmonth (unsigned short month); + gmonth (unsigned short month, + short zone_hours, short zone_minutes); + +public: + gmonth (const gmonth&); + + gmonth& + operator= (const gmonth&); + + virtual gmonth* + _clone () const; + +public: + unsigned short + month () const; + + void + month (unsigned short); +}; + +bool +operator== (const gmonth&, const gmonth&); + +bool +operator!= (const gmonth&, const gmonth&); + </pre> + + + <h2><a name="2.5.13">2.5.13 Mapping for <code>gMonthDay</code></a></h2> + + <p>The XML Schema <code>gMonthDay</code> built-in data type is mapped to the + <code>xml_schema::gmonth_day</code> C++ class which represents a day and + a month of the year with an optional time zone. Its interface is presented + below. For more information on the base <code>xml_schema::time_zone</code> + class refer to <a href="#2.5.7">Section 2.5.7, "Time Zone + Representation"</a>.</p> + + <pre class="c++"> +class gmonth_day: public simple_type, public time_zone +{ +public: + gmonth_day (unsigned short month, unsigned short day); + gmonth_day (unsigned short month, unsigned short day, + short zone_hours, short zone_minutes); + +public: + gmonth_day (const gmonth_day&); + + gmonth_day& + operator= (const gmonth_day&); + + virtual gmonth_day* + _clone () const; + +public: + unsigned short + month () const; + + void + month (unsigned short); + + unsigned short + day () const; + + void + day (unsigned short); +}; + +bool +operator== (const gmonth_day&, const gmonth_day&); + +bool +operator!= (const gmonth_day&, const gmonth_day&); + </pre> + + + <h2><a name="2.5.14">2.5.14 Mapping for <code>gYear</code></a></h2> + + <p>The XML Schema <code>gYear</code> built-in data type is mapped to the + <code>xml_schema::gyear</code> C++ class which represents a year with + an optional time zone. Its interface is presented below. For more + information on the base <code>xml_schema::time_zone</code> class refer + to <a href="#2.5.7">Section 2.5.7, "Time Zone Representation"</a>.</p> + + <pre class="c++"> +class gyear: public simple_type, public time_zone +{ +public: + explicit + gyear (int year); + gyear (int year, short zone_hours, short zone_minutes); + +public: + gyear (const gyear&); + + gyear& + operator= (const gyear&); + + virtual gyear* + _clone () const; + +public: + int + year () const; + + void + year (int); +}; + +bool +operator== (const gyear&, const gyear&); + +bool +operator!= (const gyear&, const gyear&); + </pre> + + + <h2><a name="2.5.15">2.5.15 Mapping for <code>gYearMonth</code></a></h2> + + <p>The XML Schema <code>gYearMonth</code> built-in data type is mapped to + the <code>xml_schema::gyear_month</code> C++ class which represents + a year and a month with an optional time zone. Its interface is presented + below. For more information on the base <code>xml_schema::time_zone</code> + class refer to <a href="#2.5.7">Section 2.5.7, "Time Zone + Representation"</a>.</p> + + <pre class="c++"> +class gyear_month: public simple_type, public time_zone +{ +public: + gyear_month (int year, unsigned short month); + gyear_month (int year, unsigned short month, + short zone_hours, short zone_minutes); +public: + gyear_month (const gyear_month&); + + gyear_month& + operator= (const gyear_month&); + + virtual gyear_month* + _clone () const; + +public: + int + year () const; + + void + year (int); + + unsigned short + month () const; + + void + month (unsigned short); +}; + +bool +operator== (const gyear_month&, const gyear_month&); + +bool +operator!= (const gyear_month&, const gyear_month&); + </pre> + + + <h2><a name="2.5.16">2.5.16 Mapping for <code>time</code></a></h2> + + <p>The XML Schema <code>time</code> built-in data type is mapped to + the <code>xml_schema::time</code> C++ class which represents hours, + minutes, and seconds with an optional time zone. Its interface is + presented below. For more information on the base + <code>xml_schema::time_zone</code> class refer to + <a href="#2.5.7">Section 2.5.7, "Time Zone Representation"</a>.</p> + + <pre class="c++"> +class time: public simple_type, public time_zone +{ +public: + time (unsigned short hours, unsigned short minutes, double seconds); + time (unsigned short hours, unsigned short minutes, double seconds, + short zone_hours, short zone_minutes); + +public: + time (const time&); + + time& + operator= (const time&); + + virtual time* + _clone () const; + +public: + unsigned short + hours () const; + + void + hours (unsigned short); + + unsigned short + minutes () const; + + void + minutes (unsigned short); + + double + seconds () const; + + void + seconds (double); +}; + +bool +operator== (const time&, const time&); + +bool +operator!= (const time&, const time&); + </pre> + + + <!-- Mapping for Simple Types --> + + <h2><a name="2.6">2.6 Mapping for Simple Types</a></h2> + + <p>An XML Schema simple type is mapped to a C++ class with the same + name as the simple type. The class defines a public copy constructor, + a public copy assignment operator, and a public virtual + <code>_clone</code> function. The <code>_clone</code> function is + declared <code>const</code>, does not take any arguments, and returns + a pointer to a complete copy of the instance allocated in the free + store. The <code>_clone</code> function shall be used to make copies + when static type and dynamic type of the instance may differ (see + <a href="#2.11">Section 2.11, "Mapping for <code>xsi:type</code> + and Substitution Groups"</a>). For instance:</p> + + <pre class="xml"> +<simpleType name="object"> + ... +</simpleType> + </pre> + + <p>is mapped to:</p> + + <pre class="c++"> +class object: ... +{ +public: + object (const object&); + +public: + object& + operator= (const object&); + +public: + virtual object* + _clone () const; + + ... + +}; + </pre> + + <p>The base class specification and the rest of the class definition + depend on the type of derivation used to define the simple type. </p> + + + <h3><a name="2.6.1">2.6.1 Mapping for Derivation by Restriction</a></h3> + + <p>XML Schema derivation by restriction is mapped to C++ public + inheritance. The base type of the restriction becomes the base + type for the resulting C++ class. In addition to the members described + in <a href="#2.6">Section 2.6, "Mapping for Simple Types"</a>, the + resulting C++ class defines a public constructor with the base type + as its single argument. For instance:</p> + + <pre class="xml"> +<simpleType name="object"> + <restriction base="base"> + ... + </restriction> +</simpleType> + </pre> + + <p>is mapped to:</p> + + <pre class="c++"> +class object: public base +{ +public: + object (const base&); + object (const object&); + +public: + object& + operator= (const object&); + +public: + virtual object* + _clone () const; +}; + </pre> + + + <h3><a name="2.6.2">2.6.2 Mapping for Enumerations</a></h3> + +<p>XML Schema restriction by enumeration is mapped to a C++ class + with semantics similar to C++ <code>enum</code>. Each XML Schema + enumeration element is mapped to a C++ enumerator with the + name derived from the <code>value</code> attribute and defined + in the class scope. In addition to the members + described in <a href="#2.6">Section 2.6, "Mapping for Simple Types"</a>, + the resulting C++ class defines a public constructor that can be called + with one of the enumerators as its single argument, a public constructor + that can be called with enumeration's base value as its single + argument, a public assignment operator that can be used to assign the + value of one of the enumerators, and a public implicit conversion + operator to the underlying C++ enum type.</p> + +<p>Furthermore, for string-based enumeration types, the resulting C++ + class defines a public constructor with a single argument of type + <code>const C*</code> and a public constructor with a single + argument of type <code>const std::basic_string<C>&</code>. + For instance:</p> + + <pre class="xml"> +<simpleType name="color"> + <restriction base="string"> + <enumeration value="red"/> + <enumeration value="green"/> + <enumeration value="blue"/> + </restriction> +</simpleType> + </pre> + + <p>is mapped to:</p> + + <pre class="c++"> +class color: public xml_schema::string +{ +public: + enum value + { + red, + green, + blue + }; + +public: + color (value); + color (const C*); + color (const std::basic_string<C>&); + color (const xml_schema::string&); + color (const color&); + +public: + color& + operator= (value); + + color& + operator= (const color&); + +public: + virtual color* + _clone () const; + +public: + operator value () const; +}; + </pre> + + <h3><a name="2.6.3">2.6.3 Mapping for Derivation by List</a></h3> + + <p>XML Schema derivation by list is mapped to C++ public + inheritance from <code>xml_schema::simple_type</code> + (<a href="#2.5.3">Section 2.5.3, "Mapping for + <code>anySimpleType</code>"</a>) and a suitable sequence type. + The list item type becomes the element type of the sequence. + In addition to the members described in <a href="#2.6">Section 2.6, + "Mapping for Simple Types"</a>, the resulting C++ class defines + a public default constructor, a public constructor + with the first argument of type <code>size_type</code> and + the second argument of list item type that creates + a list object with the specified number of copies of the specified + element value, and a public constructor with the two arguments + of an input iterator type that creates a list object from an + iterator range. For instance: + </p> + + <pre class="xml"> +<simpleType name="int_list"> + <list itemType="int"/> +</simpleType> + </pre> + + <p>is mapped to:</p> + + <pre class="c++"> +class int_list: public simple_type, + public sequence<int> +{ +public: + int_list (); + int_list (size_type n, int x); + + template <typename I> + int_list (const I& begin, const I& end); + int_list (const int_list&); + +public: + int_list& + operator= (const int_list&); + +public: + virtual int_list* + _clone () const; +}; + </pre> + + <p>The <code>sequence</code> class template is defined in an + implementation-specific namespace. It conforms to the + sequence interface as defined by the ISO/ANSI Standard for + C++ (ISO/IEC 14882:1998, Section 23.1.1, "Sequences"). + Practically, this means that you can treat such a sequence + as if it was <code>std::vector</code>. One notable extension + to the standard interface that is available only for + sequences of non-fundamental C++ types is the addition of + the overloaded <code>push_back</code> and <code>insert</code> + member functions which instead of the constant reference + to the element type accept automatic pointer (<code>std::auto_ptr</code> + or <code>std::unique_ptr</code>, depending on the C++ standard + selected) to the element type. These functions assume ownership + of the pointed to object and reset the passed automatic pointer. + </p> + + <h3><a name="2.6.4">2.6.4 Mapping for Derivation by Union</a></h3> + + <p>XML Schema derivation by union is mapped to C++ public + inheritance from <code>xml_schema::simple_type</code> + (<a href="#2.5.3">Section 2.5.3, "Mapping for + <code>anySimpleType</code>"</a>) and <code>std::basic_string<C></code>. + In addition to the members described in <a href="#2.6">Section 2.6, + "Mapping for Simple Types"</a>, the resulting C++ class defines a + public constructor with a single argument of type <code>const C*</code> + and a public constructor with a single argument of type + <code>const std::basic_string<C>&</code>. For instance: + </p> + + <pre class="xml"> +<simpleType name="int_string_union"> + <xsd:union memberTypes="xsd:int xsd:string"/> +</simpleType> + </pre> + + <p>is mapped to:</p> + + <pre class="c++"> +class int_string_union: public simple_type, + public std::basic_string<C> +{ +public: + int_string_union (const C*); + int_string_union (const std::basic_string<C>&); + int_string_union (const int_string_union&); + +public: + int_string_union& + operator= (const int_string_union&); + +public: + virtual int_string_union* + _clone () const; +}; + </pre> + + <h2><a name="2.7">2.7 Mapping for Complex Types</a></h2> + + <p>An XML Schema complex type is mapped to a C++ class with the same + name as the complex type. The class defines a public copy constructor, + a public copy assignment operator, and a public virtual + <code>_clone</code> function. The <code>_clone</code> function is + declared <code>const</code>, does not take any arguments, and returns + a pointer to a complete copy of the instance allocated in the free + store. The <code>_clone</code> function shall be used to make copies + when static type and dynamic type of the instance may differ (see + <a href="#2.11">Section 2.11, "Mapping for <code>xsi:type</code> + and Substitution Groups"</a>).</p> + + <p>Additionally, the resulting C++ class + defines two public constructors that take an initializer for each + member of the complex type and all its base types that belongs to + the One cardinality class (see <a href="#2.8">Section 2.8, "Mapping + for Local Elements and Attributes"</a>). In the first constructor, + the arguments are passed as constant references and the newly created + instance is initialized with copies of the passed objects. In the + second constructor, arguments that are complex types (that is, + they themselves contain elements or attributes) are passed as + either <code>std::auto_ptr</code> (C++98) or <code>std::unique_ptr</code> + (C++11), depending on the C++ standard selected. In this case the newly + created instance is directly initialized with and assumes ownership + of the pointed to objects and the <code>std::[auto|unique]_ptr</code> + arguments are reset to <code>0</code>. For instance:</p> + + <pre class="xml"> +<complexType name="complex"> + <sequence> + <element name="a" type="int"/> + <element name="b" type="string"/> + </sequence> +</complexType> + +<complexType name="object"> + <sequence> + <element name="s-one" type="boolean"/> + <element name="c-one" type="complex"/> + <element name="optional" type="int" minOccurs="0"/> + <element name="sequence" type="string" maxOccurs="unbounded"/> + </sequence> +</complexType> + </pre> + + <p>is mapped to:</p> + + <pre class="c++"> +class complex: public xml_schema::type +{ +public: + object (const int& a, const xml_schema::string& b); + object (const complex&); + +public: + object& + operator= (const complex&); + +public: + virtual complex* + _clone () const; + + ... + +}; + +class object: public xml_schema::type +{ +public: + object (const bool& s_one, const complex& c_one); + object (const bool& s_one, std::[auto|unique]_ptr<complex> c_one); + object (const object&); + +public: + object& + operator= (const object&); + +public: + virtual object* + _clone () const; + + ... + +}; + </pre> + + <p>Notice that the generated <code>complex</code> class does not + have the second (<code>std::[auto|unique]_ptr</code>) version of the + constructor since all its required members are of simple types.</p> + + <p>If an XML Schema complex type has an ultimate base which is an XML + Schema simple type then the resulting C++ class also defines a public + constructor that takes an initializer for the base type as well as + for each member of the complex type and all its base types that + belongs to the One cardinality class. For instance:</p> + + <pre class="xml"> +<complexType name="object"> + <simpleContent> + <extension base="date"> + <attribute name="lang" type="language" use="required"/> + </extension> + </simpleContent> +</complexType> + </pre> + + <p>is mapped to:</p> + + <pre class="c++"> +class object: public xml_schema::string +{ +public: + object (const xml_schema::language& lang); + + object (const xml_schema::date& base, + const xml_schema::language& lang); + + ... + +}; + </pre> + + <p>Furthermore, for string-based XML Schema complex types, the resulting C++ + class also defines two public constructors with the first arguments + of type <code>const C*</code> and <code>std::basic_string<C>&</code>, + respectively, followed by arguments for each member of the complex + type and all its base types that belongs to the One cardinality + class. For enumeration-based complex types the resulting C++ + class also defines a public constructor with the first arguments + of the underlying enum type followed by arguments for each member + of the complex type and all its base types that belongs to the One + cardinality class. For instance:</p> + + <pre class="xml"> +<simpleType name="color"> + <restriction base="string"> + <enumeration value="red"/> + <enumeration value="green"/> + <enumeration value="blue"/> + </restriction> +</simpleType> + +<complexType name="object"> + <simpleContent> + <extension base="color"> + <attribute name="lang" type="language" use="required"/> + </extension> + </simpleContent> +</complexType> + </pre> + + <p>is mapped to:</p> + + <pre class="c++"> +class color: public xml_schema::string +{ +public: + enum value + { + red, + green, + blue + }; + +public: + color (value); + color (const C*); + color (const std::basic_string<C>&); + + ... + +}; + +class object: color +{ +public: + object (const color& base, + const xml_schema::language& lang); + + object (const color::value& base, + const xml_schema::language& lang); + + object (const C* base, + const xml_schema::language& lang); + + object (const std::basic_string<C>& base, + const xml_schema::language& lang); + + ... + +}; + </pre> + + <p>Additional constructors can be requested with the + <code>--generate-default-ctor</code> and + <code>--generate-from-base-ctor</code> options. See the + <a href="http://www.codesynthesis.com/projects/xsd/documentation/xsd.xhtml">XSD + Compiler Command Line Manual</a> for details.</p> + + <p>If an XML Schema complex type is not explicitly derived from any type, + the resulting C++ class is derived from <code>xml_schema::type</code>. + In cases where an XML Schema complex type is defined using derivation + by extension or restriction, the resulting C++ base class specification + depends on the type of derivation and is described in the subsequent + sections. + </p> + + <p>The mapping for elements and attributes that are defined in a complex + type is described in <a href="#2.8">Section 2.8, "Mapping for Local + Elements and Attributes"</a>. + </p> + + <h3><a name="2.7.1">2.7.1 Mapping for Derivation by Extension</a></h3> + + <p>XML Schema derivation by extension is mapped to C++ public + inheritance. The base type of the extension becomes the base + type for the resulting C++ class. + </p> + + <h3><a name="2.7.2">2.7.2 Mapping for Derivation by Restriction</a></h3> + + <p>XML Schema derivation by restriction is mapped to C++ public + inheritance. The base type of the restriction becomes the base + type for the resulting C++ class. XML Schema elements and + attributes defined within restriction do not result in any + definitions in the resulting C++ class. Instead, corresponding + (unrestricted) definitions are inherited from the base class. + In the future versions of this mapping, such elements and + attributes may result in redefinitions of accessors and + modifiers to reflect their restricted semantics. + </p> + + <!-- 2.8 Mapping for Local Elements and Attributes --> + + <h2><a name="2.8">2.8 Mapping for Local Elements and Attributes</a></h2> + + <p>XML Schema element and attribute definitions are called local + if they appear within a complex type definition, an element group + definition, or an attribute group definitions. + </p> + + <p>Local XML Schema element and attribute definitions have the same + C++ mapping. Therefore, in this section, local elements and + attributes are collectively called members. + </p> + + <p>While there are many different member cardinality combinations + (determined by the <code>use</code> attribute for attributes and + the <code>minOccurs</code> and <code>maxOccurs</code> attributes + for elements), the mapping divides all possible cardinality + combinations into three cardinality classes: + </p> + + <dl> + <dt><i>one</i></dt> + <dd>attributes: <code>use == "required"</code></dd> + <dd>attributes: <code>use == "optional"</code> and has default or fixed value</dd> + <dd>elements: <code>minOccurs == "1"</code> and <code>maxOccurs == "1"</code></dd> + + <dt><i>optional</i></dt> + <dd>attributes: <code>use == "optional"</code> and doesn't have default or fixed value</dd> + <dd>elements: <code>minOccurs == "0"</code> and <code>maxOccurs == "1"</code></dd> + + <dt><i>sequence</i></dt> + <dd>elements: <code>maxOccurs > "1"</code></dd> + </dl> + + <p>An optional attribute with a default or fixed value acquires this value + if the attribute hasn't been specified in an instance document (see + <a href="#A">Appendix A, "Default and Fixed Values"</a>). This + mapping places such optional attributes to the One cardinality + class.</p> + + <p>A member is mapped to a set of public type definitions + (<code>typedef</code>s) and a set of public accessor and modifier + functions. Type definitions have names derived from the member's + name. The accessor and modifier functions have the same name as the + member. For example: + </p> + + <pre class="xml"> +<complexType name="object"> + <sequence> + <element name="member" type="string"/> + </sequence> +</complexType> + </pre> + + <p>is mapped to:</p> + + <pre class="c++"> +class object: public xml_schema::type +{ +public: + typedef xml_schema::string member_type; + + const member_type& + member () const; + + ... + +}; + </pre> + + <p>In addition, if a member has a default or fixed value, a static + accessor function is generated that returns this value. For + example:</p> + +<pre class="xml"> +<complexType name="object"> + <attribute name="data" type="string" default="test"/> +</complexType> + </pre> + + <p>is mapped to:</p> + + <pre class="c++"> +class object: public xml_schema::type +{ +public: + typedef xml_schema::string data_type; + + const data_type& + data () const; + + static const data_type& + data_default_value (); + + ... + +}; + </pre> + + <p>Names and semantics of type definitions for the member as well + as signatures of the accessor and modifier functions depend on + the member's cardinality class and are described in the following + sub-sections. + </p> + + + <h3><a name="2.8.1">2.8.1 Mapping for Members with the One Cardinality Class</a></h3> + + <p>For the One cardinality class, the type definitions consist of + an alias for the member's type with the name created by appending + the <code>_type</code> suffix to the member's name. + </p> + + <p>The accessor functions come in constant and non-constant versions. + The constant accessor function returns a constant reference to the + member and can be used for read-only access. The non-constant + version returns an unrestricted reference to the member and can + be used for read-write access. + </p> + + <p>The first modifier function expects an argument of type reference to + constant of the member's type. It makes a deep copy of its argument. + Except for member's types that are mapped to fundamental C++ types, + the second modifier function is provided that expects an argument + of type automatic pointer (<code>std::auto_ptr</code> or + <code>std::unique_ptr</code>, depending on the C++ standard selected) + to the member's type. It assumes ownership of the pointed to object + and resets the passed automatic pointer. For instance:</p> + + <pre class="xml"> +<complexType name="object"> + <sequence> + <element name="member" type="string"/> + </sequence> +</complexType> + </pre> + + <p>is mapped to:</p> + + <pre class="c++"> +class object: public xml_schema::type +{ +public: + // Type definitions. + // + typedef xml_schema::string member_type; + + // Accessors. + // + const member_type& + member () const; + + member_type& + member (); + + // Modifiers. + // + void + member (const member_type&); + + void + member (std::[auto|unique]_ptr<member_type>); + ... + +}; + </pre> + + <p>In addition, if requested by specifying the <code>--generate-detach</code> + option and only for members of non-fundamental C++ types, the mapping + provides a detach function that returns an automatic pointer to the + member's type, for example:</p> + + <pre class="c++"> +class object: public xml_schema::type +{ +public: + ... + + std::[auto|unique]_ptr<member_type> + detach_member (); + ... + +}; + </pre> + + <p>This function detaches the value from the tree leaving the member + value uninitialized. Accessing such an uninitialized value prior to + re-initializing it results in undefined behavior.</p> + + <p>The following code shows how one could use this mapping:</p> + + <pre class="c++"> +void +f (object& o) +{ + using xml_schema::string; + + string s (o.member ()); // get + object::member_type& sr (o.member ()); // get + + o.member ("hello"); // set, deep copy + o.member () = "hello"; // set, deep copy + + // C++98 version. + // + std::auto_ptr<string> p (new string ("hello")); + o.member (p); // set, assumes ownership + p = o.detach_member (); // detach, member is uninitialized + o.member (p); // re-attach + + // C++11 version. + // + std::unique_ptr<string> p (new string ("hello")); + o.member (std::move (p)); // set, assumes ownership + p = o.detach_member (); // detach, member is uninitialized + o.member (std::move (p)); // re-attach +} + </pre> + + +<h3><a name="2.8.2">2.8.2 Mapping for Members with the Optional Cardinality Class</a></h3> + + <p>For the Optional cardinality class, the type definitions consist of + an alias for the member's type with the name created by appending + the <code>_type</code> suffix to the member's name and an alias for + the container type with the name created by appending the + <code>_optional</code> suffix to the member's name. + </p> + + <p>Unlike accessor functions for the One cardinality class, accessor + functions for the Optional cardinality class return references to + corresponding containers rather than directly to members. The + accessor functions come in constant and non-constant versions. + The constant accessor function returns a constant reference to + the container and can be used for read-only access. The non-constant + version returns an unrestricted reference to the container + and can be used for read-write access. + </p> + + <p>The modifier functions are overloaded for the member's + type and the container type. The first modifier function + expects an argument of type reference to constant of the + member's type. It makes a deep copy of its argument. + Except for member's types that are mapped to fundamental C++ types, + the second modifier function is provided that expects an argument + of type automatic pointer (<code>std::auto_ptr</code> or + <code>std::unique_ptr</code>, depending on the C++ standard selected) + to the member's type. It assumes ownership of the pointed to object + and resets the passed automatic pointer. The last modifier function + expects an argument of type reference to constant of the container + type. It makes a deep copy of its argument. For instance: + </p> + + <pre class="xml"> +<complexType name="object"> + <sequence> + <element name="member" type="string" minOccurs="0"/> + </sequence> +</complexType> + </pre> + + <p>is mapped to:</p> + + <pre class="c++"> +class object: public xml_schema::type +{ +public: + // Type definitions. + // + typedef xml_schema::string member_type; + typedef optional<member_type> member_optional; + + // Accessors. + // + const member_optional& + member () const; + + member_optional& + member (); + + // Modifiers. + // + void + member (const member_type&); + + void + member (std::[auto|unique]_ptr<member_type>); + + void + member (const member_optional&); + + ... + +}; + </pre> + + + <p>The <code>optional</code> class template is defined in an + implementation-specific namespace and has the following + interface. The <code>[auto|unique]_ptr</code>-based constructor + and modifier function are only available if the template + argument is not a fundamental C++ type. + </p> + + <pre class="c++"> +template <typename X> +class optional +{ +public: + optional (); + + // Makes a deep copy. + // + explicit + optional (const X&); + + // Assumes ownership. + // + explicit + optional (std::[auto|unique]_ptr<X>); + + optional (const optional&); + +public: + optional& + operator= (const X&); + + optional& + operator= (const optional&); + + // Pointer-like interface. + // +public: + const X* + operator-> () const; + + X* + operator-> (); + + const X& + operator* () const; + + X& + operator* (); + + typedef void (optional::*bool_convertible) (); + operator bool_convertible () const; + + // Get/set interface. + // +public: + bool + present () const; + + const X& + get () const; + + X& + get (); + + // Makes a deep copy. + // + void + set (const X&); + + // Assumes ownership. + // + void + set (std::[auto|unique]_ptr<X>); + + // Detach and return the contained value. + // + std::[auto|unique]_ptr<X> + detach (); + + void + reset (); +}; + +template <typename X> +bool +operator== (const optional<X>&, const optional<X>&); + +template <typename X> +bool +operator!= (const optional<X>&, const optional<X>&); + +template <typename X> +bool +operator< (const optional<X>&, const optional<X>&); + +template <typename X> +bool +operator> (const optional<X>&, const optional<X>&); + +template <typename X> +bool +operator<= (const optional<X>&, const optional<X>&); + +template <typename X> +bool +operator>= (const optional<X>&, const optional<X>&); + </pre> + + + <p>The following code shows how one could use this mapping:</p> + + <pre class="c++"> +void +f (object& o) +{ + using xml_schema::string; + + if (o.member ().present ()) // test + { + string& s (o.member ().get ()); // get + o.member ("hello"); // set, deep copy + o.member ().set ("hello"); // set, deep copy + o.member ().reset (); // reset + } + + // Same as above but using pointer notation: + // + if (o.member ()) // test + { + string& s (*o.member ()); // get + o.member ("hello"); // set, deep copy + *o.member () = "hello"; // set, deep copy + o.member ().reset (); // reset + } + + // C++98 version. + // + std::auto_ptr<string> p (new string ("hello")); + o.member (p); // set, assumes ownership + + p = new string ("hello"); + o.member ().set (p); // set, assumes ownership + + p = o.member ().detach (); // detach, member is reset + o.member ().set (p); // re-attach + + // C++11 version. + // + std::unique_ptr<string> p (new string ("hello")); + o.member (std::move (p)); // set, assumes ownership + + p.reset (new string ("hello")); + o.member ().set (std::move (p)); // set, assumes ownership + + p = o.member ().detach (); // detach, member is reset + o.member ().set (std::move (p)); // re-attach +} + </pre> + + + <h3><a name="2.8.3">2.8.3 Mapping for Members with the Sequence Cardinality Class</a></h3> + + <p>For the Sequence cardinality class, the type definitions consist of an + alias for the member's type with the name created by appending + the <code>_type</code> suffix to the member's name, an alias of + the container type with the name created by appending the + <code>_sequence</code> suffix to the member's name, an alias of + the iterator type with the name created by appending the + <code>_iterator</code> suffix to the member's name, and an alias + of the constant iterator type with the name created by appending the + <code>_const_iterator</code> suffix to the member's name. + </p> + + <p>The accessor functions come in constant and non-constant versions. + The constant accessor function returns a constant reference to the + container and can be used for read-only access. The non-constant + version returns an unrestricted reference to the container and can + be used for read-write access. + </p> + + <p>The modifier function expects an argument of type reference to + constant of the container type. The modifier function + makes a deep copy of its argument. For instance: + </p> + + + <pre class="xml"> +<complexType name="object"> + <sequence> + <element name="member" type="string" minOccurs="unbounded"/> + </sequence> +</complexType> + </pre> + + <p>is mapped to:</p> + + <pre class="c++"> +class object: public xml_schema::type +{ +public: + // Type definitions. + // + typedef xml_schema::string member_type; + typedef sequence<member_type> member_sequence; + typedef member_sequence::iterator member_iterator; + typedef member_sequence::const_iterator member_const_iterator; + + // Accessors. + // + const member_sequence& + member () const; + + member_sequence& + member (); + + // Modifier. + // + void + member (const member_sequence&); + + ... + +}; + </pre> + + <p>The <code>sequence</code> class template is defined in an + implementation-specific namespace. It conforms to the + sequence interface as defined by the ISO/ANSI Standard for + C++ (ISO/IEC 14882:1998, Section 23.1.1, "Sequences"). + Practically, this means that you can treat such a sequence + as if it was <code>std::vector</code>. Two notable extensions + to the standard interface that are available only for + sequences of non-fundamental C++ types are the addition of + the overloaded <code>push_back</code> and <code>insert</code> + as well as the <code>detach_back</code> and <code>detach</code> + member functions. The additional <code>push_back</code> and + <code>insert</code> functions accept an automatic pointer + (<code>std::auto_ptr</code> or <code>std::unique_ptr</code>, + depending on the C++ standard selected) to the + element type instead of the constant reference. They assume + ownership of the pointed to object and reset the passed + automatic pointer. The <code>detach_back</code> and + <code>detach</code> functions detach the element + value from the sequence container and, by default, remove + the element from the sequence. These additional functions + have the following signatures:</p> + + <pre class="c++"> +template <typename X> +class sequence +{ +public: + ... + + void + push_back (std::[auto|unique]_ptr<X>) + + iterator + insert (iterator position, std::[auto|unique]_ptr<X>) + + std::[auto|unique]_ptr<X> + detach_back (bool pop = true); + + iterator + detach (iterator position, + std::[auto|unique]_ptr<X>& result, + bool erase = true) + + ... +} + </pre> + + <p>The following code shows how one could use this mapping:</p> + + <pre class="c++"> +void +f (object& o) +{ + using xml_schema::string; + + object::member_sequence& s (o.member ()); + + // Iteration. + // + for (object::member_iterator i (s.begin ()); i != s.end (); ++i) + { + string& value (*i); + } + + // Modification. + // + s.push_back ("hello"); // deep copy + + // C++98 version. + // + std::auto_ptr<string> p (new string ("hello")); + s.push_back (p); // assumes ownership + p = s.detach_back (); // detach and pop + s.push_back (p); // re-append + + // C++11 version. + // + std::unique_ptr<string> p (new string ("hello")); + s.push_back (std::move (p)); // assumes ownership + p = s.detach_back (); // detach and pop + s.push_back (std::move (p)); // re-append + + // Setting a new container. + // + object::member_sequence n; + n.push_back ("one"); + n.push_back ("two"); + o.member (n); // deep copy +} + </pre> + + <h3><a name="2.8.4">2.8.4 Element Order</a></h3> + + <p>C++/Tree is a "flattening" mapping in a sense that many levels of + nested compositors (<code>choice</code> and <code>sequence</code>), + all potentially with their own cardinalities, are in the end mapped + to a flat set of elements with one of the three cardinality classes + discussed in the previous sections. While this results in a simple + and easy to use API for most types, in certain cases, the order of + elements in the actual XML documents is not preserved once parsed + into the object model. And sometimes such order has + application-specific significance. As an example, consider a schema + that defines a batch of bank transactions:</p> + + <pre class="xml"> +<complexType name="withdraw"> + <sequence> + <element name="account" type="unsignedInt"/> + <element name="amount" type="unsignedInt"/> + </sequence> +</complexType> + +<complexType name="deposit"> + <sequence> + <element name="account" type="unsignedInt"/> + <element name="amount" type="unsignedInt"/> + </sequence> +</complexType> + +<complexType name="batch"> + <choice minOccurs="0" maxOccurs="unbounded"> + <element name="withdraw" type="withdraw"/> + <element name="deposit" type="deposit"/> + </choice> +</complexType> + </pre> + + <p>The batch can contain any number of transactions in any order + but the order of transactions in each actual batch is significant. + For instance, consider what could happen if we reorder the + transactions and apply all the withdrawals before deposits.</p> + + <p>For the <code>batch</code> schema type defined above the default + C++/Tree mapping will produce a C++ class that contains a pair of + sequence containers, one for each of the two elements. While this + will capture the content (transactions), the order of this content + as it appears in XML will be lost. Also, if we try to serialize the + batch we just loaded back to XML, all the withdrawal transactions + will appear before deposits.</p> + + <p>To overcome this limitation of a flattening mapping, C++/Tree + allows us to mark certain XML Schema types, for which content + order is important, as ordered.</p> + + <p>There are several command line options that control which + schema types are treated as ordered. To make an individual + type ordered, we use the <code>--ordered-type</code> option, + for example:</p> + + <pre class="term"> +--ordered-type batch + </pre> + + <p>To automatically treat all the types that are derived from an ordered + type also ordered, we use the <code>--ordered-type-derived</code> + option. This is primarily useful if you would like to iterate + over the complete hierarchy's content using the content order + sequence (discussed below).</p> + + <p>Ordered types are also useful for handling mixed content. To + automatically mark all the types with mixed content as ordered + we use the <code>--ordered-type-mixed</code> option. For more + information on handling mixed content see <a href="#2.13">Section + 2.13, "Mapping for Mixed Content Models"</a>.</p> + + <p>Finally, we can mark all the types in the schema we are + compiling with the <code>--ordered-type-all</code> option. + You should only resort to this option if all the types in + your schema truly suffer from the loss of content + order since, as we will discuss shortly, ordered types + require extra effort to access and, especially, modify. + See the + <a href="http://www.codesynthesis.com/projects/xsd/documentation/xsd.xhtml">XSD + Compiler Command Line Manual</a> for more information on + these options.</p> + + <p>Once a type is marked ordered, C++/Tree alters its mapping + in several ways. Firstly, for each local element, element + wildcard (<a href="#2.12.4">Section 2.12.4, "Element Wildcard + Order"</a>), and mixed content text (<a href="#2.13">Section + 2.13, "Mapping for Mixed Content Models"</a>) in this type, a + content id constant is generated. Secondly, an addition sequence + is added to the class that captures the content order. Here + is how the mapping of our <code>batch</code> class changes + once we make it ordered:</p> + + <pre class="c++"> +class batch: public xml_schema::type +{ +public: + // withdraw + // + typedef withdraw withdraw_type; + typedef sequence<withdraw_type> withdraw_sequence; + typedef withdraw_sequence::iterator withdraw_iterator; + typedef withdraw_sequence::const_iterator withdraw_const_iterator; + + static const std::size_t withdraw_id = 1; + + const withdraw_sequence& + withdraw () const; + + withdraw_sequence& + withdraw (); + + void + withdraw (const withdraw_sequence&); + + // deposit + // + typedef deposit deposit_type; + typedef sequence<deposit_type> deposit_sequence; + typedef deposit_sequence::iterator deposit_iterator; + typedef deposit_sequence::const_iterator deposit_const_iterator; + + static const std::size_t deposit_id = 2; + + const deposit_sequence& + deposit () const; + + deposit_sequence& + deposit (); + + void + deposit (const deposit_sequence&); + + // content_order + // + typedef xml_schema::content_order content_order_type; + typedef std::vector<content_order_type> content_order_sequence; + typedef content_order_sequence::iterator content_order_iterator; + typedef content_order_sequence::const_iterator content_order_const_iterator; + + const content_order_sequence& + content_order () const; + + content_order_sequence& + content_order (); + + void + content_order (const content_order_sequence&); + + ... +}; + </pre> + + <p>Notice the <code>withdraw_id</code> and <code>deposit_id</code> + content ids as well as the extra <code>content_order</code> + sequence that does not correspond to any element in the + schema definition. The other changes to the mapping for ordered + types has to do with XML parsing and serialization code. During + parsing the content order is captured in the <code>content_order</code> + sequence while during serialization this sequence is used to + determine the order in which content is serialized. The + <code>content_order</code> sequence is also copied during + copy construction and assigned during copy assignment. It is also + taken into account during comparison.</p> + + <p>The entry type of the <code>content_order</code> sequence is the + <code>xml_schema::content_order</code> type that has the following + interface:</p> + + <pre class="c++"> +namespace xml_schema +{ + struct content_order + { + content_order (std::size_t id, std::size_t index = 0); + + std::size_t id; + std::size_t index; + }; + + bool + operator== (const content_order&, const content_order&); + + bool + operator!= (const content_order&, const content_order&); + + bool + operator< (const content_order&, const content_order&); +} + </pre> + + <p>The <code>content_order</code> sequence describes the order of + content (elements, including wildcards, as well as mixed content + text). Each entry in this sequence consists of the content id + (for example, <code>withdraw_id</code> or <code>deposit_id</code> + in our case) as well as, for elements of the sequence cardinality + class, an index into the corresponding sequence container (the + index is unused for the one and optional cardinality classes). + For example, in our case, if the content id is <code>withdraw_id</code>, + then the index will point into the <code>withdraw</code> element + sequence.</p> + + <p>With all this information we can now examine how to iterate over + transaction in the batch in content order:</p> + + <pre class="c++"> +batch& b = ... + +for (batch::content_order_const_iterator i (b.content_order ().begin ()); + i != b.content_order ().end (); + ++i) +{ + switch (i->id) + { + case batch::withdraw_id: + { + const withdraw& t (b.withdraw ()[i->index]); + cerr << t.account () << " withdraw " << t.amount () << endl; + break; + } + case batch::deposit_id: + { + const deposit& t (b.deposit ()[i->index]); + cerr << t.account () << " deposit " << t.amount () << endl; + break; + } + default: + { + assert (false); // Unknown content id. + } + } +} + </pre> + + <p>If we serialized our batch back to XML, we would also see that the + order of transactions in the output is exactly the same as in the + input rather than all the withdrawals first followed by all the + deposits.</p> + + <p>The most complex aspect of working with ordered types is + modifications. Now we not only need to change the content, + but also remember to update the order information corresponding + to this change. As a first example, we add a deposit transaction + to the batch:</p> + + <pre class="c++"> +using xml_schema::content_order; + +batch::deposit_sequence& d (b.deposit ()); +batch::withdraw_sequence& w (b.withdraw ()); +batch::content_order_sequence& co (b.content_order ()); + +d.push_back (deposit (123456789, 100000)); +co.push_back (content_order (batch::deposit_id, d.size () - 1)); + </pre> + + <p>In the above example we first added the content (deposit + transaction) and then updated the content order information + by adding an entry with <code>deposit_id</code> content + id and the index of the just added deposit transaction.</p> + + <p>Removing the last transaction can be easy if we know which + transaction (deposit or withdrawal) is last:</p> + + <pre class="c++"> +d.pop_back (); +co.pop_back (); + </pre> + + <p>If, however, we do not know which transaction is last, then + things get a bit more complicated:</p> + + <pre class="c++"> +switch (co.back ().id) +{ +case batch::withdraw_id: + { + d.pop_back (); + break; + } +case batch::deposit_id: + { + w.pop_back (); + break; + } +} + +co.pop_back (); + </pre> + + <p>The following example shows how to add a transaction at the + beginning of the batch:</p> + + <pre class="c++"> +w.push_back (withdraw (123456789, 100000)); +co.insert (co.begin (), + content_order (batch::withdraw_id, w.size () - 1)); + </pre> + + <p>Note also that when we merely modify the content of one + of the elements in place, we do not need to update its + order since it doesn't change. For example, here is how + we can change the amount in the first withdrawal:</p> + + <pre class="c++"> +w[0].amount (10000); + </pre> + + <p>For the complete working code shown in this section refer to the + <code>order/element</code> example in the + <code>examples/cxx/tree/</code> directory in the XSD distribution.</p> + + <p>If both the base and derived types are ordered, then the + content order sequence is only added to the base and the content + ids are unique within the whole hierarchy. In this case + the content order sequence for the derived type contains + ordering information for both base and derived content.</p> + + <p>In some applications we may need to perform more complex + content processing. For example, in our case, we may need + to remove all the withdrawal transactions. The default + container, <code>std::vector</code>, is not particularly + suitable for such operations. What may be required by + some applications is a multi-index container that not + only allows us to iterate in content order similar to + <code>std::vector</code> but also search by the content + id as well as the content id and index pair.</p> + + <p>While C++/Tree does not provide this functionality by + default, it allows us to specify a custom container + type for content order with the <code>--order-container</code> + command line option. The only requirement from the + generated code side for such a container is to provide + the <code>vector</code>-like <code>push_back()</code>, + <code>size()</code>, and const iteration interfaces.</p> + + <p>As an example, here is how we can use the Boost Multi-Index + container for content order. First we create the + <code>content-order-container.hxx</code> header with the + following definition (in C++11, use the alias template + instead):</p> + + <pre class="c++"> +#ifndef CONTENT_ORDER_CONTAINER +#define CONTENT_ORDER_CONTAINER + +#include <cstddef> // std::size_t + +#include <boost/multi_index_container.hpp> +#include <boost/multi_index/member.hpp> +#include <boost/multi_index/identity.hpp> +#include <boost/multi_index/ordered_index.hpp> +#include <boost/multi_index/random_access_index.hpp> + +struct by_id {}; +struct by_id_index {}; + +template <typename T> +struct content_order_container: + boost::multi_index::multi_index_container< + T, + boost::multi_index::indexed_by< + boost::multi_index::random_access<>, + boost::multi_index::ordered_unique< + boost::multi_index::tag<by_id_index>, + boost::multi_index::identity<T> + >, + boost::multi_index::ordered_non_unique< + boost::multi_index::tag<by_id>, + boost::multi_index::member<T, std::size_t, &T::id> + > + > + > +{}; + +#endif + </pre> + + <p>Next we add the following two XSD compiler options to include + this header into every generated header file and to use the + custom container type (see the XSD compiler command line manual + for more information on shell quoting for the first option):</p> + + <pre class="term"> +--hxx-prologue '#include "content-order-container.hxx"' +--order-container content_order_container + </pre> + + <p>With these changes we can now use the multi-index functionality, + for example, to search for a specific content id:</p> + + <pre class="c++"> +typedef batch::content_order_sequence::index<by_id>::type id_set; +typedef id_set::iterator id_iterator; + +const id_set& ids (b.content_order ().get<by_id> ()); + +std::pair<id_iterator, id_iterator> r ( + ids.equal_range (std::size_t (batch::deposit_id)); + +for (id_iterator i (r.first); i != r.second; ++i) +{ + const deposit& t (b.deposit ()[i->index]); + cerr << t.account () << " deposit " << t.amount () << endl; +} + </pre> + + <h2><a name="2.9">2.9 Mapping for Global Elements</a></h2> + + <p>An XML Schema element definition is called global if it appears + directly under the <code>schema</code> element. + A global element is a valid root of an instance document. By + default, a global element is mapped to a set of overloaded + parsing and, optionally, serialization functions with the + same name as the element. It is also possible to generate types + for root elements instead of parsing and serialization functions. + This is primarily useful to distinguish object models with the + same root type but with different root elements. See + <a href="#2.9.1">Section 2.9.1, "Element Types"</a> for details. + It is also possible to request the generation of an element map + which allows uniform parsing and serialization of multiple root + elements. See <a href="#2.9.2">Section 2.9.2, "Element Map"</a> + for details. + </p> + + <p>The parsing functions read XML instance documents and return + corresponding object models as an automatic pointer + (<code>std::auto_ptr</code> or <code>std::unique_ptr</code>, + depending on the C++ standard selected). Their signatures + have the following pattern (<code>type</code> denotes + element's type and <code>name</code> denotes element's + name): + </p> + + <pre class="c++"> +std::[auto|unique]_ptr<type> +name (....); + </pre> + + <p>The process of parsing, including the exact signatures of the parsing + functions, is the subject of <a href="#3">Chapter 3, "Parsing"</a>. + </p> + + <p>The serialization functions write object models back to XML instance + documents. Their signatures have the following pattern: + </p> + + <pre class="c++"> +void +name (<stream type>&, const type&, ....); + </pre> + + <p>The process of serialization, including the exact signatures of the + serialization functions, is the subject of <a href="#4">Chapter 4, + "Serialization"</a>. + </p> + + + <h3><a name="2.9.1">2.9.1 Element Types</a></h3> + + <p>The generation of element types is requested with the + <code>--generate-element-map</code> option. With this option + each global element is mapped to a C++ class with the + same name as the element. Such a class is derived from + <code>xml_schema::element_type</code> and contains the same set + of type definitions, constructors, and member function as would a + type containing a single element with the One cardinality class + named <code>"value"</code>. In addition, the element type also + contains a set of member functions for accessing the element + name and namespace as well as its value in a uniform manner. + For example:</p> + + <pre class="xml"> +<complexType name="type"> + <sequence> + ... + </sequence> +</complexType> + +<element name="root" type="type"/> + </pre> + +<p>is mapped to:</p> + + <pre class="c++"> +class type +{ + ... +}; + +class root: public xml_schema::element_type +{ +public: + // Element value. + // + typedef type value_type; + + const value_type& + value () const; + + value_type& + value (); + + void + value (const value_type&); + + void + value (std::[auto|unique]_ptr<value_type>); + + // Constructors. + // + root (const value_type&); + + root (std::[auto|unique]_ptr<value_type>); + + root (const xercesc::DOMElement&, xml_schema::flags = 0); + + root (const root&, xml_schema::flags = 0); + + virtual root* + _clone (xml_schema::flags = 0) const; + + // Element name and namespace. + // + static const std::string& + name (); + + static const std::string& + namespace_ (); + + virtual const std::string& + _name () const; + + virtual const std::string& + _namespace () const; + + // Element value as xml_schema::type. + // + virtual const xml_schema::type* + _value () const; + + virtual xml_schema::type* + _value (); +}; + +void +operator<< (xercesc::DOMElement&, const root&); + </pre> + + <p>The <code>xml_schema::element_type</code> class is a common + base type for all element types and is defined as follows:</p> + + <pre class="c++"> +namespace xml_schema +{ + class element_type + { + public: + virtual + ~element_type (); + + virtual element_type* + _clone (flags f = 0) const = 0; + + virtual const std::basic_string<C>& + _name () const = 0; + + virtual const std::basic_string<C>& + _namespace () const = 0; + + virtual xml_schema::type* + _value () = 0; + + virtual const xml_schema::type* + _value () const = 0; + }; +} + </pre> + + <p>The <code>_value()</code> member function returns a pointer to + the element value or 0 if the element is of a fundamental C++ + type and therefore is not derived from <code>xml_schema::type</code>. + </p> + + <p>Unlike parsing and serialization functions, element types + are only capable of parsing and serializing from/to a + <code>DOMElement</code> object. This means that the application + will need to perform its own XML-to-DOM parsing and DOM-to-XML + serialization. The following section describes a mechanism + provided by the mapping to uniformly parse and serialize + multiple root elements.</p> + + + <h3><a name="2.9.2">2.9.2 Element Map</a></h3> + + <p>When element types are generated for root elements it is also + possible to request the generation of an element map with the + <code>--generate-element-map</code> option. The element map + allows uniform parsing and serialization of multiple root + elements via the common <code>xml_schema::element_type</code> + base type. The <code>xml_schema::element_map</code> class is + defined as follows:</p> + + <pre class="c++"> +namespace xml_schema +{ + class element_map + { + public: + static std::[auto|unique]_ptr<xml_schema::element_type> + parse (const xercesc::DOMElement&, flags = 0); + + static void + serialize (xercesc::DOMElement&, const element_type&); + }; +} + </pre> + + <p>The <code>parse()</code> function creates the corresponding + element type object based on the element name and namespace + and returns it as an automatic pointer (<code>std::auto_ptr</code> + or <code>std::unique_ptr</code>, depending on the C++ standard + selected) to <code>xml_schema::element_type</code>. + The <code>serialize()</code> function serializes the passed element + object to <code>DOMElement</code>. Note that in case of + <code>serialize()</code>, the <code>DOMElement</code> object + should have the correct name and namespace. If no element type is + available for an element, both functions throw the + <code>xml_schema::no_element_info</code> exception:</p> + + <pre class="c++"> +struct no_element_info: virtual exception +{ + no_element_info (const std::basic_string<C>& element_name, + const std::basic_string<C>& element_namespace); + + const std::basic_string<C>& + element_name () const; + + const std::basic_string<C>& + element_namespace () const; + + virtual const char* + what () const throw (); +}; + </pre> + + <p>The application can discover the actual type of the element + object returned by <code>parse()</code> either using + <code>dynamic_cast</code> or by comparing element names and + namespaces. The following code fragments illustrate how the + element map can be used:</p> + + <pre class="c++"> +// Parsing. +// +DOMElement& e = ... // Parse XML to DOM. + +auto_ptr<xml_schema::element_type> r ( + xml_schema::element_map::parse (e)); + +if (root1 r1 = dynamic_cast<root1*> (r.get ())) +{ + ... +} +else if (r->_name == root2::name () && + r->_namespace () == root2::namespace_ ()) +{ + root2& r2 (static_cast<root2&> (*r)); + + ... +} + </pre> + + <pre class="c++"> +// Serialization. +// +xml_schema::element_type& r = ... + +string name (r._name ()); +string ns (r._namespace ()); + +DOMDocument& doc = ... // Create a new DOMDocument with name and ns. +DOMElement& e (*doc->getDocumentElement ()); + +xml_schema::element_map::serialize (e, r); + +// Serialize DOMDocument to XML. + </pre> + + <!-- --> + + <h2><a name="2.10">2.10 Mapping for Global Attributes</a></h2> + + <p>An XML Schema attribute definition is called global if it appears + directly under the <code>schema</code> element. A global + attribute does not have any mapping. + </p> + + <!-- + When it is referenced from + a local attribute definition (using the <code>ref</code> attribute) + it is treated as a local attribute (see Section 2.8, "Mapping for + Local Elements and Attributes"). + --> + + <h2><a name="2.11">2.11 Mapping for <code>xsi:type</code> and Substitution + Groups</a></h2> + + <p>The mapping provides optional support for the XML Schema polymorphism + features (<code>xsi:type</code> and substitution groups) which can + be requested with the <code>--generate-polymorphic</code> option. + When used, the dynamic type of a member may be different from + its static type. Consider the following schema definition and + instance document: + </p> + + <pre class="xml"> +<!-- test.xsd --> +<schema> + <complexType name="base"> + <attribute name="text" type="string"/> + </complexType> + + <complexType name="derived"> + <complexContent> + <extension base="base"> + <attribute name="extra-text" type="string"/> + </extension> + </complexContent> + </complexType> + + <complexType name="root_type"> + <sequence> + <element name="item" type="base" maxOccurs="unbounded"/> + </sequence> + </complexType> + + <element name="root" type="root_type"/> +</schema> + +<!-- test.xml --> +<root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <item text="hello"/> + <item text="hello" extra-text="world" xsi:type="derived"/> +</root> + </pre> + + <p>In the resulting object model, the container for + the <code>root::item</code> member will have two elements: + the first element's type will be <code>base</code> while + the second element's (dynamic) type will be + <code>derived</code>. This can be discovered using the + <code>dynamic_cast</code> operator as shown in the following + example: + </p> + + <pre class="c++"> +void +f (root& r) +{ + for (root::item_const_iterator i (r.item ().begin ()); + i != r.item ().end () + ++i) + { + if (derived* d = dynamic_cast<derived*> (&(*i))) + { + // derived + } + else + { + // base + } + } +} + </pre> + + <p>The <code>_clone</code> virtual function should be used instead of + copy constructors to make copies of members that might use + polymorphism: + </p> + + <pre class="c++"> +void +f (root& r) +{ + for (root::item_const_iterator i (r.item ().begin ()); + i != r.item ().end () + ++i) + { + std::auto_ptr<base> c (i->_clone ()); + } +} + </pre> + + <p>The mapping can often automatically determine which types are + polymorphic based on the substitution group declarations. However, + if your XML vocabulary is not using substitution groups or if + substitution groups are defined in a separate schema, then you will + need to use the <code>--polymorphic-type</code> option to specify + which types are polymorphic. When using this option you only need + to specify the root of a polymorphic type hierarchy and the mapping + will assume that all the derived types are also polymorphic. + Also note that you need to specify this option when compiling every + schema file that references the polymorphic type. Consider the following + two schemas as an example:</p> + + <pre class="xml"> +<!-- base.xsd --> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> + + <xs:complexType name="base"> + <xs:sequence> + <xs:element name="b" type="xs:int"/> + </xs:sequence> + </xs:complexType> + + <!-- substitution group root --> + <xs:element name="base" type="base"/> + +</xs:schema> + </pre> + + <pre class="xml"> +<!-- derived.xsd --> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> + + <include schemaLocation="base.xsd"/> + + <xs:complexType name="derived"> + <xs:complexContent> + <xs:extension base="base"> + <xs:sequence> + <xs:element name="d" type="xs:string"/> + </xs:sequence> + </xs:extension> + </xs:complexContent> + </xs:complexType> + + <xs:element name="derived" type="derived" substitutionGroup="base"/> + +</xs:schema> + </pre> + + <p>In this example we need to specify "<code>--polymorphic-type base</code>" + when compiling both schemas because the substitution group is declared + in a schema other than the one defining type <code>base</code>.</p> + + <p>You can also indicate that all types should be treated as polymorphic + with the <code>--polymorphic-type-all</code>. However, this may result + in slower generated code with a greater footprint.</p> + + + <!-- Mapping for any and anyAttribute --> + + + <h2><a name="2.12">2.12 Mapping for <code>any</code> and <code>anyAttribute</code></a></h2> + + <p>For the XML Schema <code>any</code> and <code>anyAttribute</code> + wildcards an optional mapping can be requested with the + <code>--generate-wildcard</code> option. The mapping represents + the content matched by wildcards as DOM fragments. Because the + DOM API is used to access such content, the Xerces-C++ runtime + should be initialized by the application prior to parsing and + should remain initialized for the lifetime of objects with + the wildcard content. For more information on the Xerces-C++ + runtime initialization see <a href="#3.1">Section 3.1, + "Initializing the Xerces-C++ Runtime"</a>. + </p> + + <p>The mapping for <code>any</code> is similar to the mapping for + local elements (see <a href="#2.8">Section 2.8, "Mapping for Local + Elements and Attributes"</a>) except that the type used in the + wildcard mapping is <code>xercesc::DOMElement</code>. As with local + elements, the mapping divides all possible cardinality combinations + into three cardinality classes: <i>one</i>, <i>optional</i>, and + <i>sequence</i>. + </p> + + <p>The mapping for <code>anyAttribute</code> represents the attributes + matched by this wildcard as a set of <code>xercesc::DOMAttr</code> + objects with a key being the attribute's name and namespace.</p> + + <p>Similar to local elements and attributes, the <code>any</code> and + <code>anyAttribute</code> wildcards are mapped to a set of public type + definitions (typedefs) and a set of public accessor and modifier + functions. Type definitions have names derived from <code>"any"</code> + for the <code>any</code> wildcard and <code>"any_attribute"</code> + for the <code>anyAttribute</code> wildcard. The accessor and modifier + functions are named <code>"any"</code> for the <code>any</code> wildcard + and <code>"any_attribute"</code> for the <code>anyAttribute</code> + wildcard. Subsequent wildcards in the same type have escaped names + such as <code>"any1"</code> or <code>"any_attribute1"</code>. + </p> + + <p>Because Xerces-C++ DOM nodes always belong to a <code>DOMDocument</code>, + each type with a wildcard has an associated <code>DOMDocument</code> + object. The reference to this object can be obtained using the accessor + function called <code>dom_document</code>. The access to the document + object from the application code may be necessary to create or modify + the wildcard content. For example: + </p> + + <pre class="xml"> +<complexType name="object"> + <sequence> + <any namespace="##other"/> + </sequence> + <anyAttribute namespace="##other"/> +</complexType> + </pre> + + <p>is mapped to:</p> + + <pre class="c++"> +class object: public xml_schema::type +{ +public: + // any + // + const xercesc::DOMElement& + any () const; + + void + any (const xercesc::DOMElement&); + + ... + + // any_attribute + // + typedef attribute_set any_attribute_set; + typedef any_attribute_set::iterator any_attribute_iterator; + typedef any_attribute_set::const_iterator any_attribute_const_iterator; + + const any_attribute_set& + any_attribute () const; + + any_attribute_set& + any_attribute (); + + ... + + // DOMDocument object for wildcard content. + // + const xercesc::DOMDocument& + dom_document () const; + + xercesc::DOMDocument& + dom_document (); + + ... +}; + </pre> + + + <p>Names and semantics of type definitions for the wildcards as well + as signatures of the accessor and modifier functions depend on the + wildcard type as well as the cardinality class for the <code>any</code> + wildcard. They are described in the following sub-sections. + </p> + + + <h3><a name="2.12.1">2.12.1 Mapping for <code>any</code> with the One Cardinality Class</a></h3> + + <p>For <code>any</code> with the One cardinality class, + there are no type definitions. The accessor functions come in + constant and non-constant versions. The constant accessor function + returns a constant reference to <code>xercesc::DOMElement</code> and + can be used for read-only access. The non-constant version returns + an unrestricted reference to <code>xercesc::DOMElement</code> and can + be used for read-write access. + </p> + + <p>The first modifier function expects an argument of type reference + to constant <code>xercesc::DOMElement</code> and makes a deep copy + of its argument. The second modifier function expects an argument of + type pointer to <code>xercesc::DOMElement</code>. This modifier + function assumes ownership of its argument and expects the element + object to be created using the DOM document associated with this + instance. For example: + </p> + + <pre class="xml"> +<complexType name="object"> + <sequence> + <any namespace="##other"/> + </sequence> +</complexType> + </pre> + + <p>is mapped to:</p> + + <pre class="c++"> +class object: public xml_schema::type +{ +public: + // Accessors. + // + const xercesc::DOMElement& + any () const; + + xercesc::DOMElement& + any (); + + // Modifiers. + // + void + any (const xercesc::DOMElement&); + + void + any (xercesc::DOMElement*); + + ... + +}; + </pre> + + + <p>The following code shows how one could use this mapping:</p> + + <pre class="c++"> +void +f (object& o, const xercesc::DOMElement& e) +{ + using namespace xercesc; + + DOMElement& e1 (o.any ()); // get + o.any (e) // set, deep copy + DOMDocument& doc (o.dom_document ()); + o.any (doc.createElement (...)); // set, assumes ownership +} + </pre> + + <h3><a name="2.12.2">2.12.2 Mapping for <code>any</code> with the Optional Cardinality Class</a></h3> + + <p>For <code>any</code> with the Optional cardinality class, the type + definitions consist of an alias for the container type with name + <code>any_optional</code> (or <code>any1_optional</code>, etc., for + subsequent wildcards in the type definition). + </p> + + <p>Unlike accessor functions for the One cardinality class, accessor + functions for the Optional cardinality class return references to + corresponding containers rather than directly to <code>DOMElement</code>. + The accessor functions come in constant and non-constant versions. + The constant accessor function returns a constant reference to + the container and can be used for read-only access. The non-constant + version returns an unrestricted reference to the container + and can be used for read-write access. + </p> + + <p>The modifier functions are overloaded for <code>xercesc::DOMElement</code> + and the container type. The first modifier function expects an argument of + type reference to constant <code>xercesc::DOMElement</code> and + makes a deep copy of its argument. The second modifier function + expects an argument of type pointer to <code>xercesc::DOMElement</code>. + This modifier function assumes ownership of its argument and expects + the element object to be created using the DOM document associated + with this instance. The third modifier function expects an argument + of type reference to constant of the container type and makes a + deep copy of its argument. For instance: + </p> + + <pre class="xml"> +<complexType name="object"> + <sequence> + <any namespace="##other" minOccurs="0"/> + </sequence> +</complexType> + </pre> + + <p>is mapped to:</p> + + <pre class="c++"> +class object: public xml_schema::type +{ +public: + // Type definitions. + // + typedef element_optional any_optional; + + // Accessors. + // + const any_optional& + any () const; + + any_optional& + any (); + + // Modifiers. + // + void + any (const xercesc::DOMElement&); + + void + any (xercesc::DOMElement*); + + void + any (const any_optional&); + + ... + +}; + </pre> + + + <p>The <code>element_optional</code> container is a + specialization of the <code>optional</code> class template described + in <a href="#2.8.2">Section 2.8.2, "Mapping for Members with the Optional + Cardinality Class"</a>. Its interface is presented below: + </p> + + <pre class="c++"> +class element_optional +{ +public: + explicit + element_optional (xercesc::DOMDocument&); + + // Makes a deep copy. + // + element_optional (const xercesc::DOMElement&, xercesc::DOMDocument&); + + // Assumes ownership. + // + element_optional (xercesc::DOMElement*, xercesc::DOMDocument&); + + element_optional (const element_optional&, xercesc::DOMDocument&); + +public: + element_optional& + operator= (const xercesc::DOMElement&); + + element_optional& + operator= (const element_optional&); + + // Pointer-like interface. + // +public: + const xercesc::DOMElement* + operator-> () const; + + xercesc::DOMElement* + operator-> (); + + const xercesc::DOMElement& + operator* () const; + + xercesc::DOMElement& + operator* (); + + typedef void (element_optional::*bool_convertible) (); + operator bool_convertible () const; + + // Get/set interface. + // +public: + bool + present () const; + + const xercesc::DOMElement& + get () const; + + xercesc::DOMElement& + get (); + + // Makes a deep copy. + // + void + set (const xercesc::DOMElement&); + + // Assumes ownership. + // + void + set (xercesc::DOMElement*); + + void + reset (); +}; + +bool +operator== (const element_optional&, const element_optional&); + +bool +operator!= (const element_optional&, const element_optional&); + </pre> + + + <p>The following code shows how one could use this mapping:</p> + + <pre class="c++"> +void +f (object& o, const xercesc::DOMElement& e) +{ + using namespace xercesc; + + DOMDocument& doc (o.dom_document ()); + + if (o.any ().present ()) // test + { + DOMElement& e1 (o.any ().get ()); // get + o.any ().set (e); // set, deep copy + o.any ().set (doc.createElement (...)); // set, assumes ownership + o.any ().reset (); // reset + } + + // Same as above but using pointer notation: + // + if (o.member ()) // test + { + DOMElement& e1 (*o.any ()); // get + o.any (e); // set, deep copy + o.any (doc.createElement (...)); // set, assumes ownership + o.any ().reset (); // reset + } +} + </pre> + + + + <h3><a name="2.12.3">2.12.3 Mapping for <code>any</code> with the Sequence Cardinality Class</a></h3> + + <p>For <code>any</code> with the Sequence cardinality class, the type + definitions consist of an alias of the container type with name + <code>any_sequence</code> (or <code>any1_sequence</code>, etc., for + subsequent wildcards in the type definition), an alias of the iterator + type with name <code>any_iterator</code> (or <code>any1_iterator</code>, + etc., for subsequent wildcards in the type definition), and an alias + of the constant iterator type with name <code>any_const_iterator</code> + (or <code>any1_const_iterator</code>, etc., for subsequent wildcards + in the type definition). + </p> + + <p>The accessor functions come in constant and non-constant versions. + The constant accessor function returns a constant reference to the + container and can be used for read-only access. The non-constant + version returns an unrestricted reference to the container and can + be used for read-write access. + </p> + + <p>The modifier function expects an argument of type reference to + constant of the container type. The modifier function makes + a deep copy of its argument. For instance: + </p> + + + <pre class="xml"> +<complexType name="object"> + <sequence> + <any namespace="##other" minOccurs="unbounded"/> + </sequence> +</complexType> + </pre> + + <p>is mapped to:</p> + + <pre class="c++"> +class object: public xml_schema::type +{ +public: + // Type definitions. + // + typedef element_sequence any_sequence; + typedef any_sequence::iterator any_iterator; + typedef any_sequence::const_iterator any_const_iterator; + + // Accessors. + // + const any_sequence& + any () const; + + any_sequence& + any (); + + // Modifier. + // + void + any (const any_sequence&); + + ... + +}; + </pre> + + <p>The <code>element_sequence</code> container is a + specialization of the <code>sequence</code> class template described + in <a href="#2.8.3">Section 2.8.3, "Mapping for Members with the + Sequence Cardinality Class"</a>. Its interface is similar to + the sequence interface as defined by the ISO/ANSI Standard for + C++ (ISO/IEC 14882:1998, Section 23.1.1, "Sequences") and is + presented below: + </p> + + <pre class="c++"> +class element_sequence +{ +public: + typedef xercesc::DOMElement value_type; + typedef xercesc::DOMElement* pointer; + typedef const xercesc::DOMElement* const_pointer; + typedef xercesc::DOMElement& reference; + typedef const xercesc::DOMElement& const_reference; + + typedef <implementation-defined> iterator; + typedef <implementation-defined> const_iterator; + typedef <implementation-defined> reverse_iterator; + typedef <implementation-defined> const_reverse_iterator; + + typedef <implementation-defined> size_type; + typedef <implementation-defined> difference_type; + typedef <implementation-defined> allocator_type; + +public: + explicit + element_sequence (xercesc::DOMDocument&); + + // DOMElement cannot be default-constructed. + // + // explicit + // element_sequence (size_type n); + + element_sequence (size_type n, + const xercesc::DOMElement&, + xercesc::DOMDocument&); + + template <typename I> + element_sequence (const I& begin, + const I& end, + xercesc::DOMDocument&); + + element_sequence (const element_sequence&, xercesc::DOMDocument&); + + element_sequence& + operator= (const element_sequence&); + +public: + void + assign (size_type n, const xercesc::DOMElement&); + + template <typename I> + void + assign (const I& begin, const I& end); + +public: + // This version of resize can only be used to shrink the + // sequence because DOMElement cannot be default-constructed. + // + void + resize (size_type); + + void + resize (size_type, const xercesc::DOMElement&); + +public: + size_type + size () const; + + size_type + max_size () const; + + size_type + capacity () const; + + bool + empty () const; + + void + reserve (size_type); + + void + clear (); + +public: + const_iterator + begin () const; + + const_iterator + end () const; + + iterator + begin (); + + iterator + end (); + + const_reverse_iterator + rbegin () const; + + const_reverse_iterator + rend () const + + reverse_iterator + rbegin (); + + reverse_iterator + rend (); + +public: + xercesc::DOMElement& + operator[] (size_type); + + const xercesc::DOMElement& + operator[] (size_type) const; + + xercesc::DOMElement& + at (size_type); + + const xercesc::DOMElement& + at (size_type) const; + + xercesc::DOMElement& + front (); + + const xercesc::DOMElement& + front () const; + + xercesc::DOMElement& + back (); + + const xercesc::DOMElement& + back () const; + +public: + // Makes a deep copy. + // + void + push_back (const xercesc::DOMElement&); + + // Assumes ownership. + // + void + push_back (xercesc::DOMElement*); + + void + pop_back (); + + // Makes a deep copy. + // + iterator + insert (iterator position, const xercesc::DOMElement&); + + // Assumes ownership. + // + iterator + insert (iterator position, xercesc::DOMElement*); + + void + insert (iterator position, size_type n, const xercesc::DOMElement&); + + template <typename I> + void + insert (iterator position, const I& begin, const I& end); + + iterator + erase (iterator position); + + iterator + erase (iterator begin, iterator end); + +public: + // Note that the DOMDocument object of the two sequences being + // swapped should be the same. + // + void + swap (sequence& x); +}; + +inline bool +operator== (const element_sequence&, const element_sequence&); + +inline bool +operator!= (const element_sequence&, const element_sequence&); + </pre> + + + <p>The following code shows how one could use this mapping:</p> + + <pre class="c++"> +void +f (object& o, const xercesc::DOMElement& e) +{ + using namespace xercesc; + + object::any_sequence& s (o.any ()); + + // Iteration. + // + for (object::any_iterator i (s.begin ()); i != s.end (); ++i) + { + DOMElement& e (*i); + } + + // Modification. + // + s.push_back (e); // deep copy + DOMDocument& doc (o.dom_document ()); + s.push_back (doc.createElement (...)); // assumes ownership +} + </pre> + + <h3><a name="2.12.4">2.12.4 Element Wildcard Order</a></h3> + + <p>Similar to elements, element wildcards in ordered types + (<a href="#2.8.4">Section 2.8.4, "Element Order"</a>) are assigned + content ids and are included in the content order sequence. + Continuing with the bank transactions example started in Section + 2.8.4, we can extend the batch by allowing custom transactions:</p> + + <pre class="xml"> +<complexType name="batch"> + <choice minOccurs="0" maxOccurs="unbounded"> + <element name="withdraw" type="withdraw"/> + <element name="deposit" type="deposit"/> + <any namespace="##other" processContents="lax"/> + </choice> +</complexType> + </pre> + + <p>This will lead to the following changes in the generated + <code>batch</code> C++ class:</p> + + <pre class="c++"> +class batch: public xml_schema::type +{ +public: + ... + + // any + // + typedef element_sequence any_sequence; + typedef any_sequence::iterator any_iterator; + typedef any_sequence::const_iterator any_const_iterator; + + static const std::size_t any_id = 3UL; + + const any_sequence& + any () const; + + any_sequence& + any (); + + void + any (const any_sequence&); + + ... +}; + </pre> + + <p>With this change we also need to update the iteration code to handle + the new content id:</p> + + <pre class="c++"> +for (batch::content_order_const_iterator i (b.content_order ().begin ()); + i != b.content_order ().end (); + ++i) +{ + switch (i->id) + { + ... + + case batch::any_id: + { + const DOMElement& e (b.any ()[i->index]); + ... + break; + } + + ... + } +} + </pre> + + <p>For the complete working code that shows the use of wildcards in + ordered types refer to the <code>order/element</code> example in + the <code>examples/cxx/tree/</code> directory in the XSD + distribution.</p> + + <h3><a name="2.12.5">2.12.5 Mapping for <code>anyAttribute</code></a></h3> + + <p>For <code>anyAttribute</code> the type definitions consist of an alias + of the container type with name <code>any_attribute_set</code> + (or <code>any1_attribute_set</code>, etc., for subsequent wildcards + in the type definition), an alias of the iterator type with name + <code>any_attribute_iterator</code> (or <code>any1_attribute_iterator</code>, + etc., for subsequent wildcards in the type definition), and an alias + of the constant iterator type with name <code>any_attribute_const_iterator</code> + (or <code>any1_attribute_const_iterator</code>, etc., for subsequent + wildcards in the type definition). + </p> + + <p>The accessor functions come in constant and non-constant versions. + The constant accessor function returns a constant reference to the + container and can be used for read-only access. The non-constant + version returns an unrestricted reference to the container and can + be used for read-write access. + </p> + + <p>The modifier function expects an argument of type reference to + constant of the container type. The modifier function makes + a deep copy of its argument. For instance: + </p> + + + <pre class="xml"> +<complexType name="object"> + <sequence> + ... + </sequence> + <anyAttribute namespace="##other"/> +</complexType> + </pre> + + <p>is mapped to:</p> + + <pre class="c++"> +class object: public xml_schema::type +{ +public: + // Type definitions. + // + typedef attribute_set any_attribute_set; + typedef any_attribute_set::iterator any_attribute_iterator; + typedef any_attribute_set::const_iterator any_attribute_const_iterator; + + // Accessors. + // + const any_attribute_set& + any_attribute () const; + + any_attribute_set& + any_attribute (); + + // Modifier. + // + void + any_attribute (const any_attribute_set&); + + ... + +}; + </pre> + + <p>The <code>attribute_set</code> class is an associative container + similar to the <code>std::set</code> class template as defined by + the ISO/ANSI Standard for C++ (ISO/IEC 14882:1998, Section 23.3.3, + "Class template set") with the key being the attribute's name + and namespace. Unlike <code>std::set</code>, <code>attribute_set</code> + allows searching using names and namespaces instead of + <code>xercesc::DOMAttr</code> objects. It is defined in an + implementation-specific namespace and its interface is presented + below: + </p> + + <pre class="c++"> +class attribute_set +{ +public: + typedef xercesc::DOMAttr key_type; + typedef xercesc::DOMAttr value_type; + typedef xercesc::DOMAttr* pointer; + typedef const xercesc::DOMAttr* const_pointer; + typedef xercesc::DOMAttr& reference; + typedef const xercesc::DOMAttr& const_reference; + + typedef <implementation-defined> iterator; + typedef <implementation-defined> const_iterator; + typedef <implementation-defined> reverse_iterator; + typedef <implementation-defined> const_reverse_iterator; + + typedef <implementation-defined> size_type; + typedef <implementation-defined> difference_type; + typedef <implementation-defined> allocator_type; + +public: + attribute_set (xercesc::DOMDocument&); + + template <typename I> + attribute_set (const I& begin, const I& end, xercesc::DOMDocument&); + + attribute_set (const attribute_set&, xercesc::DOMDocument&); + + attribute_set& + operator= (const attribute_set&); + +public: + const_iterator + begin () const; + + const_iterator + end () const; + + iterator + begin (); + + iterator + end (); + + const_reverse_iterator + rbegin () const; + + const_reverse_iterator + rend () const; + + reverse_iterator + rbegin (); + + reverse_iterator + rend (); + +public: + size_type + size () const; + + size_type + max_size () const; + + bool + empty () const; + + void + clear (); + +public: + // Makes a deep copy. + // + std::pair<iterator, bool> + insert (const xercesc::DOMAttr&); + + // Assumes ownership. + // + std::pair<iterator, bool> + insert (xercesc::DOMAttr*); + + // Makes a deep copy. + // + iterator + insert (iterator position, const xercesc::DOMAttr&); + + // Assumes ownership. + // + iterator + insert (iterator position, xercesc::DOMAttr*); + + template <typename I> + void + insert (const I& begin, const I& end); + +public: + void + erase (iterator position); + + size_type + erase (const std::basic_string<C>& name); + + size_type + erase (const std::basic_string<C>& namespace_, + const std::basic_string<C>& name); + + size_type + erase (const XMLCh* name); + + size_type + erase (const XMLCh* namespace_, const XMLCh* name); + + void + erase (iterator begin, iterator end); + +public: + size_type + count (const std::basic_string<C>& name) const; + + size_type + count (const std::basic_string<C>& namespace_, + const std::basic_string<C>& name) const; + + size_type + count (const XMLCh* name) const; + + size_type + count (const XMLCh* namespace_, const XMLCh* name) const; + + iterator + find (const std::basic_string<C>& name); + + iterator + find (const std::basic_string<C>& namespace_, + const std::basic_string<C>& name); + + iterator + find (const XMLCh* name); + + iterator + find (const XMLCh* namespace_, const XMLCh* name); + + const_iterator + find (const std::basic_string<C>& name) const; + + const_iterator + find (const std::basic_string<C>& namespace_, + const std::basic_string<C>& name) const; + + const_iterator + find (const XMLCh* name) const; + + const_iterator + find (const XMLCh* namespace_, const XMLCh* name) const; + +public: + // Note that the DOMDocument object of the two sets being + // swapped should be the same. + // + void + swap (attribute_set&); +}; + +bool +operator== (const attribute_set&, const attribute_set&); + +bool +operator!= (const attribute_set&, const attribute_set&); + </pre> + + <p>The following code shows how one could use this mapping:</p> + + <pre class="c++"> +void +f (object& o, const xercesc::DOMAttr& a) +{ + using namespace xercesc; + + object::any_attribute_set& s (o.any_attribute ()); + + // Iteration. + // + for (object::any_attribute_iterator i (s.begin ()); i != s.end (); ++i) + { + DOMAttr& a (*i); + } + + // Modification. + // + s.insert (a); // deep copy + DOMDocument& doc (o.dom_document ()); + s.insert (doc.createAttribute (...)); // assumes ownership + + // Searching. + // + object::any_attribute_iterator i (s.find ("name")); + i = s.find ("http://www.w3.org/XML/1998/namespace", "lang"); +} + </pre> + + <!-- Mapping for Mixed Content Models --> + + <h2><a name="2.13">2.13 Mapping for Mixed Content Models</a></h2> + + <p>For XML Schema types with mixed content models C++/Tree provides + mapping support only if the type is marked as ordered + (<a href="#2.8.4">Section 2.8.4, "Element Order"</a>). Use the + <code>--ordered-type-mixed</code> XSD compiler option to + automatically mark all types with mixed content as ordered.</p> + + <p>For an ordered type with mixed content, C++/Tree adds an extra + text content sequence that is used to store the text fragments. + This text content sequence is also assigned the content id and + its entries are included in the content order sequence, just + like elements. As a result, it is possible to capture the order + between elements and text fragments.</p> + + <p>As an example, consider the following schema that describes text + with embedded links:</p> + + <pre class="xml"> +<complexType name="anchor"> + <simpleContent> + <extension base="string"> + <attribute name="href" type="anyURI" use="required"/> + </extension> + </simpleContent> +</complexType> + +<complexType name="text" mixed="true"> + <sequence> + <element name="a" type="anchor" minOccurs="0" maxOccurs="unbounded"/> + </sequence> +</complexType> + </pre> + + <p>The generated <code>text</code> C++ class will provide the following + API (assuming it is marked as ordered):</p> + + <pre class="c++"> +class text: public xml_schema::type +{ +public: + // a + // + typedef anchor a_type; + typedef sequence<a_type> a_sequence; + typedef a_sequence::iterator a_iterator; + typedef a_sequence::const_iterator a_const_iterator; + + static const std::size_t a_id = 1UL; + + const a_sequence& + a () const; + + a_sequence& + a (); + + void + a (const a_sequence&); + + // text_content + // + typedef xml_schema::string text_content_type; + typedef sequence<text_content_type> text_content_sequence; + typedef text_content_sequence::iterator text_content_iterator; + typedef text_content_sequence::const_iterator text_content_const_iterator; + + static const std::size_t text_content_id = 2UL; + + const text_content_sequence& + text_content () const; + + text_content_sequence& + text_content (); + + void + text_content (const text_content_sequence&); + + // content_order + // + typedef xml_schema::content_order content_order_type; + typedef std::vector<content_order_type> content_order_sequence; + typedef content_order_sequence::iterator content_order_iterator; + typedef content_order_sequence::const_iterator content_order_const_iterator; + + const content_order_sequence& + content_order () const; + + content_order_sequence& + content_order (); + + void + content_order (const content_order_sequence&); + + ... +}; + </pre> + + <p>Given this interface we can iterate over both link elements + and text in content order. The following code fragment converts + our format to plain text with references.</p> + + <pre class="c++"> +const text& t = ... + +for (text::content_order_const_iterator i (t.content_order ().begin ()); + i != t.content_order ().end (); + ++i) +{ + switch (i->id) + { + case text::a_id: + { + const anchor& a (t.a ()[i->index]); + cerr << a << "[" << a.href () << "]"; + break; + } + case text::text_content_id: + { + const xml_schema::string& s (t.text_content ()[i->index]); + cerr << s; + break; + } + default: + { + assert (false); // Unknown content id. + } + } +} + </pre> + + <p>For the complete working code that shows the use of mixed content + in ordered types refer to the <code>order/mixed</code> example in + the <code>examples/cxx/tree/</code> directory in the XSD + distribution.</p> + + <!-- Parsing --> + + + <h1><a name="3">3 Parsing</a></h1> + + <p>This chapter covers various aspects of parsing XML instance + documents in order to obtain corresponding tree-like object + model. + </p> + + <p>Each global XML Schema element in the form:</p> + + <pre class="xml"> +<element name="name" type="type"/> + </pre> + + <p>is mapped to 14 overloaded C++ functions in the form:</p> + + <pre class="c++"> +// Read from a URI or a local file. +// + +std::[auto|unique]_ptr<type> +name (const std::basic_string<C>& uri, + xml_schema::flags = 0, + const xml_schema::properties& = xml_schema::properties ()); + +std::[auto|unique]_ptr<type> +name (const std::basic_string<C>& uri, + xml_schema::error_handler&, + xml_schema::flags = 0, + const xml_schema::properties& = xml_schema::properties ()); + +std::[auto|unique]_ptr<type> +name (const std::basic_string<C>& uri, + xercesc::DOMErrorHandler&, + xml_schema::flags = 0, + const xml_schema::properties& = xml_schema::properties ()); + + +// Read from std::istream. +// + +std::[auto|unique]_ptr<type> +name (std::istream&, + xml_schema::flags = 0, + const xml_schema::properties& = xml_schema::properties ()); + +std::[auto|unique]_ptr<type> +name (std::istream&, + xml_schema::error_handler&, + xml_schema::flags = 0, + const xml_schema::properties& = xml_schema::properties ()); + +std::[auto|unique]_ptr<type> +name (std::istream&, + xercesc::DOMErrorHandler&, + xml_schema::flags = 0, + const xml_schema::properties& = xml_schema::properties ()); + + +std::[auto|unique]_ptr<type> +name (std::istream&, + const std::basic_string<C>& id, + xml_schema::flags = 0, + const xml_schema::properties& = xml_schema::properties ()); + +std::[auto|unique]_ptr<type> +name (std::istream&, + const std::basic_string<C>& id, + xml_schema::error_handler&, + xml_schema::flags = 0, + const xml_schema::properties& = xml_schema::properties ()); + +std::[auto|unique]_ptr<type> +name (std::istream&, + const std::basic_string<C>& id, + xercesc::DOMErrorHandler&, + xml_schema::flags = 0, + const xml_schema::properties& = xml_schema::properties ()); + + +// Read from InputSource. +// + +std::[auto|unique]_ptr<type> +name (xercesc::InputSource&, + xml_schema::flags = 0, + const xml_schema::properties& = xml_schema::properties ()); + +std::[auto|unique]_ptr<type> +name (xercesc::InputSource&, + xml_schema::error_handler&, + xml_schema::flags = 0, + const xml_schema::properties& = xml_schema::properties ()); + +std::[auto|unique]_ptr<type> +name (xercesc::InputSource&, + xercesc::DOMErrorHandler&, + xml_schema::flags = 0, + const xml_schema::properties& = xml_schema::properties ()); + + +// Read from DOM. +// + +std::[auto|unique]_ptr<type> +name (const xercesc::DOMDocument&, + xml_schema::flags = 0, + const xml_schema::properties& = xml_schema::properties ()); + +std::[auto|unique]_ptr<type> +name (xml_schema::dom::[auto|unique]_ptr<xercesc::DOMDocument>, + xml_schema::flags = 0, + const xml_schema::properties& = xml_schema::properties ()); + </pre> + + <p>You can choose between reading an XML instance from a local file, + URI, <code>std::istream</code>, <code>xercesc::InputSource</code>, + or a pre-parsed DOM instance in the form of + <code>xercesc::DOMDocument</code>. All the parsing functions + return a dynamically allocated object model as either + <code>std::auto_ptr</code> or <code>std::unique_ptr</code>, + depending on the C++ standard selected. Each of these parsing + functions is discussed in more detail in the following sections. + </p> + + <h2><a name="3.1">3.1 Initializing the Xerces-C++ Runtime</a></h2> + + <p>Some parsing functions expect you to initialize the Xerces-C++ + runtime while others initialize and terminate it as part of their + work. The general rule is as follows: if a function has any arguments + or return a value that is an instance of a Xerces-C++ type, then + this function expects you to initialize the Xerces-C++ runtime. + Otherwise, the function initializes and terminates the runtime for + you. Note that it is legal to have nested calls to the Xerces-C++ + initialize and terminate functions as long as the calls are balanced. + </p> + + <p>You can instruct parsing functions that initialize and terminate + the runtime not to do so by passing the + <code>xml_schema::flags::dont_initialize</code> flag (see + <a href="#3.2">Section 3.2, "Flags and Properties"</a>). + </p> + + + <h2><a name="3.2">3.2 Flags and Properties</a></h2> + + <p>Parsing flags and properties are the last two arguments of every + parsing function. They allow you to fine-tune the process of + instance validation and parsing. Both arguments are optional. + </p> + + + <p>The following flags are recognized by the parsing functions:</p> + + <dl> + <dt><code>xml_schema::flags::keep_dom</code></dt> + <dd>Keep association between DOM nodes and the resulting + object model nodes. For more information about DOM association + refer to <a href="#5.1">Section 5.1, "DOM Association"</a>.</dd> + + <dt><code>xml_schema::flags::own_dom</code></dt> + <dd>Assume ownership of the DOM document passed. This flag only + makes sense together with the <code>keep_dom</code> flag in + the call to the parsing function with the + <code>xml_schema::dom::[auto|unique]_ptr<DOMDocument></code> + argument.</dd> + + <dt><code>xml_schema::flags::dont_validate</code></dt> + <dd>Do not validate instance documents against schemas.</dd> + + <dt><code>xml_schema::flags::dont_initialize</code></dt> + <dd>Do not initialize the Xerces-C++ runtime.</dd> + </dl> + + <p>You can pass several flags by combining them using the bit-wise OR + operator. For example:</p> + + <pre class="c++"> +using xml_schema::flags; + +std::auto_ptr<type> r ( + name ("test.xml", flags::keep_dom | flags::dont_validate)); + </pre> + + <p>By default, validation of instance documents is turned on even + though parsers generated by XSD do not assume instance + documents are valid. They include a number of checks that prevent + construction of inconsistent object models. This, + however, does not mean that an instance document that was + successfully parsed by the XSD-generated parsers is + valid per the corresponding schema. If an instance document is not + "valid enough" for the generated parsers to construct consistent + object model, one of the exceptions defined in + <code>xml_schema</code> namespace is thrown (see + <a href="#3.3">Section 3.3, "Error Handling"</a>). + </p> + + <p>For more information on the Xerces-C++ runtime initialization + refer to <a href="#3.1">Section 3.1, "Initializing the Xerces-C++ + Runtime"</a>. + </p> + + <p>The <code>xml_schema::properties</code> class allows you to + programmatically specify schema locations to be used instead + of those specified with the <code>xsi::schemaLocation</code> + and <code>xsi::noNamespaceSchemaLocation</code> attributes + in instance documents. The interface of the <code>properties</code> + class is presented below: + </p> + + <pre class="c++"> +class properties +{ +public: + void + schema_location (const std::basic_string<C>& namespace_, + const std::basic_string<C>& location); + void + no_namespace_schema_location (const std::basic_string<C>& location); +}; + </pre> + + <p>Note that all locations are relative to an instance document unless + they are URIs. For example, if you want to use a local file as your + schema, then you will need to pass + <code>file:///absolute/path/to/your/schema</code> as the location + argument. + </p> + + <h2><a name="3.3">3.3 Error Handling</a></h2> + + <p>As discussed in <a href="#2.2">Section 2.2, "Error Handling"</a>, + the mapping uses the C++ exception handling mechanism as its primary + way of reporting error conditions. However, to handle recoverable + parsing and validation errors and warnings, a callback interface maybe + preferred by the application.</p> + + <p>To better understand error handling and reporting strategies employed + by the parsing functions, it is useful to know that the + transformation of an XML instance document to a statically-typed + tree happens in two stages. The first stage, performed by Xerces-C++, + consists of parsing an XML document into a DOM instance. For short, + we will call this stage the XML-DOM stage. Validation, if not disabled, + happens during this stage. The second stage, + performed by the generated parsers, consist of parsing the DOM + instance into the statically-typed tree. We will call this stage + the DOM-Tree stage. Additional checks are performed during this + stage in order to prevent construction of inconsistent tree which + could otherwise happen when validation is disabled, for example.</p> + + <p>All parsing functions except the one that operates on a DOM instance + come in overloaded triples. The first function in such a triple + reports error conditions exclusively by throwing exceptions. It + accumulates all the parsing and validation errors of the XML-DOM + stage and throws them in a single instance of the + <code>xml_schema::parsing</code> exception (described below). + The second and the third functions in the triple use callback + interfaces to report parsing and validation errors and warnings. + The two callback interfaces are <code>xml_schema::error_handler</code> + and <code>xercesc::DOMErrorHandler</code>. For more information + on the <code>xercesc::DOMErrorHandler</code> interface refer to + the Xerces-C++ documentation. The <code>xml_schema::error_handler</code> + interface is presented below: + </p> + + <pre class="c++"> +class error_handler +{ +public: + struct severity + { + enum value + { + warning, + error, + fatal + }; + }; + + virtual bool + handle (const std::basic_string<C>& id, + unsigned long line, + unsigned long column, + severity, + const std::basic_string<C>& message) = 0; + + virtual + ~error_handler (); +}; + </pre> + + <p>The <code>id</code> argument of the <code>error_handler::handle</code> + function identifies the resource being parsed (e.g., a file name or + URI). + </p> + + <p>By returning <code>true</code> from the <code>handle</code> function + you instruct the parser to recover and continue parsing. Returning + <code>false</code> results in termination of the parsing process. + An error with the <code>fatal</code> severity level results in + termination of the parsing process no matter what is returned from + the <code>handle</code> function. It is safe to throw an exception + from the <code>handle</code> function. + </p> + + <p>The DOM-Tree stage reports error conditions exclusively by throwing + exceptions. Individual exceptions thrown by the parsing functions + are described in the following sub-sections. + </p> + + + <h3><a name="3.3.1">3.3.1 <code>xml_schema::parsing</code></a></h3> + + <pre class="c++"> +struct severity +{ + enum value + { + warning, + error + }; + + severity (value); + operator value () const; +}; + +struct error +{ + error (severity, + const std::basic_string<C>& id, + unsigned long line, + unsigned long column, + const std::basic_string<C>& message); + + severity + severity () const; + + const std::basic_string<C>& + id () const; + + unsigned long + line () const; + + unsigned long + column () const; + + const std::basic_string<C>& + message () const; +}; + +std::basic_ostream<C>& +operator<< (std::basic_ostream<C>&, const error&); + +struct diagnostics: std::vector<error> +{ +}; + +std::basic_ostream<C>& +operator<< (std::basic_ostream<C>&, const diagnostics&); + +struct parsing: virtual exception +{ + parsing (); + parsing (const diagnostics&); + + const diagnostics& + diagnostics () const; + + virtual const char* + what () const throw (); +}; + </pre> + + <p>The <code>xml_schema::parsing</code> exception is thrown if there + were parsing or validation errors reported during the XML-DOM stage. + If no callback interface was provided to the parsing function, the + exception contains a list of errors and warnings accessible using + the <code>diagnostics</code> function. The usual conditions when + this exception is thrown include malformed XML instances and, if + validation is turned on, invalid instance documents. + </p> + + <h3><a name="3.3.2">3.3.2 <code>xml_schema::expected_element</code></a></h3> + + <pre class="c++"> +struct expected_element: virtual exception +{ + expected_element (const std::basic_string<C>& name, + const std::basic_string<C>& namespace_); + + + const std::basic_string<C>& + name () const; + + const std::basic_string<C>& + namespace_ () const; + + + virtual const char* + what () const throw (); +}; + </pre> + + <p>The <code>xml_schema::expected_element</code> exception is thrown + when an expected element is not encountered by the DOM-Tree stage. + The name and namespace of the expected element can be obtained using + the <code>name</code> and <code>namespace_</code> functions respectively. + </p> + + + <h3><a name="3.3.3">3.3.3 <code>xml_schema::unexpected_element</code></a></h3> + + <pre class="c++"> +struct unexpected_element: virtual exception +{ + unexpected_element (const std::basic_string<C>& encountered_name, + const std::basic_string<C>& encountered_namespace, + const std::basic_string<C>& expected_name, + const std::basic_string<C>& expected_namespace) + + + const std::basic_string<C>& + encountered_name () const; + + const std::basic_string<C>& + encountered_namespace () const; + + + const std::basic_string<C>& + expected_name () const; + + const std::basic_string<C>& + expected_namespace () const; + + + virtual const char* + what () const throw (); +}; + </pre> + + <p>The <code>xml_schema::unexpected_element</code> exception is thrown + when an unexpected element is encountered by the DOM-Tree stage. + The name and namespace of the encountered element can be obtained + using the <code>encountered_name</code> and + <code>encountered_namespace</code> functions respectively. If an + element was expected instead of the encountered one, its name + and namespace can be obtained using the <code>expected_name</code> and + <code>expected_namespace</code> functions respectively. Otherwise + these functions return empty strings. + </p> + + <h3><a name="3.3.4">3.3.4 <code>xml_schema::expected_attribute</code></a></h3> + + <pre class="c++"> +struct expected_attribute: virtual exception +{ + expected_attribute (const std::basic_string<C>& name, + const std::basic_string<C>& namespace_); + + + const std::basic_string<C>& + name () const; + + const std::basic_string<C>& + namespace_ () const; + + + virtual const char* + what () const throw (); +}; + </pre> + + <p>The <code>xml_schema::expected_attribute</code> exception is thrown + when an expected attribute is not encountered by the DOM-Tree stage. + The name and namespace of the expected attribute can be obtained using + the <code>name</code> and <code>namespace_</code> functions respectively. + </p> + + + <h3><a name="3.3.5">3.3.5 <code>xml_schema::unexpected_enumerator</code></a></h3> + + <pre class="c++"> +struct unexpected_enumerator: virtual exception +{ + unexpected_enumerator (const std::basic_string<C>& enumerator); + + const std::basic_string<C>& + enumerator () const; + + virtual const char* + what () const throw (); +}; + </pre> + + <p>The <code>xml_schema::unexpected_enumerator</code> exception is thrown + when an unexpected enumerator is encountered by the DOM-Tree stage. + The enumerator can be obtained using the <code>enumerator</code> + functions. + </p> + + <h3><a name="3.3.6">3.3.6 <code>xml_schema::expected_text_content</code></a></h3> + + <pre class="c++"> +struct expected_text_content: virtual exception +{ + virtual const char* + what () const throw (); +}; + </pre> + + <p>The <code>xml_schema::expected_text_content</code> exception is thrown + when a content other than text is encountered and the text content was + expected by the DOM-Tree stage. + </p> + + <h3><a name="3.3.7">3.3.7 <code>xml_schema::no_type_info</code></a></h3> + + <pre class="c++"> +struct no_type_info: virtual exception +{ + no_type_info (const std::basic_string<C>& type_name, + const std::basic_string<C>& type_namespace); + + const std::basic_string<C>& + type_name () const; + + const std::basic_string<C>& + type_namespace () const; + + virtual const char* + what () const throw (); +}; + </pre> + + <p>The <code>xml_schema::no_type_info</code> exception is thrown + when there is no type information associated with a type specified + by the <code>xsi:type</code> attribute. This exception is thrown + by the DOM-Tree stage. The name and namespace of the type in question + can be obtained using the <code>type_name</code> and + <code>type_namespace</code> functions respectively. Usually, catching + this exception means that you haven't linked the code generated + from the schema defining the type in question with your application + or this schema has been compiled without the + <code>--generate-polymorphic</code> option. + </p> + + + <h3><a name="3.3.8">3.3.8 <code>xml_schema::not_derived</code></a></h3> + + <pre class="c++"> +struct not_derived: virtual exception +{ + not_derived (const std::basic_string<C>& base_type_name, + const std::basic_string<C>& base_type_namespace, + const std::basic_string<C>& derived_type_name, + const std::basic_string<C>& derived_type_namespace); + + const std::basic_string<C>& + base_type_name () const; + + const std::basic_string<C>& + base_type_namespace () const; + + + const std::basic_string<C>& + derived_type_name () const; + + const std::basic_string<C>& + derived_type_namespace () const; + + virtual const char* + what () const throw (); +}; + </pre> + + <p>The <code>xml_schema::not_derived</code> exception is thrown + when a type specified by the <code>xsi:type</code> attribute is + not derived from the expected base type. This exception is thrown + by the DOM-Tree stage. The name and namespace of the expected + base type can be obtained using the <code>base_type_name</code> and + <code>base_type_namespace</code> functions respectively. The name + and namespace of the offending type can be obtained using the + <code>derived_type_name</code> and + <code>derived_type_namespace</code> functions respectively. + </p> + + <h3><a name="3.3.9">3.3.9 <code>xml_schema::no_prefix_mapping</code></a></h3> + + <pre class="c++"> +struct no_prefix_mapping: virtual exception +{ + no_prefix_mapping (const std::basic_string<C>& prefix); + + const std::basic_string<C>& + prefix () const; + + virtual const char* + what () const throw (); +}; + </pre> + + <p>The <code>xml_schema::no_prefix_mapping</code> exception is thrown + during the DOM-Tree stage if a namespace prefix is encountered for + which a prefix-namespace mapping hasn't been provided. The namespace + prefix in question can be obtained using the <code>prefix</code> + function. + </p> + + <h2><a name="3.4">3.4 Reading from a Local File or URI</a></h2> + + <p>Using a local file or URI is the simplest way to parse an XML instance. + For example:</p> + + <pre class="c++"> +using std::auto_ptr; + +auto_ptr<type> r1 (name ("test.xml")); +auto_ptr<type> r2 (name ("http://www.codesynthesis.com/test.xml")); + </pre> + + <p>Or, in the C++11 mode:</p> + + <pre class="c++"> +using std::unique_ptr; + +unique_ptr<type> r1 (name ("test.xml")); +unique_ptr<type> r2 (name ("http://www.codesynthesis.com/test.xml")); + </pre> + + <h2><a name="3.5">3.5 Reading from <code>std::istream</code></a></h2> + + <p>When using an <code>std::istream</code> instance, you may also + pass an optional resource id. This id is used to identify the + resource (for example in error messages) as well as to resolve + relative paths. For instance:</p> + + <pre class="c++"> +using std::auto_ptr; + +{ + std::ifstream ifs ("test.xml"); + auto_ptr<type> r (name (ifs, "test.xml")); +} + +{ + std::string str ("..."); // Some XML fragment. + std::istringstream iss (str); + auto_ptr<type> r (name (iss)); +} + </pre> + + <h2><a name="3.6">3.6 Reading from <code>xercesc::InputSource</code></a></h2> + + <p>Reading from a <code>xercesc::InputSource</code> instance + is similar to the <code>std::istream</code> case except + the resource id is maintained by the <code>InputSource</code> + object. For instance:</p> + + <pre class="c++"> +xercesc::StdInInputSource is; +std::auto_ptr<type> r (name (is)); + </pre> + + <h2><a name="3.7">3.7 Reading from DOM</a></h2> + + <p>Reading from a <code>xercesc::DOMDocument</code> instance allows + you to setup a custom XML-DOM stage. Things like DOM + parser reuse, schema pre-parsing, and schema caching can be achieved + with this approach. For more information on how to obtain DOM + representation from an XML instance refer to the Xerces-C++ + documentation. In addition, the + <a href="http://wiki.codesynthesis.com/Tree/FAQ">C++/Tree Mapping + FAQ</a> shows how to parse an XML instance to a Xerces-C++ + DOM document using the XSD runtime utilities. + </p> + + <p>The last parsing function is useful when you would like to perform + your own XML-to-DOM parsing and associate the resulting DOM document + with the object model nodes. The automatic <code>DOMDocument</code> + pointer is reset and the resulting object model assumes ownership + of the DOM document passed. For example:</p> + + <pre class="c++"> +// C++98 version. +// +xml_schema::dom::auto_ptr<xercesc::DOMDocument> doc = ... + +std::auto_ptr<type> r ( + name (doc, xml_schema::flags::keep_dom | xml_schema::flags::own_dom)); + +// At this point doc is reset to 0. + +// C++11 version. +// +xml_schema::dom::unique_ptr<xercesc::DOMDocument> doc = ... + +std::unique_ptr<type> r ( + name (std::move (doc), + xml_schema::flags::keep_dom | xml_schema::flags::own_dom)); + +// At this point doc is reset to 0. + </pre> + + <h1><a name="4">4 Serialization</a></h1> + + <p>This chapter covers various aspects of serializing a + tree-like object model to DOM or XML. + In this regard, serialization is complimentary to the reverse + process of parsing a DOM or XML instance into an object model + which is discussed in <a href="#3">Chapter 3, + "Parsing"</a>. Note that the generation of the serialization code + is optional and should be explicitly requested with the + <code>--generate-serialization</code> option. See the + <a href="http://www.codesynthesis.com/projects/xsd/documentation/xsd.xhtml">XSD + Compiler Command Line Manual</a> for more information. + </p> + + <p>Each global XML Schema element in the form: + </p> + + + <pre class="xml"> +<xsd:element name="name" type="type"/> + </pre> + + <p>is mapped to 8 overloaded C++ functions in the form:</p> + + <pre class="c++"> +// Serialize to std::ostream. +// +void +name (std::ostream&, + const type&, + const xml_schema::namespace_fomap& = + xml_schema::namespace_infomap (), + const std::basic_string<C>& encoding = "UTF-8", + xml_schema::flags = 0); + +void +name (std::ostream&, + const type&, + xml_schema::error_handler&, + const xml_schema::namespace_infomap& = + xml_schema::namespace_infomap (), + const std::basic_string<C>& encoding = "UTF-8", + xml_schema::flags = 0); + +void +name (std::ostream&, + const type&, + xercesc::DOMErrorHandler&, + const xml_schema::namespace_infomap& = + xml_schema::namespace_infomap (), + const std::basic_string<C>& encoding = "UTF-8", + xml_schema::flags = 0); + + +// Serialize to XMLFormatTarget. +// +void +name (xercesc::XMLFormatTarget&, + const type&, + const xml_schema::namespace_infomap& = + xml_schema::namespace_infomap (), + const std::basic_string<C>& encoding = "UTF-8", + xml_schema::flags = 0); + +void +name (xercesc::XMLFormatTarget&, + const type&, + xml_schema::error_handler&, + const xml_schema::namespace_infomap& = + xml_schema::namespace_infomap (), + const std::basic_string<C>& encoding = "UTF-8", + xml_schema::flags = 0); + +void +name (xercesc::XMLFormatTarget&, + const type&, + xercesc::DOMErrorHandler&, + const xml_schema::namespace_infomap& = + xml_schema::namespace_infomap (), + const std::basic_string<C>& encoding = "UTF-8", + xml_schema::flags = 0); + + +// Serialize to DOM. +// +xml_schema::dom::[auto|unique]_ptr<xercesc::DOMDocument> +name (const type&, + const xml_schema::namespace_infomap& + xml_schema::namespace_infomap (), + xml_schema::flags = 0); + +void +name (xercesc::DOMDocument&, + const type&, + xml_schema::flags = 0); + </pre> + + <p>You can choose between writing XML to <code>std::ostream</code> or + <code>xercesc::XMLFormatTarget</code> and creating a DOM instance + in the form of <code>xercesc::DOMDocument</code>. Serialization + to <code>ostream</code> or <code>XMLFormatTarget</code> requires a + considerably less work while serialization to DOM provides + for greater flexibility. Each of these serialization functions + is discussed in more detail in the following sections. + </p> + + + <h2><a name="4.1">4.1 Initializing the Xerces-C++ Runtime</a></h2> + + <p>Some serialization functions expect you to initialize the Xerces-C++ + runtime while others initialize and terminate it as part of their + work. The general rule is as follows: if a function has any arguments + or return a value that is an instance of a Xerces-C++ type, then + this function expects you to initialize the Xerces-C++ runtime. + Otherwise, the function initializes and terminates the runtime for + you. Note that it is legal to have nested calls to the Xerces-C++ + initialize and terminate functions as long as the calls are balanced. + </p> + + <p>You can instruct serialization functions that initialize and terminate + the runtime not to do so by passing the + <code>xml_schema::flags::dont_initialize</code> flag (see + <a href="#4.3">Section 4.3, "Flags"</a>). + </p> + + <h2><a name="4.2">4.2 Namespace Infomap and Character Encoding</a></h2> + + <p>When a document being serialized uses XML namespaces, custom + prefix-namespace associations can to be established. If custom + prefix-namespace mapping is not provided then generic prefixes + (<code>p1</code>, <code>p2</code>, etc) are automatically assigned + to namespaces as needed. Also, if + you would like the resulting instance document to contain the + <code>schemaLocation</code> or <code>noNamespaceSchemaLocation</code> + attributes, you will need to provide namespace-schema associations. + The <code>xml_schema::namespace_infomap</code> class is used + to capture this information:</p> + + <pre class="c++"> +struct namespace_info +{ + namespace_info (); + namespace_info (const std::basic_string<C>& name, + const std::basic_string<C>& schema); + + std::basic_string<C> name; + std::basic_string<C> schema; +}; + +// Map of namespace prefix to namespace_info. +// +struct namespace_infomap: public std::map<std::basic_string<C>, + namespace_info> +{ +}; + </pre> + + <p>Consider the following associations as an example:</p> + + <pre class="c++"> +xml_schema::namespace_infomap map; + +map["t"].name = "http://www.codesynthesis.com/test"; +map["t"].schema = "test.xsd"; + </pre> + + <p>This map, if passed to one of the serialization functions, + could result in the following XML fragment:</p> + + <pre class="xml"> +<?xml version="1.0" ?> +<t:name xmlns:t="http://www.codesynthesis.com/test" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://www.codesynthesis.com/test test.xsd"> + </pre> + + <p>As you can see, the serialization function automatically added namespace + mapping for the <code>xsi</code> prefix. You can change this by + providing your own prefix:</p> + + <pre class="c++"> +xml_schema::namespace_infomap map; + +map["xsn"].name = "http://www.w3.org/2001/XMLSchema-instance"; + +map["t"].name = "http://www.codesynthesis.com/test"; +map["t"].schema = "test.xsd"; + </pre> + + <p>This could result in the following XML fragment:</p> + + <pre class="xml"> +<?xml version="1.0" ?> +<t:name xmlns:t="http://www.codesynthesis.com/test" + xmlns:xsn="http://www.w3.org/2001/XMLSchema-instance" + xsn:schemaLocation="http://www.codesynthesis.com/test test.xsd"> + </pre> + + <p>To specify the location of a schema without a namespace you can use + an empty prefix as in the example below: </p> + + <pre class="c++"> +xml_schema::namespace_infomap map; + +map[""].schema = "test.xsd"; + </pre> + + <p>This would result in the following XML fragment:</p> + + <pre class="xml"> +<?xml version="1.0" ?> +<name xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="test.xsd"> + </pre> + + <p>To make a particular namespace default you can use an empty + prefix, for example:</p> + + <pre class="c++"> +xml_schema::namespace_infomap map; + +map[""].name = "http://www.codesynthesis.com/test"; +map[""].schema = "test.xsd"; + </pre> + + <p>This could result in the following XML fragment:</p> + + <pre class="xml"> +<?xml version="1.0" ?> +<name xmlns="http://www.codesynthesis.com/test" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://www.codesynthesis.com/test test.xsd"> + </pre> + + + <p>Another bit of information that you can pass to the serialization + functions is the character encoding method that you would like to use. + Common values for this argument are <code>"US-ASCII"</code>, + <code>"ISO8859-1"</code>, <code>"UTF-8"</code>, + <code>"UTF-16BE"</code>, <code>"UTF-16LE"</code>, + <code>"UCS-4BE"</code>, and <code>"UCS-4LE"</code>. The default + encoding is <code>"UTF-8"</code>. For more information on + encoding methods see the + "<a href="http://en.wikipedia.org/wiki/Character_code">Character + Encoding</a>" article from Wikipedia. + </p> + + <h2><a name="4.3">4.3 Flags</a></h2> + + <p>Serialization flags are the last argument of every serialization + function. They allow you to fine-tune the process of serialization. + The flags argument is optional. + </p> + + + <p>The following flags are recognized by the serialization + functions:</p> + + <dl> + <dt><code>xml_schema::flags::dont_initialize</code></dt> + <dd>Do not initialize the Xerces-C++ runtime.</dd> + + <dt><code>xml_schema::flags::dont_pretty_print</code></dt> + <dd>Do not add extra spaces or new lines that make the resulting XML + slightly bigger but easier to read.</dd> + + <dt><code>xml_schema::flags::no_xml_declaration</code></dt> + <dd>Do not write XML declaration (<?xml ... ?>).</dd> + </dl> + + <p>You can pass several flags by combining them using the bit-wise OR + operator. For example:</p> + + <pre class="c++"> +std::auto_ptr<type> r = ... +std::ofstream ofs ("test.xml"); +xml_schema::namespace_infomap map; +name (ofs, + *r, + map, + "UTF-8", + xml_schema::flags::no_xml_declaration | + xml_schema::flags::dont_pretty_print); + </pre> + + <p>For more information on the Xerces-C++ runtime initialization + refer to <a href="#4.1">Section 4.1, "Initializing the Xerces-C++ + Runtime"</a>. + </p> + + <h2><a name="4.4">4.4 Error Handling</a></h2> + + <p>As with the parsing functions (see <a href="#3.3">Section 3.3, + "Error Handling"</a>), to better understand error handling and + reporting strategies employed by the serialization functions, it + is useful to know that the transformation of a statically-typed + tree to an XML instance document happens in two stages. The first + stage, performed by the generated code, consist of building a DOM + instance from the statically-typed tree . For short, we will call + this stage the Tree-DOM stage. The second stage, performed by + Xerces-C++, consists of serializing the DOM instance into the XML + document. We will call this stage the DOM-XML stage. + </p> + + <p>All serialization functions except the two that serialize into + a DOM instance come in overloaded triples. The first function + in such a triple reports error conditions exclusively by throwing + exceptions. It accumulates all the serialization errors of the + DOM-XML stage and throws them in a single instance of the + <code>xml_schema::serialization</code> exception (described below). + The second and the third functions in the triple use callback + interfaces to report serialization errors and warnings. The two + callback interfaces are <code>xml_schema::error_handler</code> and + <code>xercesc::DOMErrorHandler</code>. The + <code>xml_schema::error_handler</code> interface is described in + <a href="#3.3">Section 3.3, "Error Handling"</a>. For more information + on the <code>xercesc::DOMErrorHandler</code> interface refer to the + Xerces-C++ documentation. + </p> + + <p>The Tree-DOM stage reports error conditions exclusively by throwing + exceptions. Individual exceptions thrown by the serialization functions + are described in the following sub-sections. + </p> + + <h3><a name="4.4.1">4.4.1 <code>xml_schema::serialization</code></a></h3> + + <pre class="c++"> +struct serialization: virtual exception +{ + serialization (); + serialization (const diagnostics&); + + const diagnostics& + diagnostics () const; + + virtual const char* + what () const throw (); +}; + </pre> + + <p>The <code>xml_schema::diagnostics</code> class is described in + <a href="#3.3.1">Section 3.3.1, "<code>xml_schema::parsing</code>"</a>. + The <code>xml_schema::serialization</code> exception is thrown if + there were serialization errors reported during the DOM-XML stage. + If no callback interface was provided to the serialization function, + the exception contains a list of errors and warnings accessible using + the <code>diagnostics</code> function. + </p> + + + <h3><a name="4.4.2">4.4.2 <code>xml_schema::unexpected_element</code></a></h3> + + <p>The <code>xml_schema::unexpected_element</code> exception is + described in <a href="#3.3.3">Section 3.3.3, + "<code>xml_schema::unexpected_element</code>"</a>. It is thrown + by the serialization functions during the Tree-DOM stage if the + root element name of the provided DOM instance does not match with + the name of the element this serialization function is for. + </p> + + <h3><a name="4.4.3">4.4.3 <code>xml_schema::no_type_info</code></a></h3> + + <p>The <code>xml_schema::no_type_info</code> exception is + described in <a href="#3.3.7">Section 3.3.7, + "<code>xml_schema::no_type_info</code>"</a>. It is thrown + by the serialization functions during the Tree-DOM stage when there + is no type information associated with a dynamic type of an + element. Usually, catching this exception means that you haven't + linked the code generated from the schema defining the type in + question with your application or this schema has been compiled + without the <code>--generate-polymorphic</code> option. + </p> + + <h2><a name="4.5">4.5 Serializing to <code>std::ostream</code></a></h2> + + <p>In order to serialize to <code>std::ostream</code> you will need + an object model, an output stream and, optionally, a namespace + infomap. For instance:</p> + + <pre class="c++"> +// Obtain the object model. +// +std::auto_ptr<type> r = ... + +// Prepare namespace mapping and schema location information. +// +xml_schema::namespace_infomap map; + +map["t"].name = "http://www.codesynthesis.com/test"; +map["t"].schema = "test.xsd"; + +// Write it out. +// +name (std::cout, *r, map); + </pre> + + <p>Note that the output stream is treated as a binary stream. This + becomes important when you use a character encoding that is wider + than 8-bit <code>char</code>, for instance UTF-16 or UCS-4. For + example, things will most likely break if you try to serialize + to <code>std::ostringstream</code> with UTF-16 or UCS-4 as an + encoding. This is due to the special value, + <code>'\0'</code>, that will most likely occur as part of such + serialization and it won't have the special meaning assumed by + <code>std::ostringstream</code>. + </p> + + + <h2><a name="4.6">4.6 Serializing to <code>xercesc::XMLFormatTarget</code></a></h2> + + <p>Serializing to an <code>xercesc::XMLFormatTarget</code> instance + is similar the <code>std::ostream</code> case. For instance: + </p> + + <pre class="c++"> +using std::auto_ptr; + +// Obtain the object model. +// +auto_ptr<type> r = ... + +// Prepare namespace mapping and schema location information. +// +xml_schema::namespace_infomap map; + +map["t"].name = "http://www.codesynthesis.com/test"; +map["t"].schema = "test.xsd"; + +using namespace xercesc; + +XMLPlatformUtils::Initialize (); + +{ + // Choose a target. + // + auto_ptr<XMLFormatTarget> ft; + + if (argc != 2) + { + ft = auto_ptr<XMLFormatTarget> (new StdOutFormatTarget ()); + } + else + { + ft = auto_ptr<XMLFormatTarget> ( + new LocalFileFormatTarget (argv[1])); + } + + // Write it out. + // + name (*ft, *r, map); +} + +XMLPlatformUtils::Terminate (); + </pre> + + <p>Note that we had to initialize the Xerces-C++ runtime before we + could call this serialization function.</p> + + <h2><a name="4.7">4.7 Serializing to DOM</a></h2> + + <p>The mapping provides two overloaded functions that implement + serialization to a DOM instance. The first creates a DOM instance + for you and the second serializes to an existing DOM instance. + While serializing to a new DOM instance is similar to serializing + to <code>std::ostream</code> or <code>xercesc::XMLFormatTarget</code>, + serializing to an existing DOM instance requires quite a bit of work + from your side. You will need to set all the custom namespace mapping + attributes as well as the <code>schemaLocation</code> and/or + <code>noNamespaceSchemaLocation</code> attributes. The following + listing should give you an idea about what needs to be done: + </p> + + <pre class="c++"> +// Obtain the object model. +// +std::auto_ptr<type> r = ... + +using namespace xercesc; + +XMLPlatformUtils::Initialize (); + +{ + // Create a DOM instance. Set custom namespace mapping and schema + // location attributes. + // + DOMDocument& doc = ... + + // Serialize to DOM. + // + name (doc, *r); + + // Serialize the DOM document to XML. + // + ... +} + +XMLPlatformUtils::Terminate (); + </pre> + + <p>For more information on how to create and serialize a DOM instance + refer to the Xerces-C++ documentation. In addition, the + <a href="http://wiki.codesynthesis.com/Tree/FAQ">C++/Tree Mapping + FAQ</a> shows how to implement these operations using the XSD + runtime utilities. + </p> + + <h1><a name="5">5 Additional Functionality</a></h1> + + <p>The C++/Tree mapping provides a number of optional features + that can be useful in certain situations. They are described + in the following sections.</p> + + <h2><a name="5.1">5.1 DOM Association</a></h2> + + <p>Normally, after parsing is complete, the DOM document which + was used to extract the data is discarded. However, the parsing + functions can be instructed to preserve the DOM document + and create an association between the DOM nodes and object model + nodes. When there is an association between the DOM and + object model nodes, you can obtain the corresponding DOM element + or attribute node from an object model node as well as perform + the reverse transition: obtain the corresponding object model + from a DOM element or attribute node.</p> + + <p>Maintaining DOM association is normally useful when the application + needs access to XML constructs that are not preserved in the + object model, for example, XML comments. + Another useful aspect of DOM association is the ability of the + application to navigate the document tree using the generic DOM + interface (for example, with the help of an XPath processor) + and then move back to the statically-typed object model. Note + also that while you can change the underlying DOM document, + these changes are not reflected in the object model and will + be ignored during serialization. If you need to not only access + but also modify some aspects of XML that are not preserved in + the object model, then type customization with custom parsing + constructors and serialization operators should be used instead.</p> + + <p>To request DOM association you will need to pass the + <code>xml_schema::flags::keep_dom</code> flag to one of the + parsing functions (see <a href="#3.2">Section 3.2, + "Flags and Properties"</a> for more information). In this case the + DOM document is retained and will be released when the object model + is deleted. Note that since DOM nodes "out-live" the parsing function + call, you need to initialize the Xerces-C++ runtime before calling + one of the parsing functions with the <code>keep_dom</code> flag and + terminate it after the object model is destroyed (see + <a href="#3.1">Section 3.1, "Initializing the Xerces-C++ Runtime"</a>).</p> + + <p>If the <code>keep_dom</code> flag is passed + as the second argument to the copy constructor and the copy + being made is of a complete tree, then the DOM association + is also maintained in the copy by cloning the underlying + DOM document and reestablishing the associations. For example:</p> + + <pre class="c++"> +using namespace xercesc; + +XMLPlatformUtils::Initialize (); + +{ + // Parse XML to object model. + // + std::auto_ptr<type> r (root ( + "root.xml", + xml_schema::flags::keep_dom | + xml_schema::flags::dont_initialize)); + + // Copy without DOM association. + // + type copy1 (*r); + + // Copy with DOM association. + // + type copy2 (*r, xml_schema::flags::keep_dom); +} + +XMLPlatformUtils::Terminate (); + </pre> + + + <p>To obtain the corresponding DOM node from an object model node + you will need to call the <code>_node</code> accessor function + which returns a pointer to <code>DOMNode</code>. You can then query + this DOM node's type and cast it to either <code>DOMAttr*</code> + or <code>DOMElement*</code>. To obtain the corresponding object + model node from a DOM node, the DOM user data API is used. The + <code>xml_schema::dom::tree_node_key</code> variable contains + the key for object model nodes. The following schema and code + fragment show how to navigate from DOM to object model nodes + and in the opposite direction:</p> + + <pre class="xml"> +<complexType name="object"> + <sequence> + <element name="a" type="string"/> + </sequence> +</complexType> + +<element name="root" type="object"/> + </pre> + + <pre class="c++"> +using namespace xercesc; + +XMLPlatformUtils::Initialize (); + +{ + // Parse XML to object model. + // + std::auto_ptr<type> r (root ( + "root.xml", + xml_schema::flags::keep_dom | + xml_schema::flags::dont_initialize)); + + DOMNode* n = root->_node (); + assert (n->getNodeType () == DOMNode::ELEMENT_NODE); + DOMElement* re = static_cast<DOMElement*> (n); + + // Get the 'a' element. Note that it is not necessarily the + // first child node of 'root' since there could be whitespace + // nodes before it. + // + DOMElement* ae; + + for (n = re->getFirstChild (); n != 0; n = n->getNextSibling ()) + { + if (n->getNodeType () == DOMNode::ELEMENT_NODE) + { + ae = static_cast<DOMElement*> (n); + break; + } + } + + // Get from the 'a' DOM element to xml_schema::string object model + // node. + // + xml_schema::type& t ( + *reinterpret_cast<xml_schema::type*> ( + ae->getUserData (xml_schema::dom::tree_node_key))); + + xml_schema::string& a (dynamic_cast<xml_schema::string&> (t)); +} + +XMLPlatformUtils::Terminate (); + </pre> + + <p>The 'mixed' example which can be found in the XSD distribution + shows how to handle the mixed content using DOM association.</p> + + <h2><a name="5.2">5.2 Binary Serialization</a></h2> + + <p>Besides reading from and writing to XML, the C++/Tree mapping + also allows you to save the object model to and load it from a + number of predefined as well as custom data representation + formats. The predefined binary formats are CDR (Common Data + Representation) and XDR (eXternal Data Representation). A + custom format can easily be supported by providing + insertion and extraction operators for basic types.</p> + + <p>Binary serialization saves only the data without any meta + information or markup. As a result, saving to and loading + from a binary representation can be an order of magnitude + faster than parsing and serializing the same data in XML. + Furthermore, the resulting representation is normally several + times smaller than the equivalent XML representation. These + properties make binary serialization ideal for internal data + exchange and storage. A typical application that uses this + facility stores the data and communicates within the + system using a binary format and reads/writes the data + in XML when communicating with the outside world.</p> + + <p>In order to request the generation of insertion operators and + extraction constructors for a specific predefined or custom + data representation stream, you will need to use the + <code>--generate-insertion</code> and <code>--generate-extraction</code> + compiler options. See the + <a href="http://www.codesynthesis.com/projects/xsd/documentation/xsd.xhtml">XSD + Compiler Command Line Manual</a> for more information.</p> + + <p>Once the insertion operators and extraction constructors are + generated, you can use the <code>xml_schema::istream</code> + and <code>xml_schema::ostream</code> wrapper stream templates + to save the object model to and load it from a specific format. + The following code fragment shows how to do this using ACE + (Adaptive Communication Environment) CDR streams as an example:</p> + + <pre class="xml"> +<complexType name="object"> + <sequence> + <element name="a" type="string"/> + <element name="b" type="int"/> + </sequence> +</complexType> + +<element name="root" type="object"/> + </pre> + + <pre class="c++"> +// Parse XML to object model. +// +std::auto_ptr<type> r (root ("root.xml")); + +// Save to a CDR stream. +// +ACE_OutputCDR ace_ocdr; +xml_schema::ostream<ACE_OutputCDR> ocdr (ace_ocdr); + +ocdr << *r; + +// Load from a CDR stream. +// +ACE_InputCDR ace_icdr (buf, size); +xml_schema::istream<ACE_InputCDR> icdr (ace_icdr); + +std::auto_ptr<object> copy (new object (icdr)); + +// Serialize to XML. +// +root (std::cout, *copy); + </pre> + + <p>The XSD distribution contains a number of examples that + show how to save the object model to and load it from + CDR, XDR, and a custom format.</p> + + <!-- Appendix A --> + + + <h1><a name="A">Appendix A — Default and Fixed Values</a></h1> + + <p>The following table summarizes the effect of default and fixed + values (specified with the <code>default</code> and <code>fixed</code> + attributes, respectively) on attribute and element values. The + <code>default</code> and <code>fixed</code> attributes are mutually + exclusive. It is also worthwhile to note that the fixed value semantics + is a superset of the default value semantics. + </p> + + <!-- border="1" is necessary for html2ps --> + <table id="default-fixed" border="1"> + <tr> + <th></th> + <th></th> + <th colspan="2">default</th> + <th colspan="2">fixed</th> + </tr> + + <!-- element --> + + <tr> + <th rowspan="4">element</th> + <th rowspan="2">not present</th> + <th>optional</th> + <th>required</th> + <th>optional</th> + <th>required</th> + </tr> + <tr> + <td>not present</td> + <td>invalid instance</td> + <td>not present</td> + <td>invalid instance</td> + </tr> + + + <tr> + <th>empty</th> + <td colspan="2">default value is used</td> + <td colspan="2">fixed value is used</td> + </tr> + + <tr> + <th>value</th> + <td colspan="2">value is used</td> + <td colspan="2">value is used provided it's the same as fixed</td> + </tr> + + <!-- attribute --> + + <!-- element --> + + <tr> + <th rowspan="4">attribute</th> + <th rowspan="2">not present</th> + <th>optional</th> + <th>required</th> + <th>optional</th> + <th>required</th> + </tr> + <tr> + <td>default value is used</td> + <td>invalid schema</td> + <td>fixed value is used</td> + <td>invalid instance</td> + </tr> + + + <tr> + <th>empty</th> + <td colspan="2">empty value is used</td> + <td colspan="2">empty value is used provided it's the same as fixed</td> + </tr> + + <tr> + <th>value</th> + <td colspan="2">value is used</td> + <td colspan="2">value is used provided it's the same as fixed</td> + </tr> + + </table> + + </div> +</div> + + +</body> +</html> diff --git a/xsd/doc/cxx/tree/manual/makefile b/xsd/doc/cxx/tree/manual/makefile new file mode 100644 index 0000000..3cb0d80 --- /dev/null +++ b/xsd/doc/cxx/tree/manual/makefile @@ -0,0 +1,54 @@ +# file : doc/cxx/tree/manual/makefile +# copyright : Copyright (c) 2006-2014 Code Synthesis Tools CC +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +include $(dir $(lastword $(MAKEFILE_LIST)))../../../../build/bootstrap.make + +default := $(out_base)/ +install := $(out_base)/.install +dist := $(out_base)/.dist +dist-win := $(out_base)/.dist-win +clean := $(out_base)/.clean + +# Build. +# +$(default): $(out_base)/cxx-tree-manual.ps $(out_base)/cxx-tree-manual.pdf + + +$(out_base)/cxx-tree-manual.ps: $(src_base)/index.xhtml \ + $(src_base)/manual.html2ps \ + | $(out_base)/. + $(call message,html2ps $<,html2ps -f $(src_base)/manual.html2ps -o $@ $<) + +$(out_base)/cxx-tree-manual.pdf: $(out_base)/cxx-tree-manual.ps | $(out_base)/. + $(call message,ps2pdf $<,ps2pdf14 $< $@) + +# Install & Dist. +# +$(install): path := $(subst $(src_root)/doc/,,$(src_base)) +$(dist): path := $(subst $(src_root)/,,$(src_base)) + +$(install): $(out_base)/cxx-tree-manual.ps $(out_base)/cxx-tree-manual.pdf + $(call install-data,$(src_base)/index.xhtml,$(install_doc_dir)/xsd/$(path)/index.xhtml) + $(call install-data,$(out_base)/cxx-tree-manual.ps,$(install_doc_dir)/xsd/$(path)/cxx-tree-manual.ps) + $(call install-data,$(out_base)/cxx-tree-manual.pdf,$(install_doc_dir)/xsd/$(path)/cxx-tree-manual.pdf) + +$(dist): $(out_base)/cxx-tree-manual.ps $(out_base)/cxx-tree-manual.pdf + $(call install-data,$(src_base)/index.xhtml,$(dist_prefix)/$(path)/index.xhtml) + $(call install-data,$(out_base)/cxx-tree-manual.ps,$(dist_prefix)/$(path)/cxx-tree-manual.ps) + $(call install-data,$(out_base)/cxx-tree-manual.pdf,$(dist_prefix)/$(path)/cxx-tree-manual.pdf) + +$(dist-win): $(dist) + + +# Clean +# +$(clean): +ifneq ($(xsd_clean_gen),n) + $(call message,rm $$1,rm -f $$1,$(out_base)/cxx-tree-manual.ps) + $(call message,rm $$1,rm -f $$1,$(out_base)/cxx-tree-manual.pdf) +endif + +# How to. +# +$(call include,$(bld_root)/install.make) diff --git a/xsd/doc/cxx/tree/manual/manual.html2ps b/xsd/doc/cxx/tree/manual/manual.html2ps new file mode 100644 index 0000000..6e714a6 --- /dev/null +++ b/xsd/doc/cxx/tree/manual/manual.html2ps @@ -0,0 +1,66 @@ +@html2ps { + option { + toc: hb; + colour: 1; + hyphenate: 1; + titlepage: 1; + } + + datefmt: "%B %Y"; + + titlepage { + content: " +<div align=center> + <h1><big>C++/Tree Mapping User Manual</big></h1> + <h1> </h1> + <h1> </h1> + <h1> </h1> + <h1> </h1> + <h1> </h1> + <h1> </h1> + <h1> </h1> +</div> + <p>Revision $[revision] $D</p> + <p>Copyright © 2005-2014 CODE SYNTHESIS TOOLS CC</p> + + <p>Permission is granted to copy, distribute and/or modify this + document under the terms of the + <a href='http://www.codesynthesis.com/licenses/fdl-1.2.txt'>GNU Free + Documentation License, version 1.2</a>; with no Invariant Sections, + no Front-Cover Texts and no Back-Cover Texts. + </p> + + <p>This document is available in the following formats: + <a href='http://www.codesynthesis.com/projects/xsd/documentation/cxx/tree/manual/index.xhtml'>XHTML</a>, + <a href='http://www.codesynthesis.com/projects/xsd/documentation/cxx/tree/manual/cxx-tree-manual.pdf'>PDF</a>, and + <a href='http://www.codesynthesis.com/projects/xsd/documentation/cxx/tree/manual/cxx-tree-manual.ps'>PostScript</a>.</p>"; + } + + toc { + indent: 2em; + } + + header { + odd-right: $H; + even-left: $H; + } + + footer { + odd-left: $D; + odd-center: $T, v$[revision]; + odd-right: $N; + + even-left: $N; + even-center: $T, v$[revision]; + even-right: $D; + } +} + +body { + font-size: 12pt; + text-align: justify; +} + +pre { + font-size: 10pt; +} diff --git a/xsd/doc/cxx/tree/reference/footer.html b/xsd/doc/cxx/tree/reference/footer.html new file mode 100644 index 0000000..4325116 --- /dev/null +++ b/xsd/doc/cxx/tree/reference/footer.html @@ -0,0 +1,6 @@ +<hr size="1"> +<div style="text-align: center; font-size: 80%;"> + Copyright © 2005-2014 CODE SYNTHESIS TOOLS CC +</div> +</body> +</html> diff --git a/xsd/doc/cxx/tree/reference/libxsd.doxygen b/xsd/doc/cxx/tree/reference/libxsd.doxygen new file mode 100644 index 0000000..376d34a --- /dev/null +++ b/xsd/doc/cxx/tree/reference/libxsd.doxygen @@ -0,0 +1,1322 @@ +# Doxyfile 1.5.4 + +# This file describes the settings to be used by the documentation system +# doxygen (www.doxygen.org) for a project +# +# All text after a hash (#) is considered a comment and will be ignored +# The format is: +# TAG = value [value, ...] +# For lists items can also be appended using: +# TAG += value [value, ...] +# Values that contain spaces should be placed between quotes (" ") + +#--------------------------------------------------------------------------- +# Project related configuration options +#--------------------------------------------------------------------------- + +# This tag specifies the encoding used for all characters in the config file that +# follow. The default is UTF-8 which is also the encoding used for all text before +# the first occurrence of this tag. Doxygen uses libiconv (or the iconv built into +# libc) for the transcoding. See http://www.gnu.org/software/libiconv for the list of +# possible encodings. + +DOXYFILE_ENCODING = UTF-8 + +# The PROJECT_NAME tag is a single word (or a sequence of words surrounded +# by quotes) that should identify the project. + +PROJECT_NAME = "C++/Tree Mapping Runtime Library" + +# The PROJECT_NUMBER tag can be used to enter a project or revision number. +# This could be handy for archiving the generated documentation or +# if some version control system is used. + +PROJECT_NUMBER = + +# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) +# base path where the generated documentation will be put. +# If a relative path is entered, it will be relative to the location +# where doxygen was started. If left blank the current directory will be used. + +OUTPUT_DIRECTORY = + +# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create +# 4096 sub-directories (in 2 levels) under the output directory of each output +# format and will distribute the generated files over these directories. +# Enabling this option can be useful when feeding doxygen a huge amount of +# source files, where putting all generated files in the same directory would +# otherwise cause performance problems for the file system. + +CREATE_SUBDIRS = NO + +# The OUTPUT_LANGUAGE tag is used to specify the language in which all +# documentation generated by doxygen is written. Doxygen will use this +# information to generate all constant output in the proper language. +# The default language is English, other supported languages are: +# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, +# Croatian, Czech, Danish, Dutch, Finnish, French, German, Greek, Hungarian, +# Italian, Japanese, Japanese-en (Japanese with English messages), Korean, +# Korean-en, Lithuanian, Norwegian, Polish, Portuguese, Romanian, Russian, +# Serbian, Slovak, Slovene, Spanish, Swedish, and Ukrainian. + +OUTPUT_LANGUAGE = English + +# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will +# include brief member descriptions after the members that are listed in +# the file and class documentation (similar to JavaDoc). +# Set to NO to disable this. + +BRIEF_MEMBER_DESC = YES + +# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend +# the brief description of a member or function before the detailed description. +# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the +# brief descriptions will be completely suppressed. + +REPEAT_BRIEF = YES + +# This tag implements a quasi-intelligent brief description abbreviator +# that is used to form the text in various listings. Each string +# in this list, if found as the leading text of the brief description, will be +# stripped from the text and the result after processing the whole list, is +# used as the annotated text. Otherwise, the brief description is used as-is. +# If left blank, the following values are used ("$name" is automatically +# replaced with the name of the entity): "The $name class" "The $name widget" +# "The $name file" "is" "provides" "specifies" "contains" +# "represents" "a" "an" "the" + +ABBREVIATE_BRIEF = + +# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then +# Doxygen will generate a detailed section even if there is only a brief +# description. + +ALWAYS_DETAILED_SEC = NO + +# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all +# inherited members of a class in the documentation of that class as if those +# members were ordinary class members. Constructors, destructors and assignment +# operators of the base classes will not be shown. + +INLINE_INHERITED_MEMB = NO + +# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full +# path before files name in the file list and in the header files. If set +# to NO the shortest path that makes the file name unique will be used. + +FULL_PATH_NAMES = NO + +# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag +# can be used to strip a user-defined part of the path. Stripping is +# only done if one of the specified strings matches the left-hand part of +# the path. The tag can be used to show relative paths in the file list. +# If left blank the directory from which doxygen is run is used as the +# path to strip. + +STRIP_FROM_PATH = + +# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of +# the path mentioned in the documentation of a class, which tells +# the reader which header file to include in order to use a class. +# If left blank only the name of the header file containing the class +# definition is used. Otherwise one should specify the include paths that +# are normally passed to the compiler using the -I flag. + +STRIP_FROM_INC_PATH = + +# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter +# (but less readable) file names. This can be useful is your file systems +# doesn't support long names like on DOS, Mac, or CD-ROM. + +SHORT_NAMES = NO + +# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen +# will interpret the first line (until the first dot) of a JavaDoc-style +# comment as the brief description. If set to NO, the JavaDoc +# comments will behave just like regular Qt-style comments +# (thus requiring an explicit @brief command for a brief description.) + +JAVADOC_AUTOBRIEF = NO + +# If the QT_AUTOBRIEF tag is set to YES then Doxygen will +# interpret the first line (until the first dot) of a Qt-style +# comment as the brief description. If set to NO, the comments +# will behave just like regular Qt-style comments (thus requiring +# an explicit \brief command for a brief description.) + +QT_AUTOBRIEF = NO + +# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen +# treat a multi-line C++ special comment block (i.e. a block of //! or /// +# comments) as a brief description. This used to be the default behaviour. +# The new default is to treat a multi-line C++ comment block as a detailed +# description. Set this tag to YES if you prefer the old behaviour instead. + +MULTILINE_CPP_IS_BRIEF = NO + +# If the DETAILS_AT_TOP tag is set to YES then Doxygen +# will output the detailed description near the top, like JavaDoc. +# If set to NO, the detailed description appears after the member +# documentation. + +DETAILS_AT_TOP = NO + +# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented +# member inherits the documentation from any documented member that it +# re-implements. + +INHERIT_DOCS = YES + +# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce +# a new page for each member. If set to NO, the documentation of a member will +# be part of the file/class/namespace that contains it. + +SEPARATE_MEMBER_PAGES = NO + +# The TAB_SIZE tag can be used to set the number of spaces in a tab. +# Doxygen uses this value to replace tabs by spaces in code fragments. + +TAB_SIZE = 8 + +# This tag can be used to specify a number of aliases that acts +# as commands in the documentation. An alias has the form "name=value". +# For example adding "sideeffect=\par Side Effects:\n" will allow you to +# put the command \sideeffect (or @sideeffect) in the documentation, which +# will result in a user-defined paragraph with heading "Side Effects:". +# You can put \n's in the value part of an alias to insert newlines. + +ALIASES = + +# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C +# sources only. Doxygen will then generate output that is more tailored for C. +# For instance, some of the names that are used will be different. The list +# of all members will be omitted, etc. + +OPTIMIZE_OUTPUT_FOR_C = NO + +# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java +# sources only. Doxygen will then generate output that is more tailored for Java. +# For instance, namespaces will be presented as packages, qualified scopes +# will look different, etc. + +OPTIMIZE_OUTPUT_JAVA = NO + +# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want to +# include (a tag file for) the STL sources as input, then you should +# set this tag to YES in order to let doxygen match functions declarations and +# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. +# func(std::string) {}). This also make the inheritance and collaboration +# diagrams that involve STL classes more complete and accurate. + +BUILTIN_STL_SUPPORT = YES + +# If you use Microsoft's C++/CLI language, you should set this option to YES to +# enable parsing support. + +CPP_CLI_SUPPORT = NO + +# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. +# Doxygen will parse them like normal C++ but will assume all classes use public +# instead of private inheritance when no explicit protection keyword is present. + +SIP_SUPPORT = NO + +# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC +# tag is set to YES, then doxygen will reuse the documentation of the first +# member in the group (if any) for the other members of the group. By default +# all members of a group must be documented explicitly. + +DISTRIBUTE_GROUP_DOC = NO + +# Set the SUBGROUPING tag to YES (the default) to allow class member groups of +# the same type (for instance a group of public functions) to be put as a +# subgroup of that type (e.g. under the Public Functions section). Set it to +# NO to prevent subgrouping. Alternatively, this can be done per class using +# the \nosubgrouping command. + +SUBGROUPING = YES + +# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct (or union) is +# documented as struct with the name of the typedef. So +# typedef struct TypeS {} TypeT, will appear in the documentation as a struct +# with name TypeT. When disabled the typedef will appear as a member of a file, +# namespace, or class. And the struct will be named TypeS. This can typically +# be useful for C code where the coding convention is that all structs are +# typedef'ed and only the typedef is referenced never the struct's name. + +TYPEDEF_HIDES_STRUCT = NO + +#--------------------------------------------------------------------------- +# Build related configuration options +#--------------------------------------------------------------------------- + +# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in +# documentation are documented, even if no documentation was available. +# Private class members and static file members will be hidden unless +# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES + +EXTRACT_ALL = NO + +# If the EXTRACT_PRIVATE tag is set to YES all private members of a class +# will be included in the documentation. + +EXTRACT_PRIVATE = NO + +# If the EXTRACT_STATIC tag is set to YES all static members of a file +# will be included in the documentation. + +EXTRACT_STATIC = NO + +# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) +# defined locally in source files will be included in the documentation. +# If set to NO only classes defined in header files are included. + +EXTRACT_LOCAL_CLASSES = YES + +# This flag is only useful for Objective-C code. When set to YES local +# methods, which are defined in the implementation section but not in +# the interface are included in the documentation. +# If set to NO (the default) only methods in the interface are included. + +EXTRACT_LOCAL_METHODS = NO + +# If this flag is set to YES, the members of anonymous namespaces will be extracted +# and appear in the documentation as a namespace called 'anonymous_namespace{file}', +# where file will be replaced with the base name of the file that contains the anonymous +# namespace. By default anonymous namespace are hidden. + +EXTRACT_ANON_NSPACES = NO + +# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all +# undocumented members of documented classes, files or namespaces. +# If set to NO (the default) these members will be included in the +# various overviews, but no documentation section is generated. +# This option has no effect if EXTRACT_ALL is enabled. + +HIDE_UNDOC_MEMBERS = NO + +# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all +# undocumented classes that are normally visible in the class hierarchy. +# If set to NO (the default) these classes will be included in the various +# overviews. This option has no effect if EXTRACT_ALL is enabled. + +HIDE_UNDOC_CLASSES = NO + +# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all +# friend (class|struct|union) declarations. +# If set to NO (the default) these declarations will be included in the +# documentation. + +HIDE_FRIEND_COMPOUNDS = NO + +# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any +# documentation blocks found inside the body of a function. +# If set to NO (the default) these blocks will be appended to the +# function's detailed documentation block. + +HIDE_IN_BODY_DOCS = NO + +# The INTERNAL_DOCS tag determines if documentation +# that is typed after a \internal command is included. If the tag is set +# to NO (the default) then the documentation will be excluded. +# Set it to YES to include the internal documentation. + +INTERNAL_DOCS = NO + +# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate +# file names in lower-case letters. If set to YES upper-case letters are also +# allowed. This is useful if you have classes or files whose names only differ +# in case and if your file system supports case sensitive file names. Windows +# and Mac users are advised to set this option to NO. + +CASE_SENSE_NAMES = YES + +# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen +# will show members with their full class and namespace scopes in the +# documentation. If set to YES the scope will be hidden. + +HIDE_SCOPE_NAMES = YES + +# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen +# will put a list of the files that are included by a file in the documentation +# of that file. + +SHOW_INCLUDE_FILES = NO + +# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] +# is inserted in the documentation for inline members. + +INLINE_INFO = YES + +# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen +# will sort the (detailed) documentation of file and class members +# alphabetically by member name. If set to NO the members will appear in +# declaration order. + +SORT_MEMBER_DOCS = NO + +# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the +# brief documentation of file, namespace and class members alphabetically +# by member name. If set to NO (the default) the members will appear in +# declaration order. + +SORT_BRIEF_DOCS = NO + +# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be +# sorted by fully-qualified names, including namespaces. If set to +# NO (the default), the class list will be sorted only by class name, +# not including the namespace part. +# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. +# Note: This option applies only to the class list, not to the +# alphabetical list. + +SORT_BY_SCOPE_NAME = NO + +# The GENERATE_TODOLIST tag can be used to enable (YES) or +# disable (NO) the todo list. This list is created by putting \todo +# commands in the documentation. + +GENERATE_TODOLIST = YES + +# The GENERATE_TESTLIST tag can be used to enable (YES) or +# disable (NO) the test list. This list is created by putting \test +# commands in the documentation. + +GENERATE_TESTLIST = YES + +# The GENERATE_BUGLIST tag can be used to enable (YES) or +# disable (NO) the bug list. This list is created by putting \bug +# commands in the documentation. + +GENERATE_BUGLIST = YES + +# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or +# disable (NO) the deprecated list. This list is created by putting +# \deprecated commands in the documentation. + +GENERATE_DEPRECATEDLIST= YES + +# The ENABLED_SECTIONS tag can be used to enable conditional +# documentation sections, marked by \if sectionname ... \endif. + +ENABLED_SECTIONS = + +# The MAX_INITIALIZER_LINES tag determines the maximum number of lines +# the initial value of a variable or define consists of for it to appear in +# the documentation. If the initializer consists of more lines than specified +# here it will be hidden. Use a value of 0 to hide initializers completely. +# The appearance of the initializer of individual variables and defines in the +# documentation can be controlled using \showinitializer or \hideinitializer +# command in the documentation regardless of this setting. + +MAX_INITIALIZER_LINES = 30 + +# Set the SHOW_USED_FILES tag to NO to disable the list of files generated +# at the bottom of the documentation of classes and structs. If set to YES the +# list will mention the files that were used to generate the documentation. + +SHOW_USED_FILES = YES + +# If the sources in your project are distributed over multiple directories +# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy +# in the documentation. The default is NO. + +SHOW_DIRECTORIES = NO + +# The FILE_VERSION_FILTER tag can be used to specify a program or script that +# doxygen should invoke to get the current version for each file (typically from the +# version control system). Doxygen will invoke the program by executing (via +# popen()) the command <command> <input-file>, where <command> is the value of +# the FILE_VERSION_FILTER tag, and <input-file> is the name of an input file +# provided by doxygen. Whatever the program writes to standard output +# is used as the file version. See the manual for examples. + +FILE_VERSION_FILTER = + +#--------------------------------------------------------------------------- +# configuration options related to warning and progress messages +#--------------------------------------------------------------------------- + +# The QUIET tag can be used to turn on/off the messages that are generated +# by doxygen. Possible values are YES and NO. If left blank NO is used. + +QUIET = NO + +# The WARNINGS tag can be used to turn on/off the warning messages that are +# generated by doxygen. Possible values are YES and NO. If left blank +# NO is used. + +WARNINGS = YES + +# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings +# for undocumented members. If EXTRACT_ALL is set to YES then this flag will +# automatically be disabled. + +WARN_IF_UNDOCUMENTED = YES + +# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for +# potential errors in the documentation, such as not documenting some +# parameters in a documented function, or documenting parameters that +# don't exist or using markup commands wrongly. + +WARN_IF_DOC_ERROR = YES + +# This WARN_NO_PARAMDOC option can be abled to get warnings for +# functions that are documented, but have no documentation for their parameters +# or return value. If set to NO (the default) doxygen will only warn about +# wrong or incomplete parameter documentation, but not about the absence of +# documentation. + +WARN_NO_PARAMDOC = NO + +# The WARN_FORMAT tag determines the format of the warning messages that +# doxygen can produce. The string should contain the $file, $line, and $text +# tags, which will be replaced by the file and line number from which the +# warning originated and the warning text. Optionally the format may contain +# $version, which will be replaced by the version of the file (if it could +# be obtained via FILE_VERSION_FILTER) + +WARN_FORMAT = "$file:$line: $text" + +# The WARN_LOGFILE tag can be used to specify a file to which warning +# and error messages should be written. If left blank the output is written +# to stderr. + +WARN_LOGFILE = + +#--------------------------------------------------------------------------- +# configuration options related to the input files +#--------------------------------------------------------------------------- + +# The INPUT tag can be used to specify the files and/or directories that contain +# documented source files. You may enter file names like "myfile.cpp" or +# directories like "/usr/src/myproject". Separate the files or directories +# with spaces. + +INPUT = \ +../../../../libxsd/xsd/cxx/tree/buffer.hxx \ +../../../../libxsd/xsd/cxx/tree/types.hxx \ +../../../../libxsd/xsd/cxx/tree/date-time.hxx \ +../../../../libxsd/xsd/cxx/tree/elements.hxx \ +../../../../libxsd/xsd/cxx/tree/element-map.hxx \ +../../../../libxsd/xsd/cxx/tree/exceptions.hxx + +# This tag can be used to specify the character encoding of the source files that +# doxygen parses. Internally doxygen uses the UTF-8 encoding, which is also the default +# input encoding. Doxygen uses libiconv (or the iconv built into libc) for the transcoding. +# See http://www.gnu.org/software/libiconv for the list of possible encodings. + +INPUT_ENCODING = UTF-8 + +# If the value of the INPUT tag contains directories, you can use the +# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank the following patterns are tested: +# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx +# *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py *.f90 + +FILE_PATTERNS = + +# The RECURSIVE tag can be used to turn specify whether or not subdirectories +# should be searched for input files as well. Possible values are YES and NO. +# If left blank NO is used. + +RECURSIVE = NO + +# The EXCLUDE tag can be used to specify files and/or directories that should +# excluded from the INPUT source files. This way you can easily exclude a +# subdirectory from a directory tree whose root is specified with the INPUT tag. + +EXCLUDE = + +# The EXCLUDE_SYMLINKS tag can be used select whether or not files or +# directories that are symbolic links (a Unix filesystem feature) are excluded +# from the input. + +EXCLUDE_SYMLINKS = NO + +# If the value of the INPUT tag contains directories, you can use the +# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude +# certain files from those directories. Note that the wildcards are matched +# against the file with absolute path, so to exclude all test directories +# for example use the pattern */test/* + +EXCLUDE_PATTERNS = + +# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names +# (namespaces, classes, functions, etc.) that should be excluded from the output. +# The symbol name can be a fully qualified name, a word, or if the wildcard * is used, +# a substring. Examples: ANamespace, AClass, AClass::ANamespace, ANamespace::*Test + +EXCLUDE_SYMBOLS = + +# The EXAMPLE_PATH tag can be used to specify one or more files or +# directories that contain example code fragments that are included (see +# the \include command). + +EXAMPLE_PATH = + +# If the value of the EXAMPLE_PATH tag contains directories, you can use the +# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank all files are included. + +EXAMPLE_PATTERNS = + +# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be +# searched for input files to be used with the \include or \dontinclude +# commands irrespective of the value of the RECURSIVE tag. +# Possible values are YES and NO. If left blank NO is used. + +EXAMPLE_RECURSIVE = NO + +# The IMAGE_PATH tag can be used to specify one or more files or +# directories that contain image that are included in the documentation (see +# the \image command). + +IMAGE_PATH = + +# The INPUT_FILTER tag can be used to specify a program that doxygen should +# invoke to filter for each input file. Doxygen will invoke the filter program +# by executing (via popen()) the command <filter> <input-file>, where <filter> +# is the value of the INPUT_FILTER tag, and <input-file> is the name of an +# input file. Doxygen will then use the output that the filter program writes +# to standard output. If FILTER_PATTERNS is specified, this tag will be +# ignored. + +INPUT_FILTER = + +# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern +# basis. Doxygen will compare the file name with each pattern and apply the +# filter if there is a match. The filters are a list of the form: +# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further +# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER +# is applied to all files. + +FILTER_PATTERNS = + +# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using +# INPUT_FILTER) will be used to filter the input files when producing source +# files to browse (i.e. when SOURCE_BROWSER is set to YES). + +FILTER_SOURCE_FILES = NO + +#--------------------------------------------------------------------------- +# configuration options related to source browsing +#--------------------------------------------------------------------------- + +# If the SOURCE_BROWSER tag is set to YES then a list of source files will +# be generated. Documented entities will be cross-referenced with these sources. +# Note: To get rid of all source code in the generated output, make sure also +# VERBATIM_HEADERS is set to NO. If you have enabled CALL_GRAPH or CALLER_GRAPH +# then you must also enable this option. If you don't then doxygen will produce +# a warning and turn it on anyway + +SOURCE_BROWSER = NO + +# Setting the INLINE_SOURCES tag to YES will include the body +# of functions and classes directly in the documentation. + +INLINE_SOURCES = NO + +# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct +# doxygen to hide any special comment blocks from generated source code +# fragments. Normal C and C++ comments will always remain visible. + +STRIP_CODE_COMMENTS = YES + +# If the REFERENCED_BY_RELATION tag is set to YES (the default) +# then for each documented function all documented +# functions referencing it will be listed. + +REFERENCED_BY_RELATION = YES + +# If the REFERENCES_RELATION tag is set to YES (the default) +# then for each documented function all documented entities +# called/used by that function will be listed. + +REFERENCES_RELATION = YES + +# If the REFERENCES_LINK_SOURCE tag is set to YES (the default) +# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from +# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will +# link to the source code. Otherwise they will link to the documentstion. + +REFERENCES_LINK_SOURCE = YES + +# If the USE_HTAGS tag is set to YES then the references to source code +# will point to the HTML generated by the htags(1) tool instead of doxygen +# built-in source browser. The htags tool is part of GNU's global source +# tagging system (see http://www.gnu.org/software/global/global.html). You +# will need version 4.8.6 or higher. + +USE_HTAGS = NO + +# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen +# will generate a verbatim copy of the header file for each class for +# which an include is specified. Set to NO to disable this. + +VERBATIM_HEADERS = YES + +#--------------------------------------------------------------------------- +# configuration options related to the alphabetical class index +#--------------------------------------------------------------------------- + +# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index +# of all compounds will be generated. Enable this if the project +# contains a lot of classes, structs, unions or interfaces. + +ALPHABETICAL_INDEX = NO + +# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then +# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns +# in which this list will be split (can be a number in the range [1..20]) + +COLS_IN_ALPHA_INDEX = 5 + +# In case all classes in a project start with a common prefix, all +# classes will be put under the same header in the alphabetical index. +# The IGNORE_PREFIX tag can be used to specify one or more prefixes that +# should be ignored while generating the index headers. + +IGNORE_PREFIX = + +#--------------------------------------------------------------------------- +# configuration options related to the HTML output +#--------------------------------------------------------------------------- + +# If the GENERATE_HTML tag is set to YES (the default) Doxygen will +# generate HTML output. + +GENERATE_HTML = YES + +# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `html' will be used as the default path. + +HTML_OUTPUT = html + +# The HTML_FILE_EXTENSION tag can be used to specify the file extension for +# each generated HTML page (for example: .htm,.php,.asp). If it is left blank +# doxygen will generate files with .html extension. + +HTML_FILE_EXTENSION = .html + +# The HTML_HEADER tag can be used to specify a personal HTML header for +# each generated HTML page. If it is left blank doxygen will generate a +# standard header. + +HTML_HEADER = + +# The HTML_FOOTER tag can be used to specify a personal HTML footer for +# each generated HTML page. If it is left blank doxygen will generate a +# standard footer. + +HTML_FOOTER = footer.html + +# The HTML_STYLESHEET tag can be used to specify a user-defined cascading +# style sheet that is used by each HTML page. It can be used to +# fine-tune the look of the HTML output. If the tag is left blank doxygen +# will generate a default style sheet. Note that doxygen will try to copy +# the style sheet file to the HTML output directory, so don't put your own +# stylesheet in the HTML output directory as well, or it will be erased! + +HTML_STYLESHEET = + +# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, +# files or namespaces will be aligned in HTML using tables. If set to +# NO a bullet list will be used. + +HTML_ALIGN_MEMBERS = YES + +# If the GENERATE_HTMLHELP tag is set to YES, additional index files +# will be generated that can be used as input for tools like the +# Microsoft HTML help workshop to generate a compressed HTML help file (.chm) +# of the generated HTML documentation. + +GENERATE_HTMLHELP = NO + +# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML +# documentation will contain sections that can be hidden and shown after the +# page has loaded. For this to work a browser that supports +# JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox +# Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari). + +HTML_DYNAMIC_SECTIONS = NO + +# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can +# be used to specify the file name of the resulting .chm file. You +# can add a path in front of the file if the result should not be +# written to the html output directory. + +CHM_FILE = + +# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can +# be used to specify the location (absolute path including file name) of +# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run +# the HTML help compiler on the generated index.hhp. + +HHC_LOCATION = + +# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag +# controls if a separate .chi index file is generated (YES) or that +# it should be included in the master .chm file (NO). + +GENERATE_CHI = NO + +# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag +# controls whether a binary table of contents is generated (YES) or a +# normal table of contents (NO) in the .chm file. + +BINARY_TOC = NO + +# The TOC_EXPAND flag can be set to YES to add extra items for group members +# to the contents of the HTML help documentation and to the tree view. + +TOC_EXPAND = NO + +# The DISABLE_INDEX tag can be used to turn on/off the condensed index at +# top of each HTML page. The value NO (the default) enables the index and +# the value YES disables it. + +DISABLE_INDEX = NO + +# This tag can be used to set the number of enum values (range [1..20]) +# that doxygen will group on one line in the generated HTML documentation. + +ENUM_VALUES_PER_LINE = 4 + +# If the GENERATE_TREEVIEW tag is set to YES, a side panel will be +# generated containing a tree-like index structure (just like the one that +# is generated for HTML Help). For this to work a browser that supports +# JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+, +# Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are +# probably better off using the HTML help feature. + +GENERATE_TREEVIEW = NO + +# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be +# used to set the initial width (in pixels) of the frame in which the tree +# is shown. + +TREEVIEW_WIDTH = 250 + +#--------------------------------------------------------------------------- +# configuration options related to the LaTeX output +#--------------------------------------------------------------------------- + +# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will +# generate Latex output. + +GENERATE_LATEX = NO + +# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `latex' will be used as the default path. + +LATEX_OUTPUT = latex + +# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be +# invoked. If left blank `latex' will be used as the default command name. + +LATEX_CMD_NAME = latex + +# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to +# generate index for LaTeX. If left blank `makeindex' will be used as the +# default command name. + +MAKEINDEX_CMD_NAME = makeindex + +# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact +# LaTeX documents. This may be useful for small projects and may help to +# save some trees in general. + +COMPACT_LATEX = NO + +# The PAPER_TYPE tag can be used to set the paper type that is used +# by the printer. Possible values are: a4, a4wide, letter, legal and +# executive. If left blank a4wide will be used. + +PAPER_TYPE = a4wide + +# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX +# packages that should be included in the LaTeX output. + +EXTRA_PACKAGES = + +# The LATEX_HEADER tag can be used to specify a personal LaTeX header for +# the generated latex document. The header should contain everything until +# the first chapter. If it is left blank doxygen will generate a +# standard header. Notice: only use this tag if you know what you are doing! + +LATEX_HEADER = + +# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated +# is prepared for conversion to pdf (using ps2pdf). The pdf file will +# contain links (just like the HTML output) instead of page references +# This makes the output suitable for online browsing using a pdf viewer. + +PDF_HYPERLINKS = NO + +# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of +# plain latex in the generated Makefile. Set this option to YES to get a +# higher quality PDF documentation. + +USE_PDFLATEX = NO + +# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. +# command to the generated LaTeX files. This will instruct LaTeX to keep +# running if errors occur, instead of asking the user for help. +# This option is also used when generating formulas in HTML. + +LATEX_BATCHMODE = NO + +# If LATEX_HIDE_INDICES is set to YES then doxygen will not +# include the index chapters (such as File Index, Compound Index, etc.) +# in the output. + +LATEX_HIDE_INDICES = NO + +#--------------------------------------------------------------------------- +# configuration options related to the RTF output +#--------------------------------------------------------------------------- + +# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output +# The RTF output is optimized for Word 97 and may not look very pretty with +# other RTF readers or editors. + +GENERATE_RTF = NO + +# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `rtf' will be used as the default path. + +RTF_OUTPUT = rtf + +# If the COMPACT_RTF tag is set to YES Doxygen generates more compact +# RTF documents. This may be useful for small projects and may help to +# save some trees in general. + +COMPACT_RTF = NO + +# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated +# will contain hyperlink fields. The RTF file will +# contain links (just like the HTML output) instead of page references. +# This makes the output suitable for online browsing using WORD or other +# programs which support those fields. +# Note: wordpad (write) and others do not support links. + +RTF_HYPERLINKS = NO + +# Load stylesheet definitions from file. Syntax is similar to doxygen's +# config file, i.e. a series of assignments. You only have to provide +# replacements, missing definitions are set to their default value. + +RTF_STYLESHEET_FILE = + +# Set optional variables used in the generation of an rtf document. +# Syntax is similar to doxygen's config file. + +RTF_EXTENSIONS_FILE = + +#--------------------------------------------------------------------------- +# configuration options related to the man page output +#--------------------------------------------------------------------------- + +# If the GENERATE_MAN tag is set to YES (the default) Doxygen will +# generate man pages + +GENERATE_MAN = NO + +# The MAN_OUTPUT tag is used to specify where the man pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `man' will be used as the default path. + +MAN_OUTPUT = man + +# The MAN_EXTENSION tag determines the extension that is added to +# the generated man pages (default is the subroutine's section .3) + +MAN_EXTENSION = .3 + +# If the MAN_LINKS tag is set to YES and Doxygen generates man output, +# then it will generate one additional man file for each entity +# documented in the real man page(s). These additional files +# only source the real man page, but without them the man command +# would be unable to find the correct page. The default is NO. + +MAN_LINKS = NO + +#--------------------------------------------------------------------------- +# configuration options related to the XML output +#--------------------------------------------------------------------------- + +# If the GENERATE_XML tag is set to YES Doxygen will +# generate an XML file that captures the structure of +# the code including all documentation. + +GENERATE_XML = NO + +# The XML_OUTPUT tag is used to specify where the XML pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `xml' will be used as the default path. + +XML_OUTPUT = xml + +# The XML_SCHEMA tag can be used to specify an XML schema, +# which can be used by a validating XML parser to check the +# syntax of the XML files. + +XML_SCHEMA = + +# The XML_DTD tag can be used to specify an XML DTD, +# which can be used by a validating XML parser to check the +# syntax of the XML files. + +XML_DTD = + +# If the XML_PROGRAMLISTING tag is set to YES Doxygen will +# dump the program listings (including syntax highlighting +# and cross-referencing information) to the XML output. Note that +# enabling this will significantly increase the size of the XML output. + +XML_PROGRAMLISTING = YES + +#--------------------------------------------------------------------------- +# configuration options for the AutoGen Definitions output +#--------------------------------------------------------------------------- + +# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will +# generate an AutoGen Definitions (see autogen.sf.net) file +# that captures the structure of the code including all +# documentation. Note that this feature is still experimental +# and incomplete at the moment. + +GENERATE_AUTOGEN_DEF = NO + +#--------------------------------------------------------------------------- +# configuration options related to the Perl module output +#--------------------------------------------------------------------------- + +# If the GENERATE_PERLMOD tag is set to YES Doxygen will +# generate a Perl module file that captures the structure of +# the code including all documentation. Note that this +# feature is still experimental and incomplete at the +# moment. + +GENERATE_PERLMOD = NO + +# If the PERLMOD_LATEX tag is set to YES Doxygen will generate +# the necessary Makefile rules, Perl scripts and LaTeX code to be able +# to generate PDF and DVI output from the Perl module output. + +PERLMOD_LATEX = NO + +# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be +# nicely formatted so it can be parsed by a human reader. This is useful +# if you want to understand what is going on. On the other hand, if this +# tag is set to NO the size of the Perl module output will be much smaller +# and Perl will parse it just the same. + +PERLMOD_PRETTY = YES + +# The names of the make variables in the generated doxyrules.make file +# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. +# This is useful so different doxyrules.make files included by the same +# Makefile don't overwrite each other's variables. + +PERLMOD_MAKEVAR_PREFIX = + +#--------------------------------------------------------------------------- +# Configuration options related to the preprocessor +#--------------------------------------------------------------------------- + +# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will +# evaluate all C-preprocessor directives found in the sources and include +# files. + +ENABLE_PREPROCESSING = YES + +# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro +# names in the source code. If set to NO (the default) only conditional +# compilation will be performed. Macro expansion can be done in a controlled +# way by setting EXPAND_ONLY_PREDEF to YES. + +MACRO_EXPANSION = YES + +# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES +# then the macro expansion is limited to the macros specified with the +# PREDEFINED and EXPAND_AS_DEFINED tags. + +EXPAND_ONLY_PREDEF = YES + +# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files +# in the INCLUDE_PATH (see below) will be search if a #include is found. + +SEARCH_INCLUDES = YES + +# The INCLUDE_PATH tag can be used to specify one or more directories that +# contain include files that are not input files but should be processed by +# the preprocessor. + +INCLUDE_PATH = + +# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard +# patterns (like *.h and *.hpp) to filter out the header-files in the +# directories. If left blank, the patterns specified with FILE_PATTERNS will +# be used. + +INCLUDE_FILE_PATTERNS = + +# The PREDEFINED tag can be used to specify one or more macro names that +# are defined before the preprocessor is started (similar to the -D option of +# gcc). The argument of the tag is a list of macros of the form: name +# or name=definition (no spaces). If the definition and the = are +# omitted =1 is assumed. To prevent a macro definition from being +# undefined via #undef or recursively expanded use the := operator +# instead of the = operator. + +# C++98 version. +# +PREDEFINED = XSD_AUTO_PTR=std::auto_ptr + +# C++11 version. +# +# PREDEFINED = XSD_AUTO_PTR=std::unique_ptr + +# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then +# this tag can be used to specify a list of macro names that should be expanded. +# The macro definition that is found in the sources will be used. +# Use the PREDEFINED tag if you want to use a different macro definition. + +EXPAND_AS_DEFINED = + +# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then +# doxygen's preprocessor will remove all function-like macros that are alone +# on a line, have an all uppercase name, and do not end with a semicolon. Such +# function macros are typically used for boiler-plate code, and will confuse +# the parser if not removed. + +SKIP_FUNCTION_MACROS = YES + +#--------------------------------------------------------------------------- +# Configuration::additions related to external references +#--------------------------------------------------------------------------- + +# The TAGFILES option can be used to specify one or more tagfiles. +# Optionally an initial location of the external documentation +# can be added for each tagfile. The format of a tag file without +# this location is as follows: +# TAGFILES = file1 file2 ... +# Adding location for the tag files is done as follows: +# TAGFILES = file1=loc1 "file2 = loc2" ... +# where "loc1" and "loc2" can be relative or absolute paths or +# URLs. If a location is present for each tag, the installdox tool +# does not have to be run to correct the links. +# Note that each tag file must have a unique name +# (where the name does NOT include the path) +# If a tag file is not located in the directory in which doxygen +# is run, you must also specify the path to the tagfile here. + +TAGFILES = + +# When a file name is specified after GENERATE_TAGFILE, doxygen will create +# a tag file that is based on the input files it reads. + +GENERATE_TAGFILE = libxsd.doxytag + +# If the ALLEXTERNALS tag is set to YES all external classes will be listed +# in the class index. If set to NO only the inherited external classes +# will be listed. + +ALLEXTERNALS = NO + +# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed +# in the modules index. If set to NO, only the current project's groups will +# be listed. + +EXTERNAL_GROUPS = YES + +# The PERL_PATH should be the absolute path and name of the perl script +# interpreter (i.e. the result of `which perl'). + +PERL_PATH = /usr/bin/perl + +#--------------------------------------------------------------------------- +# Configuration options related to the dot tool +#--------------------------------------------------------------------------- + +# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will +# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base +# or super classes. Setting the tag to NO turns the diagrams off. Note that +# this option is superseded by the HAVE_DOT option below. This is only a +# fallback. It is recommended to install and use dot, since it yields more +# powerful graphs. + +CLASS_DIAGRAMS = YES + +# You can define message sequence charts within doxygen comments using the \msc +# command. Doxygen will then run the mscgen tool (see http://www.mcternan.me.uk/mscgen/) to +# produce the chart and insert it in the documentation. The MSCGEN_PATH tag allows you to +# specify the directory where the mscgen tool resides. If left empty the tool is assumed to +# be found in the default search path. + +MSCGEN_PATH = + +# If set to YES, the inheritance and collaboration graphs will hide +# inheritance and usage relations if the target is undocumented +# or is not a class. + +HIDE_UNDOC_RELATIONS = YES + +# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is +# available from the path. This tool is part of Graphviz, a graph visualization +# toolkit from AT&T and Lucent Bell Labs. The other options in this section +# have no effect if this option is set to NO (the default) + +HAVE_DOT = NO + +# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect inheritance relations. Setting this tag to YES will force the +# the CLASS_DIAGRAMS tag to NO. + +CLASS_GRAPH = YES + +# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect implementation dependencies (inheritance, containment, and +# class references variables) of the class with other documented classes. + +COLLABORATION_GRAPH = YES + +# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for groups, showing the direct groups dependencies + +GROUP_GRAPHS = YES + +# If the UML_LOOK tag is set to YES doxygen will generate inheritance and +# collaboration diagrams in a style similar to the OMG's Unified Modeling +# Language. + +UML_LOOK = NO + +# If set to YES, the inheritance and collaboration graphs will show the +# relations between templates and their instances. + +TEMPLATE_RELATIONS = NO + +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT +# tags are set to YES then doxygen will generate a graph for each documented +# file showing the direct and indirect include dependencies of the file with +# other documented files. + +INCLUDE_GRAPH = YES + +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and +# HAVE_DOT tags are set to YES then doxygen will generate a graph for each +# documented header file showing the documented files that directly or +# indirectly include this file. + +INCLUDED_BY_GRAPH = YES + +# If the CALL_GRAPH, SOURCE_BROWSER and HAVE_DOT tags are set to YES then doxygen will +# generate a call dependency graph for every global function or class method. +# Note that enabling this option will significantly increase the time of a run. +# So in most cases it will be better to enable call graphs for selected +# functions only using the \callgraph command. + +CALL_GRAPH = NO + +# If the CALLER_GRAPH, SOURCE_BROWSER and HAVE_DOT tags are set to YES then doxygen will +# generate a caller dependency graph for every global function or class method. +# Note that enabling this option will significantly increase the time of a run. +# So in most cases it will be better to enable caller graphs for selected +# functions only using the \callergraph command. + +CALLER_GRAPH = NO + +# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen +# will graphical hierarchy of all classes instead of a textual one. + +GRAPHICAL_HIERARCHY = YES + +# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES +# then doxygen will show the dependencies a directory has on other directories +# in a graphical way. The dependency relations are determined by the #include +# relations between the files in the directories. + +DIRECTORY_GRAPH = YES + +# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images +# generated by dot. Possible values are png, jpg, or gif +# If left blank png will be used. + +DOT_IMAGE_FORMAT = png + +# The tag DOT_PATH can be used to specify the path where the dot tool can be +# found. If left blank, it is assumed the dot tool can be found in the path. + +DOT_PATH = + +# The DOTFILE_DIRS tag can be used to specify one or more directories that +# contain dot files that are included in the documentation (see the +# \dotfile command). + +DOTFILE_DIRS = + +# The MAX_DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of +# nodes that will be shown in the graph. If the number of nodes in a graph +# becomes larger than this value, doxygen will truncate the graph, which is +# visualized by representing a node as a red box. Note that doxygen if the number +# of direct children of the root node in a graph is already larger than +# MAX_DOT_GRAPH_NOTES then the graph will not be shown at all. Also note +# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH. + +DOT_GRAPH_MAX_NODES = 50 + +# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the +# graphs generated by dot. A depth value of 3 means that only nodes reachable +# from the root by following a path via at most 3 edges will be shown. Nodes +# that lay further from the root node will be omitted. Note that setting this +# option to 1 or 2 may greatly reduce the computation time needed for large +# code bases. Also note that the size of a graph can be further restricted by +# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction. + +MAX_DOT_GRAPH_DEPTH = 0 + +# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent +# background. This is disabled by default, which results in a white background. +# Warning: Depending on the platform used, enabling this option may lead to +# badly anti-aliased labels on the edges of a graph (i.e. they become hard to +# read). + +DOT_TRANSPARENT = YES + +# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output +# files in one run (i.e. multiple -o and -T options on the command line). This +# makes dot run faster, but since only newer versions of dot (>1.8.10) +# support this, this feature is disabled by default. + +DOT_MULTI_TARGETS = NO + +# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will +# generate a legend page explaining the meaning of the various boxes and +# arrows in the dot generated graphs. + +GENERATE_LEGEND = YES + +# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will +# remove the intermediate dot files that are used to generate +# the various graphs. + +DOT_CLEANUP = YES + +#--------------------------------------------------------------------------- +# Configuration::additions related to the search engine +#--------------------------------------------------------------------------- + +# The SEARCHENGINE tag specifies whether or not a search engine should be +# used. If set to NO the values of all tags below this one will be ignored. + +SEARCHENGINE = NO diff --git a/xsd/doc/cxx/tree/reference/makefile b/xsd/doc/cxx/tree/reference/makefile new file mode 100644 index 0000000..5df62c9 --- /dev/null +++ b/xsd/doc/cxx/tree/reference/makefile @@ -0,0 +1,18 @@ +.PHONY: all +all: libxsd.doxytag + +headers := \ +../../../../libxsd/xsd/cxx/tree/buffer.hxx \ +../../../../libxsd/xsd/cxx/tree/types.hxx \ +../../../../libxsd/xsd/cxx/tree/date-time.hxx \ +../../../../libxsd/xsd/cxx/tree/elements.hxx \ +../../../../libxsd/xsd/cxx/tree/exceptions.hxx + +libxsd.doxytag: libxsd.doxygen footer.html $(headers) + doxygen $< + +.PHONY: clean +clean: + rm -f libxsd.doxytag + rm -rf html + |