D
David Dean
I am using the new InfoPath 2007 object model to retrieve and set values of
nodes within my main data source via managed code. I am able to successfully
use MainDataSource.GetNavigator() to get an XPathNavigator instance and
SelectSingleNode to get an XPathNavigator that points to an element in my
document.
Using the SetValue() method to change the element value works fine if the
element is defined in the schema as a string, but if the schema defines the
element as an integer, SetValue() causes the exception "Schema validation
found non-data type errors". If I try to use the SetTypedValue() method and
pass an Integer, I get the exception "The method or operation is not
implemented".
Here's a code example:
Dim birthDate As DateTime = DateTime.Parse(e.NewValue)
Dim age As Integer = GetAgeFromBirthDate(birthDate)
Dim ageNode As XPathNavigator =
myRoot.SelectSingleNode("/my:myFields/my:Age", nsmgr)
'ageNode.SetValue(age) ' causes schema validation exception
ageNode.SetTypedValue(age.ToString()) ' causes not implemented exception
In effect, there doesn't seem to be any way to set the node value if it's
declared in the schema as anything other than a string.
Any ideas?
nodes within my main data source via managed code. I am able to successfully
use MainDataSource.GetNavigator() to get an XPathNavigator instance and
SelectSingleNode to get an XPathNavigator that points to an element in my
document.
Using the SetValue() method to change the element value works fine if the
element is defined in the schema as a string, but if the schema defines the
element as an integer, SetValue() causes the exception "Schema validation
found non-data type errors". If I try to use the SetTypedValue() method and
pass an Integer, I get the exception "The method or operation is not
implemented".
Here's a code example:
Dim birthDate As DateTime = DateTime.Parse(e.NewValue)
Dim age As Integer = GetAgeFromBirthDate(birthDate)
Dim ageNode As XPathNavigator =
myRoot.SelectSingleNode("/my:myFields/my:Age", nsmgr)
'ageNode.SetValue(age) ' causes schema validation exception
ageNode.SetTypedValue(age.ToString()) ' causes not implemented exception
In effect, there doesn't seem to be any way to set the node value if it's
declared in the schema as anything other than a string.
Any ideas?