+1 800 256 3608 (toll-free in North America) or +49 7531 90 60 10| service@combit.com

What algorithm does XmlDataProvider use to decide whether a field is numeric or string?

dataprovider

(David Mackenzie) #1

And when is this algorithm applied?

I generate XML with fields which are either numerical values (with decimal point, not comma) or empty.
It looks as if they are treated as numeric if the first line is not empty.
Can I rely on this?

However, when I have a report (.lst file) where a field was previously treated as string, it seems to continue to be treated as string. Is there a way to force the type to be re-evaluated?


(Oliver Hambrecht) #2

You can influence the type in the XML to be another format in LL by using the attribute “lltype” for the field - see that in the remark section remarks section of the XmlDataProvider. Also the event PreParseXPathNavigator of the XmlDataProvider can be used to modify the field type. Maybe this can help you?


(David Mackenzie) #3

Thank you very much Oliver.
The fields are themselves generated from attributes, so unfortunately I can’t easily use “lltype” in my XML.
However, “PreParseXPathNavigator” sounds interesting - I’ll look at that in detail on Monday.


(David Mackenzie) #4

The PreParseXPathNavigator event was the solution for me.
I use the following function to force each field to String or Double (depending on e.Navigator.Name):

private void SetParsedType(System.Type t, PreParseXPathNavigatorEventArgs e)
{
    e.ParsedType = t;

    try
    {
        e.ParsedContent = e.Navigator.ValueAs(t);
    }
    catch (Exception ex)
    {
        if (t == typeof(Double))
        {
            e.ParsedContent = Double.NaN;
        }
    }

    e.SkipDefaultProcessing = true;
}