DB.TOXML bug?

38 views
Skip to first unread message

ArnoldBR

unread,
Jan 22, 2021, 4:16:03 PM1/22/21
to Pick and MultiValue Databases
Based on my understanding of the XMAP specification relative to DB.TOXML, the following XMAP represents a simple object model containing two child tables with the same parent table. The command DB.TOXML CUST_ACT.XML XMAP_CustomerActivity.XML produces an XML file containing the records and fields from the parent table and one of the child tables as expected. However, the fields for each record of the other child table are repeated once within the record node. If I switch the child TableMaps, in the parent TABLECLASSMAP, the problem switches to the other child table. It appears that when more than one (child) TableMap is specified in the parent map, fields from the table in the child map referenced by the first (child) TableMap entry are repeated TableMap times in record nodes of that table. This behavior was noticed during development of a process in a real-world UniVerse database environment with a more involved object model. In order to confirm, I created simple CUSTOMER / CONTACT, CUSTOMER / ORDER files with a few test records for demonstration purposes. If this is a bug versus an XMAP configuration error on my part, then it appears either the XMAPCreate() API function or the XMAPAppendRec() API function may not correctly support this structure. Any ideas? Thanks in advance. UniVerse 11.3.1 on AIX.

XMAP:
 ?xml version="1.0" encoding="UTF-8"?>
<!-- DOCTYPE U2XMAP SYSTEM "U2XMAP.DTD" -->
<U2XMAP version="1.0" Name="XMAP1" >
<!-- Table/Class map XCLASS_CLASS -->
<TABLECLASSMAP MapName="M1" StartNode="/Customers/Customer" TableName="CUSTOMERTBL">
<ColumnMap Node="CustKey" Column="CKEY"/>
<ColumnMap Node="Name" Column="CNAME" />
<TableMap Node="Orders/Order" MapName="M2" />
<TableMap Node="Contact/Methods" MapName="M3" />
</TABLECLASSMAP>
<TABLECLASSMAP MapName="M2" StartNode="Orders/Order" TableName="ORDERTBL">
<ColumnMap Node="CustKey" Column="C.KEY" />
<ColumnMap Node="OrderKey" Column="@ID" />
<ColumnMap Node="OrderDate" Column="ORDERDATE" />
<ColumnMap Node="ProductId" Column="PRODUCTID" />
</TABLECLASSMAP>
<TABLECLASSMAP MapName="M3" StartNode="Contact/Methods" TableName="CONTACTMETHTBL">
<ColumnMap Node="CustKey" Column="C.KEY" />
<ColumnMap Node="ContactKey" Column="@ID" />
<ColumnMap Node="Type" Column="TYPE" />
<ColumnMap Node="Address" Column="ADDRESS" />
</TABLECLASSMAP>
<RelatedTable>
<MapParentKey TableName="CUSTOMERTBL" Column="CKEY" KeyGenerate="No" />
<MapChildKey TableName="ORDERTBL" Column="CKEY" />
</RelatedTable>
<RelatedTable>
<MapParentKey TableName="CUSTOMERTBL" Column="CKEY" KeyGenerate="No" />
<MapChildKey TableName="CONTACTMETHTBL" Column="CKEY" />
</RelatedTable>
</U2XMAP>

RESULT:
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<Customers>
  <Customer>
    <CustKey>1</CustKey>
    <Name>MOUSE, MICKEY</Name>
    <Orders>
      <Order>
        <CustKey>1</CustKey>
        <OrderKey>10</OrderKey>
        <OrderDate>01-04-2022</OrderDate>
        <ProductId>555R3232</ProductId>
        <CustKey>1</CustKey>
        <OrderKey>10</OrderKey>
        <OrderDate>01-04-2022</OrderDate>
        <ProductId>555R3232</ProductId>
      </Order>
      <Order>
        <CustKey>1</CustKey>
        <OrderKey>1</OrderKey>
        <OrderDate>12-27-2021</OrderDate>
        <ProductId>5323423</ProductId>
        <CustKey>1</CustKey>
        <OrderKey>1</OrderKey>
        <OrderDate>12-27-2021</OrderDate>
        <ProductId>5323423</ProductId>
      </Order>
      <Order>
        <CustKey>1</CustKey>
        <OrderKey>2</OrderKey>
        <OrderDate>12-28-2021</OrderDate>
        <ProductId>9299399</ProductId>
        <CustKey>1</CustKey>
        <OrderKey>2</OrderKey>
        <OrderDate>12-28-2021</OrderDate>
        <ProductId>9299399</ProductId>
      </Order>
      <Order>
        <CustKey>1</CustKey>
        <OrderKey>3</OrderKey>
        <OrderDate>12-29-2021</OrderDate>
        <ProductId>23492349</ProductId>
        <CustKey>1</CustKey>
        <OrderKey>3</OrderKey>
        <OrderDate>12-29-2021</OrderDate>
        <ProductId>23492349</ProductId>
      </Order>
    </Orders>
    <Contact>
      <Methods>
        <CustKey>1</CustKey>
        <ContactKey>1</ContactKey>
        <Type>HOMEPH</Type>
        <Address>444-555-6666</Address>
      </Methods>
      <Methods>
        <CustKey>1</CustKey>
        <ContactKey>2</ContactKey>
        <Type>HOMEST</Type>
        <Address>580 LIBERTY CIR</Address>
      </Methods>
    </Contact>
  </Customer>
  <Customer>
    <CustKey>2</CustKey>
    <Name>FROG, KERMIT</Name>
    <Orders>
      <Order>
        <CustKey>2</CustKey>
        <OrderKey>4</OrderKey>
        <OrderDate>12-29-2021</OrderDate>
        <ProductId>99338822</ProductId>
        <CustKey>2</CustKey>
        <OrderKey>4</OrderKey>
        <OrderDate>12-29-2021</OrderDate>
        <ProductId>99338822</ProductId>
      </Order>
      <Order>
        <CustKey>2</CustKey>
        <OrderKey>5</OrderKey>
        <OrderDate>12-28-2021</OrderDate>
        <ProductId>23874771</ProductId>
        <CustKey>2</CustKey>
        <OrderKey>5</OrderKey>
        <OrderDate>12-28-2021</OrderDate>
        <ProductId>23874771</ProductId>
      </Order>
    </Orders>
    <Contact>
      <Methods>
        <CustKey>2</CustKey>
        <ContactKey>3</ContactKey>
        <Type>HOMEPH</Type>
        <Address>777-888-9999</Address>
      </Methods>
      <Methods>
        <CustKey>2</CustKey>
        <ContactKey>4</ContactKey>
        <Type>WORKPH</Type>
        <Address>909-090-0909</Address>
      </Methods>
    </Contact>
  </Customer>
  <Customer>
    <CustKey>3</CustKey>
    <Name>BIRD, BIG</Name>
    <Orders>
      <Order>
        <CustKey>3</CustKey>
        <OrderKey>6</OrderKey>
        <OrderDate>12-30-2021</OrderDate>
        <ProductId>83776632</ProductId>
        <CustKey>3</CustKey>
        <OrderKey>6</OrderKey>
        <OrderDate>12-30-2021</OrderDate>
        <ProductId>83776632</ProductId>
      </Order>
      <Order>
        <CustKey>3</CustKey>
        <OrderKey>7</OrderKey>
        <OrderDate>12-30-2021</OrderDate>
        <ProductId>R29898W9</ProductId>
        <CustKey>3</CustKey>
        <OrderKey>7</OrderKey>
        <OrderDate>12-30-2021</OrderDate>
        <ProductId>R29898W9</ProductId>
      </Order>
      <Order>
        <CustKey>3</CustKey>
        <OrderKey>8</OrderKey>
        <OrderDate>12-31-2021</OrderDate>
        <ProductId>23884888</ProductId>
        <CustKey>3</CustKey>
        <OrderKey>8</OrderKey>
        <OrderDate>12-31-2021</OrderDate>
        <ProductId>23884888</ProductId>
      </Order>
      <Order>
        <CustKey>3</CustKey>
        <OrderKey>9</OrderKey>
        <OrderDate>12-29-2021</OrderDate>
        <ProductId>29993999</ProductId>
        <CustKey>3</CustKey>
        <OrderKey>9</OrderKey>
        <OrderDate>12-29-2021</OrderDate>
        <ProductId>29993999</ProductId>
      </Order>
    </Orders>
    <Contact>
      <Methods>
        <CustKey>3</CustKey>
        <ContactKey>5</ContactKey>
        <Type>HOMEPH</Type>
        <Address>405-040-5040</Address>
      </Methods>
    </Contact>
  </Customer>
</Customers>

Reply all
Reply to author
Forward
0 new messages