Page 1 of 1

Version Validation

Posted: Fri Jul 24, 2020 3:54 pm
by madhukar
Hi Team,

I have a requirement to validate an XML using Xpath Schematron based on the Version.

Posting a sample below.

<Node1 version="1">
<Node1 version="2">
<Node1 version="3">

I have a requirement to fetch the min value of the version element and then fetch the Value of Type Element for the min version and need to validate as the Type element Value should be the same for remaining versions.

So Technically value of Version 3 should fail and the Type Element value does not equals the one with Version 1 element.

I am new to Xpath Schematron, Can you help me figure out a way.

Thanks in advance.

Re: Version Validation

Posted: Tue Jul 28, 2020 1:17 pm
by tavy

For this type of questions probably is better to use the "schematron at schematronist dot org" mailing list. There are more people that can respond to them, and maybe better answers.

I think that a solution for your Schematron rule can be something like this:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<sch:schema xmlns:sch="" queryBinding="xslt2">
    <sch:let name="typeValue" value="//Node1[not(@version > ../Node1/@version)][1]/Type/text()"/>
        <sch:rule context="Type">
            <sch:assert test="text() = $typeValue">
                The Type value must be "<sch:value-of select="$typeValue"/>"
Best Regards,