Software Development

Kotlin – Validate XML against XSDs

Last Updated on

This post is about XML validation against more than one related XSDs – one XSD is included into the main XSD.

Requirements

Stuff used for this post.

  1. Java JDK 1.8.0_171
  2. IntelliJ IDEA
  3. Kotlin 1.2
    • Using 1.2.31-release-95

XML Schemas

We use the following schemas for XML validation.

[wp_ad_camp_1]

Note on line 3, we included the first XSD in myschema.xsd. These files must be in the same directory.

XML to Validate

Kotlin Codes

[wp_ad_camp_2]

Sample Output

[wp_ad_camp_3]

You Might Also Like