be.ehealth.technicalconnector.validator

## Class ValidatorHelper

- java.lang.Object
- - be.ehealth.technicalconnector.validator.ValidatorHelper

-     public final class ValidatorHelper
      extends Object

  Helper class providing XML validation utilities for the eHealth technical connector.

  Supports validation of XML `Source` objects and JAXB-bound objects against one or more W3C XML Schema (XSD) files. Optionally handles XOP (XML-binary Optimized Packaging) content during validation.

  Schema resources are resolved from the classpath relative to `SchemaValidatorHandler`. Validation errors and fatal errors are collected and reported as a single `TechnicalConnectorException`; warnings are logged but do not cause the validation to fail.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `ValidatorHelper()`

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static void` | `validate(Object jaxbObj, Class xmlClass, String rootSchemaFileLocation)` Validates a JAXB object against a single XSD schema file using an explicit JAXB class.
    `static void` | `validate(Object jaxbObj, String rootSchemaFileLocation)` Validates a JAXB object against a single XSD schema file.
    `static void` | `validate(Source source, boolean xop, String... schemaLocations)` Validates an XML `Source` against one or more XSD schema files, with optional XOP processing support.
    `static void` | `validate(Source source, String... schemaLocations)` Validates an XML `Source` against one or more XSD schema files.

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### ValidatorHelper

          public ValidatorHelper()

  - ### Method Detail

    - #### validate

          public static void validate(Source source,
                                      boolean xop,
                                      String... schemaLocations)
                               throws TechnicalConnectorException

      Validates an XML `Source` against one or more XSD schema files, with optional XOP processing support.
      Parameters:
        `source` - the XML source to validate
        `xop` - `true` to enable XOP include handling during validation
        `schemaLocations` - one or more classpath-relative paths to XSD schema files
      Throws:
        `TechnicalConnectorException` - if the source is not schema-valid, or if a technical error occurs during parsing or validation

    - #### validate

          public static void validate(Source source,
                                      String... schemaLocations)
                               throws TechnicalConnectorException

      Validates an XML `Source` against one or more XSD schema files.

      Equivalent to calling `validate(Source, boolean, String...)` with `xop = false`.

      Parameters:
        `source` - the XML source to validate
        `schemaLocations` - one or more classpath-relative paths to XSD schema files
      Throws:
        `TechnicalConnectorException` - if the source is not schema-valid, or if a technical error occurs during parsing or validation

    - #### validate

          public static void validate(Object jaxbObj,
                                      String rootSchemaFileLocation)
                               throws TechnicalConnectorException

      Validates a JAXB object against a single XSD schema file.

      The JAXB context is derived from the runtime class of `jaxbObj`. Equivalent to calling `validate(Object, Class, String)` with `xmlClass = jaxbObj.getClass()`.

      Parameters:
        `jaxbObj` - the JAXB-bound object to validate; must not be `null`
        `rootSchemaFileLocation` - classpath-relative path to the root XSD schema file
      Throws:
        `TechnicalConnectorException` - if `jaxbObj` is `null`, is not schema-valid, or if a technical error occurs

    - #### validate

          public static void validate(Object jaxbObj,
                                      Class xmlClass,
                                      String rootSchemaFileLocation)
                               throws TechnicalConnectorException

      Validates a JAXB object against a single XSD schema file using an explicit JAXB class.

      The JAXB context is resolved via `JaxbContextFactory` for the given `xmlClass`. The object is first serialised to a `JAXBSource` before schema validation is applied.

      Parameters:
        `jaxbObj` - the JAXB-bound object to validate; must not be `null`
        `xmlClass` - the class used to resolve the `JAXBContext`
        `rootSchemaFileLocation` - classpath-relative path to the root XSD schema file
      Throws:
        `TechnicalConnectorException` - if `jaxbObj` is `null`, is not schema-valid, or if a technical error occurs

Connector Packaging OTMOBILITYIMPROVEMENT 4.9.5 API
Copyright © {inceptionYear}-2026 eHealth. All Rights Reserved.