none
InfoPath - Programmatically Copy Data from Secondary Data Connection into Main Data Connection RRS feed

  • Question

  • I am having trouble copying data from my secondary data connection into my main data connections repeating table, below is my code for adding an item to my main data connections repeating table:

    Private Sub AddItem( _
        ByVal Car As String)
    
            Dim doc As XmlDocument = New XmlDocument()
            Dim group As XmlNode = doc.CreateElement("CurrentBodiesSnapShot", _
            NamespaceManager.LookupNamespace("d"))
    
            Dim field As XmlNode = doc.CreateElement("Car_ID", _
            NamespaceManager.LookupNamespace("@"))
            Dim node As XmlNode = group.AppendChild(field)
            node.InnerText = Car
    
            doc.AppendChild(group)
    
            MainDataSource.CreateNavigator().SelectSingleNode( _
            "/dfs:myFields/dfs:dataFields", _
            NamespaceManager).AppendChild(doc.DocumentElement.CreateNavigator())
    
        End Sub

    I get this message when I enter debugging mode "Schema validation found non-data type errors", it highlights this line when it pops up:

    MainDataSource.CreateNavigator().SelectSingleNode( _
        "/dfs:myFields/dfs:dataFields", _
        NamespaceManager).AppendChild(doc.DocumentElement.CreateNavigator())

    Its the first time I've had this message and do not know how to get around it, and I think its with the "/dfs:myFields/dfs:dataFields" code, if anyone could provide any assistance I would greatly appreciate it :)

    Thanks in advance!


    • Edited by hayer89 Monday, January 13, 2014 11:52 AM
    Monday, January 13, 2014 10:01 AM

Answers

  • Hi Simon_1989,

    Did you have a chance to look at the schema definition?

    For example, please check out the following points:

    • You might be missing a required attribute on an element.
    • You might have had to use attributes instead of elements.
    • etc. etc.

    The only thing I can advise you to do is to first figure out what the schema definition is and what the final XML should look like before trying to write the XML, since you are currently violating the schema definition somewhere.

    I have found a similar Schema validation found non-datatype errors forum thread.

    Tuesday, January 14, 2014 3:09 PM
  • Based on your description, I suggest you checking the following points:

    1.check whether there is any fields of null values in the data of your secondary data connection.

    2.check whether the order in which you are writing the xml into the node is in the correct sequence as it is in the InfoPath design.

    Here is a blog about the error message you are getting you could refer:

    InfoPath Forms Code Error: Schema validation found non-data type errors

    Thursday, January 16, 2014 3:09 AM
  • Hi,

    Extending chunchencool's reply:

    I found a Microsoft blog about the error message, hope it can help you.

    Many times, this error is caused by the “nillable” attribute being present on the node. The nillable attribute is a special attribute that can appear on an xsd:element within an XML schema. If an element has the xsi:nil attribute specified, it indicates that the element is present but has no value, and therefore no content is associated with it.

    If you attempt to programmatically set a value on this node and the nillable attribute is present, you will get an error similar to: “Schema validation found non-data type errors.”

    To resolve this error, your code will simply need to test if the nil attribute is present and if so, remove that attribute before setting the value on the node. (From Microsoft InfoPath 2010


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, January 16, 2014 3:22 AM
    Moderator

All replies

  • Hello Simon_1989,

    If you use Open XML files, I'd recommend asking Open XML related questions in the Open XML SDK forum instead. There you will find the most qualified answers.


    Monday, January 13, 2014 11:16 AM
  • I am having trouble copying data from my secondary data connection into my main data connections repeating table, below is my code for adding an item to my main data connections repeating table:

    Private Sub AddItem( _
        ByVal Car As String)
    
            Dim doc As XmlDocument = New XmlDocument()
            Dim group As XmlNode = doc.CreateElement("CurrentBodiesSnapShot", _
            NamespaceManager.LookupNamespace("d"))
    
            Dim field As XmlNode = doc.CreateElement("Car_ID", _
            NamespaceManager.LookupNamespace("@"))
            Dim node As XmlNode = group.AppendChild(field)
            node.InnerText = Car
    
            doc.AppendChild(group)
    
            MainDataSource.CreateNavigator().SelectSingleNode( _
            "/dfs:myFields/dfs:dataFields", _
            NamespaceManager).AppendChild(doc.DocumentElement.CreateNavigator())
    
        End Sub

    I get this message when I enter debugging mode "Schema validation found non-data type errors", it highlights this line when it pops up:

    MainDataSource.CreateNavigator().SelectSingleNode( _
        "/dfs:myFields/dfs:dataFields", _
        NamespaceManager).AppendChild(doc.DocumentElement.CreateNavigator())

    Its the first time I've had this message and do not know how to get around it, and I think its with the "/dfs:myFields/dfs:dataFields" code, if anyone could provide any assistance I would greatly appreciate it :)

    Thanks in advance!

    Monday, January 13, 2014 11:55 AM
  • Hi Simon_1989,

    Did you have a chance to look at the schema definition?

    For example, please check out the following points:

    • You might be missing a required attribute on an element.
    • You might have had to use attributes instead of elements.
    • etc. etc.

    The only thing I can advise you to do is to first figure out what the schema definition is and what the final XML should look like before trying to write the XML, since you are currently violating the schema definition somewhere.

    I have found a similar Schema validation found non-datatype errors forum thread.

    Tuesday, January 14, 2014 3:09 PM
  • Based on your description, I suggest you checking the following points:

    1.check whether there is any fields of null values in the data of your secondary data connection.

    2.check whether the order in which you are writing the xml into the node is in the correct sequence as it is in the InfoPath design.

    Here is a blog about the error message you are getting you could refer:

    InfoPath Forms Code Error: Schema validation found non-data type errors

    Thursday, January 16, 2014 3:09 AM
  • Hi,

    Extending chunchencool's reply:

    I found a Microsoft blog about the error message, hope it can help you.

    Many times, this error is caused by the “nillable” attribute being present on the node. The nillable attribute is a special attribute that can appear on an xsd:element within an XML schema. If an element has the xsi:nil attribute specified, it indicates that the element is present but has no value, and therefore no content is associated with it.

    If you attempt to programmatically set a value on this node and the nillable attribute is present, you will get an error similar to: “Schema validation found non-data type errors.”

    To resolve this error, your code will simply need to test if the nil attribute is present and if so, remove that attribute before setting the value on the node. (From Microsoft InfoPath 2010


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, January 16, 2014 3:22 AM
    Moderator