Professional Documents
Culture Documents
0 Technical Articles
Introduction
2n Microsoft SQL Server 2000: )e introd"ced the +,R -ML cla"se to the SELECT state'ent. This cla"se provides the a&ilit to aggregate the relational ro)set ret"rned & the SELECT state'ent into -ML. +,R -ML on the server s"pports three 'odes;RA<: A=T,: and 7-8L2C2T;that provide different transfor'ation se'antics. RA< 'ode generates single ele'ents: )hich are na'ed row: for each ro) ret"rned. The A=T, 'ode e'plo s a he"ristic to infer a si'ple: one ele'ent na'e*per*level hierarch &ased on the lineage infor'ation and the order of the data in a SELECT state'ent. +inall : the 7-8L2C2T 'ode re>"ires a specific ro)set for'at that can &e 'apped into al'ost an -ML shape: )hile still &eing for'"lated & a single SQL >"er . All three 'odes are designed to generate the -ML in a strea'a&le )a in order to &e a&le to prod"ce large doc"'ents efficientl . The 7-8L2C2T 'ode for'at is highl s"ccessf"l in achieving its goals. There are onl a fe) things it cannot do /ar&itrar rec"rsive part*list trees are one of the'1. The preferred SQL e.pression to generate the ro)set for'at is a for'ida&le ?>"er fro' hell:? ho)ever. =nfort"natel : +,R -ML res"lts in SQL Server 2000 can onl &e cons"'ed on the client side: and a"thoring co'ple. -ML str"ct"res "sing +,R -ML 7-8L2C2T is a co'ple. e.ercise. As one of the designers of the ro)set for'at: 2 have all the respect for people )ho )rite: and then 'aintain:
'"lti*tho"sand line 7-8L2C2T 'ode >"eries. 2 also: ho)ever: "nderstand the "sa&ilit : 'aintaina&ilit : and co'ple.it iss"es. 2n SQL Server 200$: )e no) have alternatives to the ?>"er fro' hell.? 2n the follo)ing: )e )ill ta4e a loo4 at the 'ain feat"res added to +,R -ML in SQL Server 200$% 2ntegration )ith the -ML data t pe: assigna&ilit and nesting of e.pressions: and the ne) 8AT9 'ode. <e provide so'e 6orth)ind sche'a*&ased e.a'ples that sho) ho) 7-8L2C2T 'ode >"eries can &e 'ore easil )ritten "sing the ne) feat"res. 3esides these ne) feat"res: +,R -ML also provides a co"ple of additional ne): s'aller feat"res that are s"''ari@ed at the end of this section and s"pports an easier )a to generate na'espace* a)are doc"'ents. Note +,R -ML contin"es to &e a ro)set aggregation cla"se of the SQL S7L7CT state'ent: and th"s cannot transfor' side*effect o"tp"t fro' stored proced"res. 2f o" )ant res"lts of so'e for' of processing transfor'ed into -ML: please "se either a "ser*defined f"nction or a vie).
ret"rns the Customers ele'ents as an ()L data t pe instance: instead of the n archar%ma$& instance that )o"ld have &een the case )itho"t the T+,E directive. This res"lt is g"aranteed to confor' to the )ell*for'edness constraints provided & the ()L data t pe. Since the res"lt is an ()L data t pe instance: o" can also "se (Query e.pressions to >"er and reshape the res"lt. +or e.a'ple: the follo)ing e.pression retrieves the Customer contact na'e into a ne) ,erson ele'ent. Cop Code
SELECT (SELECT * FROM Customers FOR XML AUTO, TYPE).query( '< o!"# $or %! &' (Customers retur' <Perso' ')me*+# )t)(%!(,Co't)!t-)me).+(" .<( o!"')
ret"rns /onl first ele'ents sho)n1: Cop Code
< o!" <Perso' ')me*+M)r&) A' ers+ (" <Perso' ')me*+A') Tru/&00o+ (" <Perso' ')me*+A'to'&o More'o+ (" ... <( o!"
1ECLARE ,!ust XML2 SET ,!ust * (SELECT * FROM Customers FOR XML AUTO, TYPE) CREATE TA3LE T(& &'t, 4 XML) 5-SERT 5-TO T SELECT 6, (SELECT * FROM Customers FOR XML AUTO, TYPE)
SELECT 6 )s TA7,
-ULL )s P)re't, Customer51 )s +Customer868Customer51+, -ULL )s +Or er898Or er51+, -ULL )s +Em:0oyee8;8L)st-)me+ FROM Customers U-5O- ALL SELECT 9, 6, Customers.Customer51, Or ers.Or er51, -ULL FROM Or ers <O5- Customers O- Or ers.Customer51 * Customers.Customer51 U-5O- ALL SELECT 15ST5-CT ;, 6, Customers.Customer51, -ULL, Em:0oyees.L)st-)me FROM Customers <O5- Or ers O- Customers.Customer51 * Or ers.Customer51 <O5- Em:0oyees O- Or ers.Em:0oyee51 * Em:0oyees.Em:0oyee51 OR1ER 3Y +Customer868Customer51+,+Em:0oyee8;8L)st-)me+,+Or er898Or er51+ FOR XML EXPL5C5T
ret"rns /onl first c"sto'er sho)n1: Cop Code
<Customer Customer51*+ALF=5+" <Or er Or er51*+6>?@;+ (" <Or er Or er51*+6>?A9+ (" <Or er Or er51*+6>B>9+ (" <Or er Or er51*+6>C;D+ (" <Or er Or er51*+6>AD9+ (" <Or er Or er51*+66>66+ (" <Em:0oyee L)st-)me*+1)Eo0&o+ (" <Em:0oyee L)st-)me*+LeEer0&'F+ (" <Em:0oyee L)st-)me*+Pe)!o!G+ ("
SELECT Customer51 )s +Customer51+, (SELECT Or er51 )s +Or er51+ FROM Or ers +Or er+ HIERE +Or er+.Customer51 * Customer.Customer51 FOR XML AUTO, TYPE), (SELECT 15ST5-CT L)st-)me )s +L)st-)me+ FROM Em:0oyees Em:0oyee <O5- Or ers +Or er+ O- +Or er+.Em:0oyee51 * Em:0oyee.Em:0oyee51 HIERE Customer.Customer51 * +Or er+.Customer51 FOR XML AUTO, TYPE) FROM Customers Customer FOR XML AUTO, TYPE
This ret"rns: e.cept for g"aranteeing the ele'ent order: the sa'e res"lt as the 7-8L2C2T 'ode >"er /if o" care a&o"t the order: o" can add an order & state'ent1. ,&vio"sl : this >"er is easier to )rite: "nderstand: and 'aintain: even tho"gh it contains &asicall the sa'e n"'&er of select state'ents and (oin conditions.
5onBt despairE A ne) +,R -ML 'ode gives o" the sa'e fle.i&ilit in a '"ch si'pler )a . The ne) 8AT9 'ode: together )ith the a&ilit to nest +,R -ML e.pressions: has &eco'e the si'plest )a to generate co'ple. -ML doc"'ents. The 8AT9 'ode allo)s o" to "se an -8ath*li4e s nta. as a col"'n na'e: )hich then is 'apped into an attri&"te /e.g.: 34a31: ele'ent /e.g.: 3e31: s"& ele'ent str"ct"re /3e56e!31: ele'ent content /3731: te.t node /3te$t%&31: or data val"e /3data%&31. As )ith the RA< 'ode: the defa"lt na'e for the ro) ele'ent is row and can &e over)ritten )ith an 6C6a'e /a na'e )itho"t a prefi.1. LetBs loo4 at so'e e.a'ples. +irst: let "s give the 8AT9 'ode for'"lation of the a&ove 7-8L2C2T 'ode >"er . Cop Code
SELECT Customer51 )s +,Customer51+, (SELECT Or er51 )s +,Or er51+ FROM Or ers HIERE Or ers.Customer51 * Customers.Customer51 FOR XML PATI('Or er'), TYPE), (SELECT 15ST5-CT L)st-)me )s +,L)st-)me+ FROM Em:0oyees <O5- Or ers O- Or ers.Em:0oyee51 * Em:0oyees.Em:0oyee51 HIERE Customers.Customer51 * Or ers.Customer51 FOR XML PATI('Em:0oyee'), TYPE) FROM Customers FOR XML PATI('Customer')
This e.a'ple is si'ilar to the A=T, 'ode version and ret"rns the sa'e res"lt. 6o) letBs loo4 at so'e of the 8AT9 'ode specific capa&ilities. The ne.t >"er ta4es the c"sto'er infor'ation and gro"ps the address and contact infor'ation into separate s"& ele'ents "sing a 'ore co'ple. path e.pression as col"'n alias: and;"sing the ne) R,,T directive;adds a root node aro"nd it for good 'eas"re. Cop Code
C&ty )s +) ReF&o' )s +)
Post)0Co e )s +) Cou'try )s +)
ress(!ou'try+,
<!o't)!t" <')me"M)r&) A' ers<(')me" <t&t0e"S)0es Re:rese't)t&Ee<(t&t0e" <:Ko'e">;>M>>B@;96<(:Ko'e" <$)4">;>M>>B?D@D<($)4" <(!o't)!t" <(Customer" ... <( o!"
9o) )o"ld this >"er loo4 li4e if it "sed the 7-8L2C2T 'odeD <e need fo"r select cla"ses;one for each non*leaf ele'ent;instead of onl one selection. Cop Code
SELECT to: 6 6 )s TA7, -ULL )s P)re't, 6 )s + o!868 ummy8K& e+, -ULL )s +Customer898Customer51+, -ULL )s +Customer898Com:)'y-)me8e0eme't+, -ULL )s +) -ULL )s +) -ULL )s +) -ULL )s +) -ULL )s +) ress8;8street8e0eme't+, ress8;8!&ty8e0eme't+, ress8;8reF&o'8e0eme't+, ress8;8J&:8e0eme't+, ress8;8!ou'try8e0eme't+,
-ULL )s +!o't)!t8@8')me8e0eme't+, -ULL )s +!o't)!t8@8t&t0e8e0eme't+, -ULL )s +!o't)!t8@8:Ko'e8e0eme't+, -ULL )s +!o't)!t8@8$)48e0eme't+ FROM Customers U-5O- ALL SELECT 9, 6, 6, Customer51, Com:)'y-)me, -ULL, -ULL, -ULL, -ULL, -ULL, -ULL, -ULL, -ULL, -ULL FROM Customers U-5O- ALL SELECT ;, 9, 6, Customer51, -ULL, A ress, C&ty, ReF&o', Post)0Co e, Cou'try,
-ULL, -ULL, -ULL, -ULL FROM Customers U-5O- ALL SELECT @, 9, 6, Customer51, -ULL, -ULL, -ULL, -ULL, -ULL, -ULL, Co't)!t-)me, Co't)!tT&t0e, PKo'e, F)4 FROM Customers OR1ER 3Y + o!868 ummy8K& e+,+Customer898Customer51+ FOR XML EXPL5C5T, TYPE
6o) )e 4no) )h the 7-8L2C2T 'ode is so'eti'es called the ?>"er fro' hell.? Last &"t not least: the follo)ing gives "s an e.a'ple of generating a val"e list: and sho)s the "se of a te.t node. Cop Code
SELECT Customer51 )s +,51+, (SELECT Or er51 )s + )t)()+ FROM Or ers HIERE Customers.Customer51*Or ers.Customer51
FOR XML PATI('') ) )s +,Or er51s+, Com:)'y-)me, Co't)!tT&t0e )s +Co't)!t-)me(,Co't)!tT&t0e+, Co't)!t-)me )s +Co't)!t-)me(te4t()+, Post)0Co e )s +A A ress )s +A ress(,N5P+,
ress(Street+,
ress(C&ty+
<Customer 51*+IU-7C+ Or er51s*+6>;BD 6>;A@ 6>@6D 6>?>> 6>??>+" <Com:)'y-)me"Iu'Fry Coyote 5m:ort Store<(Com:)'y-)me" <Co't)!t-)me Co't)!tT&t0e*+S)0es Re:rese't)t&Ee+"YosK& L)t&mer<(Co't)!t-)me" <A ress N5P*+ABC9B+"
<(Customer"
LetBs dissect the relevant parts of the >"er . The s"& >"er : )hich generates the /rderI*s attri&"te list: 'aps the /rderI* col"'n val"es as ato'ic val"es /"sing the path data%&1. These val"es )ill then &e seriali@ed as a te.t node & adding a space &et)een si&ling ato'ic val"es: )hich are provided in the ne.t cell in the ro)set. <e then avoid generating a na'e for the ro) & "sing the @ero*length string as the 8AT9 'ode arg"'ent: so that )e get a single string /note: there is no TF87 directiveE1 as the res"lt of the +,R -ML 8AT9 e.pression. That string gets 'apped to the /rderI*s attri&"te & the containing +,R -ML e.pression. The CompanyName gets 'apped to a s"& ele'ent of the sa'e na'e. The ContactTitle prod"ces the ContactTitle attri&"te of the ContactName ele'ent: )hile the ContactName col"'n val"e is 'apped into the te.t node of the sa'e ele'ent. 6ote that in this case: the sa'e res"lt )o"ld have &een achieved & 'apping ContactName to the ContactName ele'ent directl . +inall : the properties for the -ddress ele'ent parts are p"t together.
a voca&"lar : and to associate -ML Sche'a infor'ation /and potentiall other infor'ation1 )ith an -ML ele'ent or attri&"te. +,R -ML: in SQL Server 2000: p"ts the &"rden of generating and 'aintaining -ML na'espaces co'pletel on the >"er )riter. The -ML na'espace declaration attri&"tes had to &e created: li4e ever other attri&"te: )ith the na'espace =R2 &eing the col"'n val"e. =nless the generated -ML )as in attri&"te*centric for': this 'eant that the >"er had to &e )ritten "sing the 7-8L2C2T 'ode. +or e.a'ple: the follo)ing >"er p"ts the res"lting C"sto'er ele'ents and its propert ele'ents into the na'espace urn:e$ample8com6customer% Cop Code
SELECT 6 )s t)F, -ULL )s :)re't, 'ur'Oe4)m:0e.!om(!ustomer' )s +!ustOCustomer8684m0'sO!ust+, Customer51 )s +!ustOCustomer868!ustOCustomer518e0eme't+, Co't)!t-)me )s +!ustOCustomer868!ustOCo't)!t-)me8e0eme't+ FROM Customers FOR XML EXPL5C5T
The res"lt of the >"er is /onl first t)o ele'ents sho)n1% Cop Code
<!ustOCustomer 4m0'sO!ust*+ur'Oe4)m:0e.!om(!ustomer+" <!ustOCustomer51"ALF=5<(!ustOCustomer51" <!ustOCo't)!t-)me"M)r&) A' ers<(!ustOCo't)!t-)me" <(!ustOCustomer" <!ustOCustomer 4m0'sO!ust*+ur'Oe4)m:0e.!om(!ustomer+" <!ustOCustomer51"A-ATR<(!ustOCustomer51" <!ustOCo't)!t-)me"A') Tru/&00o<(!ustOCo't)!t-)me" <(!ustOCustomer"
6a'espace declarations are not reall attri&"tes in the -ML data 'odel. Th"s: the 8AT9 'ode does not allo) the' to &e specified as attri&"tes. 2n order to si'plif the "se of -ML na'espaces in +,R -ML: )e have added s"pport for the <2T9 -ML6AM7S8AC7S cla"se starting in the April CT8 version of SQL Server 200$. The <2T9 -ML6AM7S8AC7S cla"se is defined in the SQL%200G standard as an e.tension to the general <2T9 cla"se that is co''onl "sed to define co''on ta&le e.pressions. The <2T9 cla"se can &e placed on top*level SQL state'ents: s"ch as S7L7CT: 26S7RT and =85AT7 state'ents: and "sed inside a CR7AT7 H27< state'ent. The <2T9 -ML6AM7S8AC7S cla"se can &e "sed )ith the RA<: A=T, and 8AT9 'ode: &"t not )ith either the -MLSC97MA and -ML5ATA directives or the 7-8L2C2T 'ode. The previo"s 'ethod of creating na'espaces is still s"pported for the SQL Server 2000 'odes: &"t cannot &e 'i.ed )ith the <2T9 -ML6AM7S8AC7S cla"se. To disa'&ig"ate the <2T9 cla"se fro' other s ntactic "ses of <2T9: T*SQL state'ents that precede <2T9 cla"ses need to &e ter'inated )ith a se'i*colon /I1. The follo)ing >"er places the c"sto'er and order data into different na'espaces and adds a root node in a defa"lt na'espace. Cop Code
, 'ur'Oe4)m:0e.!om(!ustomer' )s +!+ , 'ur'Oe4)m:0e.!om(or er' )s +o+ ) SELECT Customer51 )s +,51+, (SELECT Or er51 )s +,Or er51+ $rom Or ers PKere Customers.Customer51*Or ers.Customer51 FOR XML PATI('oOOr er'), TYPE ) )s +!OOr ers+, Com:)'y-)me )s +!OCom:)'y-)me+, Co't)!tT&t0e )s +!OCo't)!t-)me(,Co't)!tT&t0e+, Co't)!t-)me )s +!OCo't)!t-)me(te4t()+, Post)0Co e )s +!OA A ress )s +!OA ress(,N5P+,
ress(!OStreet+,
ress(!OC&ty+
As the follo)ing partial res"lt sho)s: the -ML na'espace declarations are c"rrentl added at the top*level ele'ents of ever +,R -ML selection% Cop Code
< o! 4m0'sOo*+ur'Oe4)m:0e.!om(or er+ 4m0'sO!*+ur'Oe4)m:0e.!om(!ustomer+ 4m0's*+ur'Oe4)m:0e.!om( o!+" <!OCustomer 51*+ALF=5+" <!OOr ers" <oOOr er 4m0'sOo*+ur'Oe4)m:0e.!om(or er+ 4m0'sO!*+ur'Oe4)m:0e.!om(!ustomer+ 4m0's*+ur'Oe4)m:0e.!om( o!+ Or er51*+6>?@;+ (" <oOOr er 4m0'sOo*+ur'Oe4)m:0e.!om(or er+ 4m0'sO!*+ur'Oe4)m:0e.!om(!ustomer+ 4m0's*+ur'Oe4)m:0e.!om( o!+ Or er51*+6>?A9+ (" <oOOr er 4m0'sOo*+ur'Oe4)m:0e.!om(or er+ 4m0'sO!*+ur'Oe4)m:0e.!om(!ustomer+ 4m0's*+ur'Oe4)m:0e.!om( o!+ Or er51*+6>B>9+ (" <oOOr er 4m0'sOo*+ur'Oe4)m:0e.!om(or er+ 4m0'sO!*+ur'Oe4)m:0e.!om(!ustomer+ 4m0's*+ur'Oe4)m:0e.!om( o!+
Or er51*+6>C;D+ (" <oOOr er 4m0'sOo*+ur'Oe4)m:0e.!om(or er+ 4m0'sO!*+ur'Oe4)m:0e.!om(!ustomer+ 4m0's*+ur'Oe4)m:0e.!om( o!+ Or er51*+6>AD9+ (" <oOOr er 4m0'sOo*+ur'Oe4)m:0e.!om(or er+ 4m0'sO!*+ur'Oe4)m:0e.!om(!ustomer+ 4m0's*+ur'Oe4)m:0e.!om( o!+ Or er51*+66>66+ (" <(!OOr ers" <!OCom:)'y-)me"A0$re s FutterG&ste<(!OCom:)'y-)me" <!OCo't)!t-)me Co't)!tT&t0e*+S)0es Re:rese't)t&Ee+"M)r&) A' ers<(!OCo't)!t-)me" <!OA ress N5P*+699>A+"
<(!OCustomer" ...
The a&ove >"er "sed the 57+A=LT cla"se for adding a defa"lt na'espace. 6ote that if there are nested -ML doc"'ents )ith no defa"lt na'espace incl"ded in the res"lt: a slight perfor'ance penalt has to &e paid to 'a4e s"re that the preserve their a&sence of a defa"lt na'espace. +inall : the <2T9 -ML6AM7S8AC7S cla"se can also &e "sed to provide na'espace &indings for the -Q"er and -ML 5ML 'ethods on the -ML data t pe.
SELECT ;, 6, -'Lo y' U-5OSELECT @, ;, -' oor' U-5OSELECT D, ;, -'$e' er' U-5OSELECT ?, @, -'P&' oP' U-5OSELECT B, 9, -':&sto''
6e.t: )e define the f"nction that for a given part n"'&er ret"rns the s"&parts in -ML for'% Cop Code
CREATE FU-CT5O- P)rtsL&st(,P)rts-o &'t) RETUR-S XML H5TI RETUR-S -ULL O- -ULL 5-PUT 3E75- RETUR(SELECT & )s +,& +, ')me )s +,')me+,
se0e!t &
CASE HIE- & *; TIEE-1 FROM PARTS HIERE & *; FOR XML PATI('P)rts'), TYPE
Ret"rns% Cop Code
Lo.P)rtsL&st(& )
<P)rts & *+@+ ')me*+ oor+" <P)rts & *+?+ ')me*+P&' oP+ (" <(P)rts" <P)rts & *+D+ ')me*+$e' er+ (" <(P)rts"
6ote that SQL Server 200$ has a 'a.i'"' li'it of G2 rec"rsivel nested f"nction invocations. 2f o"r parts hierarch e.ceeds the li'it: o" )ill need to "se the old approach of getting the -ML in flat for' and appl ing an -SLT st le sheet to create the hierarch .
<Customer" <Customer51"ALF=5<(Customer51" <Com:)'y-)me"A0$re s FutterG&ste<(Com:)'y-)me" <Co't)!t-)me"M)r&) A' ers<(Co't)!t-)me" <Co't)!tT&t0e"S)0es Re:rese't)t&Ee<(Co't)!tT&t0e" <A ress"OLere Str. DB<(A ress"
2.
The ELE)ENTS directive provides an -S262L option to 'ap N9LL val"es to an ele'ent )ith an attri&"te $si:nil:3true3. +or e.a'ple: Cop Code
SELECT * FROM Customers HIERE ReF&o' &s 'u00 FOR XML PATI('Customer'), ELEME-TS XS5-5L
ret"rns /onl sho)ing the first c"sto'er1: Cop Code
<Customer 4m0'sO4s&*+Ktt:O((PPP.P;.orF(9>>6(XMLS!Kem)M&'st)'!e+" <Customer51"ALF=5<(Customer51" <Com:)'y-)me"A0$re s FutterG&ste<(Com:)'y-)me" <Co't)!t-)me"M)r&) A' ers<(Co't)!t-)me" <Co't)!tT&t0e"S)0es Re:rese't)t&Ee<(Co't)!tT&t0e" <A ress"OLere Str. DB<(A ress"
<C&ty"3er0&'<(C&ty" <ReF&o' 4s&O'&0*+true+ (" <Post)0Co e"699>A<(Post)0Co e" <Cou'try"7erm)'y<(Cou'try" <PKo'e">;>M>>B@;96<(PKo'e" <F)4">;>M>>B?D@D<(F)4" <(Customer"
G. A ne) in*line sche'a inference directive ()LSC2E)- that ta4es a target na'espace 90I as an optional arg"'ent has &een added for the RA< and A=T, 'odes. +or e.a'ple: Cop Code
Cop Code
<4s Os!Kem) t)rFet-)mes:)!e*+ur'Oe4)m:0e.!om+ 4m0'sO4s *+Ktt:O((PPP.P;.orF(9>>6(XMLS!Kem)+ 4m0'sOsq0ty:es* +Ktt:O((s!Kem)s.m&!roso$t.!om(sq0serEer(9>>@(sq0ty:es+ e0eme'tForm1e$)u0t*+qu)0&$&e +" <4s O&m:ort ')mes:)!e* +Ktt:O((s!Kem)s.m&!roso$t.!om(sq0serEer(9>>@(sq0ty:es+ (" <4s Oe0eme't ')me*+Customer+" ... <(4s Oe0eme't" <(4s Os!Kem)" <Customer 4m0's*+ur'Oe4)m:0e.!om+ Customer51*+ALF=5+ Com:)'y-)me*+A0$re s FutterG&ste+ Co't)!t-)me*+M)r&) A' ers+ Co't)!tT&t0e*+S)0es Re:rese't)t&Ee+ A ress*+OLere Str. DB+ C&ty*+3er0&'+ Post)0Co e*+699>A+ Cou'try*+7erm)'y+ PKo'e*+>;>M>>B@;96+ F)4*+>;>M>>B?D@D+ (" ...
6ote that the 7-8L2C2T and 8AT9 'odes J "nli4e the RA< and A=T, 'odes J are nor'all "sed )hen generating the -ML according to a previo"sl provided sche'a. Therefore )e do not provide the sche'a inference directive )ith the 7-8L2C2T and 8AT9 'odes.
Conclusion
<e provided a first loo4 at the e.tended +,R -ML s"pport in SQL Server 200$. The added f"nctionalit : 'ostl ena&led & the ne) ()L data t pe: )ill 'a4e +,R -ML a ver po)erf"l and eas to "se tool to generate -ML fro' o"r relational data. The ne) 8AT9 'ode: together )ith the nesting of +,R -ML >"eries and the <2T9 -ML6AM7S8AC7S cla"se: gives eno"gh po)er to replace 'ost of the 7-8L2C2T 'ode >"eries in a si'pler: 'ore 'aintaina&le )a . The a&ilit to nest +,R -ML >"eries also provides a 'echanis' to generate rec"rsive hierarchies. There )ill still &e a fe) cases )here o" 'a )ant to "se the 7-8L2C2T 'ode /in order to generate C5ATA sections or to "se the #$mlte$t directive: for e.a'ple1: &"t the ne) f"nctionalit sho"ld 'a4e the ?>"er fro' hell? a '"ch less fre>"ent enco"nter.