30
Greenfox A schema language for validating file systems Hans-Jürgen Rennau, parsQube GmbH Presented at xmlprague 2020, February 15, 2020

Why SHOULD Java integrate XQuery? · Schema-valid (XSD, JSON Schema, SHACL, ... Example: folder resource values 2020-02-15 Greenfox 21 Resource value empty files Resource value ill-formed

  • Upload
    others

  • View
    11

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Why SHOULD Java integrate XQuery? · Schema-valid (XSD, JSON Schema, SHACL, ... Example: folder resource values 2020-02-15 Greenfox 21 Resource value empty files Resource value ill-formed

Greenfox

A schema language for

validating file systems

Hans-Jürgen Rennau, parsQube GmbH

Presented at xmlprague 2020, February 15, 2020

Page 2: Why SHOULD Java integrate XQuery? · Schema-valid (XSD, JSON Schema, SHACL, ... Example: folder resource values 2020-02-15 Greenfox 21 Resource value empty files Resource value ill-formed

Greenfox: definition

2020-02-15 Greenfox 2

Greenfox is a language for validating

file system trees* against a set of conditions.

*file system tree =

a folder + all folders and files directly or indirectly contained

Page 3: Why SHOULD Java integrate XQuery? · Schema-valid (XSD, JSON Schema, SHACL, ... Example: folder resource values 2020-02-15 Greenfox 21 Resource value empty files Resource value ill-formed

File system validation

Why?

What, precisely?

How?

2020-02-15 Greenfox 3

Page 4: Why SHOULD Java integrate XQuery? · Schema-valid (XSD, JSON Schema, SHACL, ... Example: folder resource values 2020-02-15 Greenfox 21 Resource value empty files Resource value ill-formed

Conventional validation –

some basic limitations

2020-02-15 Greenfox 4

Limitation 1:

The scope is limited to a set of related document types,

belonging to a single mediatype

Limitation 2:

Files are the input – their presence or absence is out of scope,

whereas the real problem may be the absence of a file

Limitation 3:

Expectations about resources are static –

ignoring dependence on other resources (their presence and contents)

Page 5: Why SHOULD Java integrate XQuery? · Schema-valid (XSD, JSON Schema, SHACL, ... Example: folder resource values 2020-02-15 Greenfox 21 Resource value empty files Resource value ill-formed

What, precisely?

Folder contents

File contents

Schema-valid (XSD, JSON Schema, SHACL, …)

Rules conformant („If contains Foo, contains Bar“)

Folder/file content dependencies:

File A exists <=> file B exists

File A exists <=> file B contains <Bar>

File A contains <Foo> <=> file B contains <Bar>

5

Page 6: Why SHOULD Java integrate XQuery? · Schema-valid (XSD, JSON Schema, SHACL, ... Example: folder resource values 2020-02-15 Greenfox 21 Resource value empty files Resource value ill-formed

A first schema,

with a folder shape

2020-02-15 Greenfox 6

Page 7: Why SHOULD Java integrate XQuery? · Schema-valid (XSD, JSON Schema, SHACL, ... Example: folder resource values 2020-02-15 Greenfox 21 Resource value empty files Resource value ill-formed

A folder shape

2020-02-15

Features to remember

(a) wildcards + min/maxCount (b) hash keys (c) closed?

Page 8: Why SHOULD Java integrate XQuery? · Schema-valid (XSD, JSON Schema, SHACL, ... Example: folder resource values 2020-02-15 Greenfox 21 Resource value empty files Resource value ill-formed

A file shape

2020-02-15 Greenfox 8

Page 9: Why SHOULD Java integrate XQuery? · Schema-valid (XSD, JSON Schema, SHACL, ... Example: folder resource values 2020-02-15 Greenfox 21 Resource value empty files Resource value ill-formed

A folder shape,

containing a file shape

2020-02-15 Greenfox 9

Page 10: Why SHOULD Java integrate XQuery? · Schema-valid (XSD, JSON Schema, SHACL, ... Example: folder resource values 2020-02-15 Greenfox 21 Resource value empty files Resource value ill-formed

Nesting shapes - subsetting

2020-02-15 Greenfox 10

Page 11: Why SHOULD Java integrate XQuery? · Schema-valid (XSD, JSON Schema, SHACL, ... Example: folder resource values 2020-02-15 Greenfox 21 Resource value empty files Resource value ill-formed

Nesting shapes –

if outer target, then inner

2020-02-15 Greenfox 11

Page 12: Why SHOULD Java integrate XQuery? · Schema-valid (XSD, JSON Schema, SHACL, ... Example: folder resource values 2020-02-15 Greenfox 21 Resource value empty files Resource value ill-formed

Validating JSON contents

2020-02-15 Greenfox 12

Page 13: Why SHOULD Java integrate XQuery? · Schema-valid (XSD, JSON Schema, SHACL, ... Example: folder resource values 2020-02-15 Greenfox 21 Resource value empty files Resource value ill-formed

Key feature #1 - XDM based

2020-02-15 Greenfox 13

Value = XDM value

- Value = sequence of items

- Item

• Atomic value (with a type from xsd)

• XDM node (element, attribute, …)

• Map or array (rarely used)

• Function item (currently not used)

Page 14: Why SHOULD Java integrate XQuery? · Schema-valid (XSD, JSON Schema, SHACL, ... Example: folder resource values 2020-02-15 Greenfox 21 Resource value empty files Resource value ill-formed

Key feature #2

Navigation skills

Between resources

Within resources

Multi-mediatype

Cross-boundary:

Start inside file, …………… || …… arrive at a file-or-folder

Start at a file-or-folder, ……|| …… arrive inside file

Start inside file A, ……....... || …… arrive inside file B

2020-02-15 Greenfox 14

XPath

foxpath

XPath - extensions

foxpath

Page 15: Why SHOULD Java integrate XQuery? · Schema-valid (XSD, JSON Schema, SHACL, ... Example: folder resource values 2020-02-15 Greenfox 21 Resource value empty files Resource value ill-formed

Key feature #3

Validation concept

2020-02-15 Greenfox 15

Page 16: Why SHOULD Java integrate XQuery? · Schema-valid (XSD, JSON Schema, SHACL, ... Example: folder resource values 2020-02-15 Greenfox 21 Resource value empty files Resource value ill-formed

Concepts

Resource file, folder

Shape a set of constraints

Constraint a condition to be checked

Resource shape checks a resource

Target declaration selects resources

Constraints check resource properties

Value shape checks a resource value

Expression constructs a resource value

Constraints check the resource value

Resourceproperty !

Resourcevalue !

Page 17: Why SHOULD Java integrate XQuery? · Schema-valid (XSD, JSON Schema, SHACL, ... Example: folder resource values 2020-02-15 Greenfox 21 Resource value empty files Resource value ill-formed

Constraints

A constraint is declared by a shape

Constraint declaration: like a function call

„function name“ = Constraint Component name

„call parameters“ = Constraint Parameter values

Validation:

Input:

parameter values

resource or resource value

Output: validation result

2020-02-15 Greenfox 17

Page 18: Why SHOULD Java integrate XQuery? · Schema-valid (XSD, JSON Schema, SHACL, ... Example: folder resource values 2020-02-15 Greenfox 21 Resource value empty files Resource value ill-formed

What a constraint perceives

2020-02-15 Greenfox 18

Resource properties

- predefinedResource values

- expression defined

- may reflect content

- may reflect surroundings

Resource

Constraint

Page 19: Why SHOULD Java integrate XQuery? · Schema-valid (XSD, JSON Schema, SHACL, ... Example: folder resource values 2020-02-15 Greenfox 21 Resource value empty files Resource value ill-formed

Constraining resource values

2020-02-15 Greenfox 19

Value shape, declaring a constraint

Validation result

Page 20: Why SHOULD Java integrate XQuery? · Schema-valid (XSD, JSON Schema, SHACL, ... Example: folder resource values 2020-02-15 Greenfox 21 Resource value empty files Resource value ill-formed

Expression tandems

2020-02-15 Greenfox 20

Page 21: Why SHOULD Java integrate XQuery? · Schema-valid (XSD, JSON Schema, SHACL, ... Example: folder resource values 2020-02-15 Greenfox 21 Resource value empty files Resource value ill-formed

Example:

folder resource values

2020-02-15 Greenfox 21

Resource value empty files

Resource value ill-formed XML

Resource value ill-formed JSON

Good folder shape

Page 22: Why SHOULD Java integrate XQuery? · Schema-valid (XSD, JSON Schema, SHACL, ... Example: folder resource values 2020-02-15 Greenfox 21 Resource value empty files Resource value ill-formed

Example:

external resource value

2020-02-15 Greenfox 22

Resource value expected return code,

fetched from a distant CSV

Page 23: Why SHOULD Java integrate XQuery? · Schema-valid (XSD, JSON Schema, SHACL, ... Example: folder resource values 2020-02-15 Greenfox 21 Resource value empty files Resource value ill-formed

Exploring files with

shifting focus nodes

2020-02-15 Greenfox 23

Page 24: Why SHOULD Java integrate XQuery? · Schema-valid (XSD, JSON Schema, SHACL, ... Example: folder resource values 2020-02-15 Greenfox 21 Resource value empty files Resource value ill-formed

Constraint components

24

Resource shapesTargetSize*, LastUpdate*, FileSize*, Mediatype*, FolderContent*, xsdValid

Value shapes I: Literal parametersitemsUnique

empty exists

count minCount maxCount

datatype

eq ne gt ge lt le

length minLength maxLength

matches notMatches

like notLike

Value shapes II: Expression valued parameterseqFoxpath neFoxpath ltFoxpath leFoxpath gtFoxpath geFoxpath

eqXPath neXPath ltXPath leXPath gtXPath geXPath

inFoxpath containsFoxpath

inXPath containsXPath

Page 25: Why SHOULD Java integrate XQuery? · Schema-valid (XSD, JSON Schema, SHACL, ... Example: folder resource values 2020-02-15 Greenfox 21 Resource value empty files Resource value ill-formed

User-defined constraints

2020-02-15 Greenfox 25

Constraint definition

Constraint declaration

Page 26: Why SHOULD Java integrate XQuery? · Schema-valid (XSD, JSON Schema, SHACL, ... Example: folder resource values 2020-02-15 Greenfox 21 Resource value empty files Resource value ill-formed

Validation chemistry

Validation report = Σ Validation results

Validation result = outcome of validating …

ONE resource against ONE constraint

2020-02-15 Greenfox 26

Page 27: Why SHOULD Java integrate XQuery? · Schema-valid (XSD, JSON Schema, SHACL, ... Example: folder resource values 2020-02-15 Greenfox 21 Resource value empty files Resource value ill-formed

Pouring waters of validity

2020-02-15 Greenfox 27

Page 28: Why SHOULD Java integrate XQuery? · Schema-valid (XSD, JSON Schema, SHACL, ... Example: folder resource values 2020-02-15 Greenfox 21 Resource value empty files Resource value ill-formed

Implementation

2020-02-15 Greenfox 28

https://github.com/hrennau/greenfox

Apologies for the incomplete documentation –

extension under construction.

Page 29: Why SHOULD Java integrate XQuery? · Schema-valid (XSD, JSON Schema, SHACL, ... Example: folder resource values 2020-02-15 Greenfox 21 Resource value empty files Resource value ill-formed

Greenfox – a summary

Goal: validation of a file system tree

Based on XDM

Powered by XPath and foxpath

Inspired by SHACL

Mediatypes hidden behind XDM node trees

Resource boundaries hidden by foxpath navigation

Producing structured information

Extensible

2020-02-15 Greenfox 29

Page 30: Why SHOULD Java integrate XQuery? · Schema-valid (XSD, JSON Schema, SHACL, ... Example: folder resource values 2020-02-15 Greenfox 21 Resource value empty files Resource value ill-formed

2020-02-15 Greenfox 30

Thank you.