Rocket U2 | UniVerse & UniData

 View Only

 U2XMAP spec / api problem - field set repeats within child table nodes

Brian Arnold's profile image
Brian Arnold posted 01-27-2021 16:57
The XMAP and result below is from my UniVerse 11.3.1 AIX platform. They represent a simple object model containing two child tables with the same parent table. The data is from the HS.SALES sample/demo tables that come with UniVerse.

Using the DB.TOXML command, also provided with UV, produces an XML file containing records from the parent table and related records from each child table. However, the fields for each record from one of the child tables are duplicated within each record node from that table.

In fact, further analysis showed that the set of fields mapped for each child table will repeat count(TableMap)–1 times within each child record node in the output. This means that if there are three sibling tables defined under one parent, output for the child TableMap referenced first in the parent TABLECLASSMAP, will contain fields in triplicate; output for the child TableMap referenced second will contain fields in duplicate; and so on.

This behavior was noticed during development of a process in a real-world UniVerse database environment with a more involved object model. So, in order to confirm it, the issue is demonstrated here with a simple out-of-the box data set.

It is reasonable to expect the XMAP specification and APIs to accurately serialize this simple data model. The XMAP here, including the use of the TableMap element, was designed based on the documentation and examples available in the basic and extended commands reference guides. I’ve thus far been unable to unearth details about the XMAPCreate(), XMAPAppendRec() and XMAPToXMLDoc() api functions sufficient to aid in troubleshooting the XMAP specification, or to determine in which of those api functions is at fault. Any insight would be greatly appreciated. See attached pdf for a formatted version of the structures below.

>CT &XML& XMAP_TESTDBTOXML.XML

XMAP_TESTDBTOXML.XML
0001 <?xml version="1.0" encoding="UTF-8"?>
0002 <!-- DOCTYPE U2XMAP SYSTEM "U2XMAP.DTD" -->
0003 <U2XMAP version="1.0" Name="XMAP1" >
0004 <!-- Table/Class map XCLASS_CLASS -->
0005 <TABLECLASSMAP MapName="M1" StartNode="/Customers/Customer" TableName="CUSTOMER">
0006 <ColumnMap Node="CustID" Column="@ID"/>
0007 <ColumnMap Node="FirstName" Column="FNAME"/>
0008 <ColumnMap Node="LastName" Column="LNAME" />
0009 <ColumnMap Node="State" Column="STATE" />
0010 <ColumnMap Node="ProductID" Column="PRODID" />
0011 <TableMap Node="Products/Product" MapName="M2" />
0012 <TableMap Node="States/State" MapName="M3" />
0013 </TABLECLASSMAP>
0014 <TABLECLASSMAP MapName="M2" StartNode="Products/Product" TableName="PRODUCTS">
0015 <ColumnMap Node="Price" Column="LIST" />
0016 <ColumnMap Node="Description" Column="DESCRIPTION" />
0017 </TABLECLASSMAP>
0018 <TABLECLASSMAP MapName="M3" StartNode="States/State" TableName="STATES">
0019 <ColumnMap Node="StateName" Column="NAME" />
0020 </TABLECLASSMAP>
0021 <RelatedTable>
0022 <MapParentKey TableName="CUSTOMER" Column="PRODID" KeyGenerate="No" />
0023 <MapChildKey TableName="PRODUCTS" Column="PRODID" />
0024 </RelatedTable>
0025 <RelatedTable>
0026 <MapParentKey TableName="CUSTOMER" Column="STATE" KeyGenerate="No" />
0027 <MapChildKey TableName="STATES" Column="CODE" />
0028 </RelatedTable>
0029 </U2XMAP>

OUTPUT: (notice the repeating sets of fields within the <Product> element)

>DB.TOXML CUSTOMERINFO.XML XMAP_TESTDBTOXML.XML
DB.TOXML success

>CT &XML& CUSTOMERINFO.XML

CUSTOMERINFO.XML
0001 <?xml version="1.0" encoding="utf-8" standalone="yes" ?>
0002 <Customers>
0003
0004 <Customer>
0005 <CustID>2</CustID>
0006 <FirstName>Diana</FirstName>
0007 <LastName>Morris</LastName>
0008 <State>MA</State>
0009 <ProductID>C2000ýM3000ýS3000</ProductID>
0010 <Products>
0011 <Product>
0012 <Price>$12,990</Price>
0013 <Description>Heavy duty monochrome copier</Description>
0014 <Price>$12,990</Price>
0015 <Description>Heavy duty monochrome copier</Description>
0016 </Product>
0017 <Product>
0018 <Price>$6,890</Price>
0019 <Description>Moderate duty, entry level, color copier</Description>
0020 <Price>$6,890</Price>
0021 <Description>Moderate duty, entry level, color copier</Description>
0022 </Product>
0023 <Product>
0024 <Price>$1,990</Price>
0025 <Description>Sorting attachment for M3000/C3000</Description>
0026 <Price>$1,990</Price>
0027 <Description>Sorting attachment for M3000/C3000</Description>
0028 </Product>
0029 </Products>
0030 <States>
0031 <State>
0032 <StateName>Massachusetts</StateName>
0033 </State>
0034 </States>
0035 </Customer>
0036
0037 <Customer>
0038 <CustID>4</CustID>
0039 <FirstName>Jill</FirstName>
0040 <LastName>Kahn</LastName>
0041 <State>MA</State>
0042 <ProductID>C3000</ProductID>
0043 <Products>
0044 <Product>
0045 <Price>$17,990</Price>
0046 <Description>Heavy duty color copier</Description>
0047 <Price>$17,990</Price>
0048 <Description>Heavy duty color copier</Description>
0049 </Product>
0050 </Products>
0051 <States>
0052 <State>
0053 <StateName>Massachusetts</StateName>
0054 </State>
0055 </States>
0056 </Customer>
0057
0058 <Customer>
0059 <CustID>6</CustID>
0060 <FirstName>Betty</FirstName>
0061 <LastName>Burke</LastName>
0062 <State>VT</State>
0063 <States>
0064 <State>
0065 <StateName>Vermont</StateName>
0066 </State>
0067 </States>
0068 </Customer>
0069
0070 <Customer>
0071 <CustID>3</CustID>
0072 <FirstName>David</FirstName>
0073 <LastName>Argonne</LastName>
0074 <State>MA</State>
0075 <ProductID>M2000</ProductID>
0076 <Products>
0077 <Product>
0078 <Price>$4,490</Price>
0079 <Description>Moderate duty, monochrome copier</Description>
0080 <Price>$4,490</Price>
0081 <Description>Moderate duty, monochrome copier</Description>
0082 </Product>
0083 </Products>
0084 <States>
0085 <State>
0086 <StateName>Massachusetts</StateName>
0087 </State>
0088 </States>
0089 </Customer>
0090
0091 <Customer>
0092 <CustID>5</CustID>
0093 <FirstName>Kenneth</FirstName>
0094 <LastName>Williams</LastName>
0095 <State>RI</State>
0096 <ProductID>M1000ýM1000</ProductID>
0097 <Products>
0098 <Product>
0099 <Price>$1,990</Price>
0100 <Description>Low cost, entry level, light duty, monochrome copier</Description>
0101 <Price>$1,990</Price>
0102 <Description>Low cost, entry level, light duty, monochrome copier</Description>
0103 </Product>
0104 </Products>
0105 <States>
0106 <State>
0107 <StateName>Rhode Island</StateName>
0108 </State>
0109 </States>
0110 </Customer>
0111
0112 <Customer>
0113 <CustID>7</CustID>
0114 <FirstName>Martha</FirstName>
0115 <LastName>Gill</LastName>
0116 <State>NH</State>
0117 <ProductID>M2000ýS2000</ProductID>
0118 <Products>
0119 <Product>
0120 <Price>$990</Price>
0121 <Description>Sorting attachment for M2000/C2000</Description>
0122 <Price>$990</Price>
0123 <Description>Sorting attachment for M2000/C2000</Description>
0124 </Product>
0125 <Product>
0126 <Price>$4,490</Price>
0127 <Description>Moderate duty, monochrome copier</Description>
0128 <Price>$4,490</Price>
0129 <Description>Moderate duty, monochrome copier</Description>
0130 </Product>
0131 </Products>
0132 <States>
0133 <State>
0134 <StateName>New Hampshire</StateName>
0135 </State>
0136 </States>
0137 </Customer>
0138
0139 <Customer>
0140 <CustID>10</CustID>
0141 <FirstName>Andrew</FirstName>
0142 <LastName>McCaig</LastName>
0143 <State>VT</State>
0144 <ProductID>M1000ýM1000ýC2000</ProductID>
0145 <Products>
0146 <Product>
0147 <Price>$1,990</Price>
0148 <Description>Low cost, entry level, light duty, monochrome copier</Description>
0149 <Price>$1,990</Price>
0150 <Description>Low cost, entry level, light duty, monochrome copier</Description>
0151 </Product>
0152 <Product>
0153 <Price>$6,890</Price>
0154 <Description>Moderate duty, entry level, color copier</Description>
0155 <Price>$6,890</Price>
0156 <Description>Moderate duty, entry level, color copier</Description>
0157 </Product>
0158 </Products>
0159 <States>
0160 <State>
0161 <StateName>Vermont</StateName>
0162 </State>
0163 </States>
0164 </Customer>
0165
0166 <Customer>
0167 <CustID>8</CustID>
0168 <FirstName>Steven</FirstName>
0169 <LastName>Holland</LastName>
0170 <State>MA</State>
0171 <ProductID>M3000ýS3000</ProductID>
0172 <Products>
0173 <Product>
0174 <Price>$1,990</Price>
0175 <Description>Sorting attachment for M3000/C3000</Description>
0176 <Price>$1,990</Price>
0177 <Description>Sorting attachment for M3000/C3000</Description>
0178 </Product>
0179 <Product>
0180 <Price>$12,990</Price>
0181 <Description>Heavy duty monochrome copier</Description>
0182 <Price>$12,990</Price>
0183 <Description>Heavy duty monochrome copier</Description>
0184 </Product>
0185 </Products>
0186 <States>
0187 <State>
0188 <StateName>Massachusetts</StateName>
0189 </State>
0190 </States>
0191 </Customer>
0192
0193 <Customer>
0194 <CustID>12</CustID>
0195 <FirstName>Laurie</FirstName>
0196 <LastName>Patry</LastName>
0197 <State>MA</State>
0198 <States>
0199 <State>
0200 <StateName>Massachusetts</StateName>
0201 </State>
0202 </States>
0203 </Customer>
0204
0205 <Customer>
0206 <CustID>1</CustID>
0207 <FirstName>Samuel</FirstName>
0208 <LastName>Smith</LastName>
0209 <State>NH</State>
0210 <ProductID>M2000</ProductID>
0211 <Products>
0212 <Product>
0213 <Price>$4,490</Price>
0214 <Description>Moderate duty, monochrome copier</Description>
0215 <Price>$4,490</Price>
0216 <Description>Moderate duty, monochrome copier</Description>
0217 </Product>
0218 </Products>
0219 <States>
0220 <State>
0221 <StateName>New Hampshire</StateName>
0222 </State>
0223 </States>
0224 </Customer>
0225
0226 <Customer>
0227 <CustID>9</CustID>
0228 <FirstName>Nicole</FirstName>
0229 <LastName>Orlando</LastName>
0230 <State>MA</State>
0231 <States>
0232 <State>
0233 <StateName>Massachusetts</StateName>
0234 </State>
0235 </States>
0236 </Customer>
0237
0238 <Customer>
0239 <CustID>11</CustID>
0240 <FirstName>Skip</FirstName>
0241 <LastName>Lewis</LastName>
0242 <State>MA</State>
0243 <States>
0244 <State>
0245 <StateName>Massachusetts</StateName>
0246 </State>
0247 </States>
0248 </Customer>
0249
0250 </Customers>
>
Mike Rajkowski's profile image
ROCKETEER Mike Rajkowski
What is the DTD (or Schema) you are using for this?