
So, what should your XMLport look like to make the first XML document ( XML50101_DiffComplexZeroOccurs_FailSchema.xml) pass? If you have the same XMLport but this time the XML contains exactly the same Tax -> Amount elements ( XML50101_DiffComplexZeroOccurs_FailMetadata.xml), it will pass the schema validation but it will fail because the XMLport definition in XMLport is defined so that the second Tax element should have a child Date. We get an error in this scenario because Invoice and Total are referring to the same element Tax, but the definition is not compatible because there is no information about a possible child Date. As you can see from the first Tax element’s definition, it only has one child Amount.

A type in XSD is created based on the first element referenced outside its namespace, meaning that the first Tax element is a child of the element Invoice, which does not have any prefix, unlike the element Tax, which is part of the Finance namespace. If you try to import XML that has Tax -> Amount and Tax -> Date ( XML50101_DiffComplexZeroOccurs_FailSchema.xml), you will get an error because the XML is not valid according to a generated XSD.

Based on that element, an element in XSD is created and that XSD (generated schema) is used later to validate the XML. When creating XMLports, you need to make sure that the first element that is referenced outside its namespace is the most general (we will call this rule “ First General”). Imagine that you have an XMLport where the elements Amount and Date have the MinOccurs property set to Zero and they belong to different nodes that share the same XML name. To better understand the impact of those two validations, let’s take a look at a few examples. A generated XSD (XML Schema Definition).Default value for the Occurrence property of an attribute is Required.īasically there are two validations that XML is validated against:.Default values for the MinOccurs and MaxOccurs properties of an element are Once and Unbounded, respectively.In this blog post, we’ll take a closer look at how to make sure that the XML that is being imported is valid.īefore we get into details about XMLports, here’s a quick reminder about default values: If you’re not familiar with the technology, you can learn more by reading XMLport Object. In Dynamics 365 Business Central, you can use XMLports to export and import data between an external source and Business Central.

Applies to: Dynamics 365 Business Central
