Sunday, December 28, 2008

Truncated real fields (ex. LineNum) when table is exported as XML

When you are using the method xml() for exporting records from any table in DAX you could get inconsistency data for real fields.

The problem is located inside the method Global::xmlstring. In this method, the real type is exported only with 2 decimals. You must override this method in the appropiated layer to export reals with 8, 10, 12 or more number of decimals.

// Returns a XML string describing the given value of the given type.
static str xmlString(anytype value, Types theType, int indent=0)
{
    str r;
    Object o;
    Common record;

    ...

    r = strrep(' ', indent);

    switch (theType)
    {

    ...
    
    // Modified: original allows only 2 decimals,
    // now, we allow 12
    case Types::Real:       r += num2str(value,
                                        /* min chars */ 1,
                                        /* decimals */  12,  // Original = 2
                                        /* decimals = point */ 1,
                                        /* no thousand sep */ 0); break;

    ...

    }
    return r;
}


0 comments:


View My Stats