Open mhaack opened 6 years ago
XDM is a declarative schema - it has no concepts of conditionals nor should it.
@lrosenthol I disagree. XDM being declarative bears no relationship whatsoever to it having conditionals or not. For example, SQL and XSLT have support for conditional statements are are declarative languages.
Why does XDM need a common way of modeling conditions? Because the alternative is to model conditions not at all (reducing the usefulness of XDM in the applications below) or to model conditions in an inconsistent way.
Examples where conditions are needed:
I don’t believe that we need conditionals in a declarative schema. Please elaborate on those specific uses cases and why they need such capabilities in the schema (vs. business rules outside the data definitions)
Here are a couple of examples of existing applications that model conditions in JSON:
if
, then
, and else
keywords. The if
condition itself is a JSON Schema http://json-schema.org/draft-07/json-schema-validation.html#rfc.section.6.6DateGreaterThan
https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_condition.htmlMy personal preference order would be something like this:
@mhaack could you verify that (1) works for you. Imagine you have a $data
object that has properties for everything that would be available to the condition evaluation engine as properties and you write a schema that evaluates the condition.
@lrosenthol let's take pricing as an example:
In the EU, stated prices must include VAT (value added tax) and the American practice of showing the price without tax and calculating what the customer will pay at checkout is illegal (false advertising). However, customers only have to pay VAT if they are residing in the EU, and are not a business.
So, an online shop would need to model two things:
Because the online shop is typically a combination of multiple systems, these conditions need to be kept in sync between (at least)
Modern experiences are personalized, and this means conditional. If we can't model the conditions, we can't model the experience.
Our products like AEM Commerce, but also Adobe Target, Audience Manager, etc. are using both conditions in their domain model and are using XDM as the schema for their APIs. If we keep business rules out of XDM, they will be kept out of the API, and will effectively either make the API useless, or make XDM partially irrelevant to our products (because they implement a private, non-standard business rule API)
@trieloff I hadn't seen the if/then/else stuff in JSON Schema. Since that's the standard we are using - I agree with you, we should support it.
However, I still don't buy the argument about putting business rules inside of the XDMs.
I think XDM should have a "conditional language" to have a standard way to define conditions when a property should be used or not. Conditions could refer to other attributes of the same or another XDM schema. The language should support basic checks like:
Examples of this are for example in the commerce area where products have prices which only apply to a certain region/customer group/channel/etc.
Example: