NAV2013R2: dotNet XSD check
DHendriksen
Member Posts: 32
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
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
-
which line is it exactly?0
-
Good question! It's the last line, the validate.0
-
Solved:
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'1 -
Thanks for that piece of code! Was searching around for some examples.
Do you know how to store the return string (if the xml is invalid) and prevent the error message from the DotNet variable?0 -
Hi jhenav,
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, Don0 -
DHendriksen wrote:Hi jhenav,
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?* Daniele Rebussi * | * Rebu NAV Diary *0 -
Hello DHendriksen :
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,
Gierkink0 -
Hi 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.Gierkink wrote:Hello DHendriksen :
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
It is not available :-k
2. I would think this is asynchrone programming, and Navision does not support this.
warm Regard,
Gierkink0 -
The method can't be declared from the overview, but you can copy-paste it while declaring a variable. Undocumented feature :-)
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,
Don0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 328 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions
