[xsl] Compare logical expressions with XPath/XSLT

Subject: [xsl] Compare logical expressions with XPath/XSLT
From: "Michael Müller-Hillebrand mmh@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 7 Mar 2019 15:53:42 -0000
Hi,

I have a problem at hand that (I think) I understood on the whiteboard, but
have no initial idea how to best tackle this using our beloved tools
(currently limited to XSLT/XPath 2).

We have larger objects (documents) and many child objects (chapters), and both
can have a property, let's call it "Project Name". The task is to find
conflicts between the document's and the chapter's project setting. Behind
each project name there is a configurable boolean expression using AND, OR and
NOT, which defines whether two projects may match or not.

The definition of project names looks like this (with required="false"
describing the NOT logic):

<defs>
  <def name="project-1">
    <set>
      <AND>
        <OR>
          <item required="false">A</item>
          <item required="false">B</item>
        </OR>
        <item required="false">C</item>
      </AND>
    </set>
  </def>
  <def name="project-2">
    <set>
      <OR>
        <item required="true">A</item>
        <item required="true">C</item>
      </OR>
    </set>
  </def>
  <def name="project-3">
    <set>
      <item required="false">C</item>
    </set>
  </def>
</defs>

If the document uses "project-1", a chapter with "project-2" would be in
conflict with project-1, because { A OR C } is not a subset of { (!A OR !B)
AND !C }.

A chapter with "project-3" would be okay, because { !C } is a subset of { (!A
OR !B) AND !C }.

I simply hope for some pointers to similar problems.

Thanks a lot for your time,

- Michael MC<ller-Hillebrand

Current Thread