1

I have a requirement whereby we need to validate an incoming XML against different schemas in MarkLogic. So, the steps required are :

  1. Validate the outer structure of xml for possible elements/structure against schema A.
  2. Validate each section against dedicated section schemas for them.[section1-schema,section2-schema etc]
  3. Report back the errors received to the front-end.

From what I have read/done till now for a single document that needs validation against single schema inMarkLogic is : Ingest the schema in Schemas DB and the incoming document can be validated against that using validate{} if they both are in same namespace. I haven't encountered such requirement before so need some pointers.

Shabana
  • 121
  • 7

1 Answers1

1

One approach would be to use the XML Schema standard reuse mechanisms to create a new schema that combines the component schemas by reference through use of include, import, or redefine statements.

The combining schema can then be installed in the schemas database and used for validation.

Explanatory resources for schema reuse by reference include the following:

https://learn.microsoft.com/en-us/biztalk/core/schemas-that-use-other-schemas

As an alternative, you can use a schema on a node:

https://docs.marklogic.com/xdmp:validate

That might be easier for prototyping but could be less efficient, encapsulated, and flexible in the long run than exploiting the reuse mechanisms of XML Schema.

Hoping that helps,

ehennum
  • 7,295
  • 13
  • 9
  • If this clarifies my question better : is there a way to pass schema name as a parameter in some in-built function present in MarkLogic? That could make it straightforward to validate individual sections against dedicated schemas. Something like this : validate(sectionName,schemaName) – Shabana Dec 29 '20 at 12:15