Hi All,
We have some NAV code based on dotNet variables which checks an XML document with an XSD Schema:
doc := doc.XmlDocument();
doc.Load('c:\temp\dev\test.xml');
schemas := doc.Schemas;
schemas.Add('', 'c:\temp\dev\test.xsd');
doc.Validate(null);
//doc DotNet 'System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Xml.XmlDocument
//schemas DotNet 'System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Xml.Schema.XmlSchemaSet
//null DotNet 'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Object
This code compiles in a NAV2009R2 environment, but not in a NAV2013R2 environment. The compile Error is:
ENU: The function call was ambiguous. No matching method was found.
NLD: De functieaanroep is dubbelzinnig. Er is geen overeenkomende methode gevonden.
Does anyone have any clue why this error occures in NAV2013R2 and what is the solution to prevend this error?
Thanks in advance.
Regards, Don
0
Comments
doc := doc.XmlDocument();
doc.Load('c:\temp\dev\test.xml');
schemas := doc.Schemas;
schemas.Add('', 'c:\temp\dev\test.xsd');
doc.Validate(handler);
//doc DotNet System.Xml.XmlDocument.'System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
//schemas DotNet System.Xml.Schema.XmlSchemaSet.'System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
//handler DotNet System.Xml.Schema.ValidationEventHandler.'System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
Do you know how to store the return string (if the xml is invalid) and prevent the error message from the DotNet variable?
If the XML is not valid you get an Error message from the [doc.Validate(null);]. We show this Error message to the user. So we don't have any more code around it.
Regards, Don
What about insert it in a codeunit to call with "IF codeunit.RUN" statement?
1. In my case the handler could not be declared as variable :
doc := doc.XmlDoc//handler DotNet System.Xml.Schema.ValidationEventHandler.'System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'[/quote]
It is not available :-k
2. I would think this is asynchrone programming, and Navision does not support this.
warm Regard,
Gierkink
have you been able to resolve this? I also need to validate an xml file against an xsd schema.
Anyone can help with this one?
Thanks.
System.Xml.Schema.ValidationEventHandler.'System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
Variables:
DotNetSchemas, DotNet, System.Xml.Schema.XmlSchemaSet.'System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
DotNetSchemaHandler, DotNet, System.Xml.Schema.ValidationEventHandler.'System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
Code lines:
DotNetSchemas := DotNetXmlDoc.Schemas;
DotNetSchemas.Add('',<XSDSchemaLocation>); // Change <XSDSchemaLocation> with the location.
DotNetXmlDoc.Validate(DotNetSchemaHandler);
This is working correct in our processes... Hopefully this helps.
Regards,
Don