why should java integrate xquery? · schema-valid (xsd, json schema, shacl, ... example: folder...
TRANSCRIPT
![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](https://reader034.vdocuments.mx/reader034/viewer/2022052423/5f0a8cb27e708231d42c2ea0/html5/thumbnails/1.jpg)
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](https://reader034.vdocuments.mx/reader034/viewer/2022052423/5f0a8cb27e708231d42c2ea0/html5/thumbnails/2.jpg)
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](https://reader034.vdocuments.mx/reader034/viewer/2022052423/5f0a8cb27e708231d42c2ea0/html5/thumbnails/3.jpg)
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](https://reader034.vdocuments.mx/reader034/viewer/2022052423/5f0a8cb27e708231d42c2ea0/html5/thumbnails/4.jpg)
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](https://reader034.vdocuments.mx/reader034/viewer/2022052423/5f0a8cb27e708231d42c2ea0/html5/thumbnails/5.jpg)
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](https://reader034.vdocuments.mx/reader034/viewer/2022052423/5f0a8cb27e708231d42c2ea0/html5/thumbnails/6.jpg)
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](https://reader034.vdocuments.mx/reader034/viewer/2022052423/5f0a8cb27e708231d42c2ea0/html5/thumbnails/7.jpg)
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](https://reader034.vdocuments.mx/reader034/viewer/2022052423/5f0a8cb27e708231d42c2ea0/html5/thumbnails/8.jpg)
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](https://reader034.vdocuments.mx/reader034/viewer/2022052423/5f0a8cb27e708231d42c2ea0/html5/thumbnails/9.jpg)
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](https://reader034.vdocuments.mx/reader034/viewer/2022052423/5f0a8cb27e708231d42c2ea0/html5/thumbnails/10.jpg)
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](https://reader034.vdocuments.mx/reader034/viewer/2022052423/5f0a8cb27e708231d42c2ea0/html5/thumbnails/11.jpg)
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](https://reader034.vdocuments.mx/reader034/viewer/2022052423/5f0a8cb27e708231d42c2ea0/html5/thumbnails/12.jpg)
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](https://reader034.vdocuments.mx/reader034/viewer/2022052423/5f0a8cb27e708231d42c2ea0/html5/thumbnails/13.jpg)
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](https://reader034.vdocuments.mx/reader034/viewer/2022052423/5f0a8cb27e708231d42c2ea0/html5/thumbnails/14.jpg)
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](https://reader034.vdocuments.mx/reader034/viewer/2022052423/5f0a8cb27e708231d42c2ea0/html5/thumbnails/15.jpg)
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](https://reader034.vdocuments.mx/reader034/viewer/2022052423/5f0a8cb27e708231d42c2ea0/html5/thumbnails/16.jpg)
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](https://reader034.vdocuments.mx/reader034/viewer/2022052423/5f0a8cb27e708231d42c2ea0/html5/thumbnails/17.jpg)
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](https://reader034.vdocuments.mx/reader034/viewer/2022052423/5f0a8cb27e708231d42c2ea0/html5/thumbnails/18.jpg)
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](https://reader034.vdocuments.mx/reader034/viewer/2022052423/5f0a8cb27e708231d42c2ea0/html5/thumbnails/19.jpg)
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](https://reader034.vdocuments.mx/reader034/viewer/2022052423/5f0a8cb27e708231d42c2ea0/html5/thumbnails/20.jpg)
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](https://reader034.vdocuments.mx/reader034/viewer/2022052423/5f0a8cb27e708231d42c2ea0/html5/thumbnails/21.jpg)
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](https://reader034.vdocuments.mx/reader034/viewer/2022052423/5f0a8cb27e708231d42c2ea0/html5/thumbnails/22.jpg)
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](https://reader034.vdocuments.mx/reader034/viewer/2022052423/5f0a8cb27e708231d42c2ea0/html5/thumbnails/23.jpg)
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](https://reader034.vdocuments.mx/reader034/viewer/2022052423/5f0a8cb27e708231d42c2ea0/html5/thumbnails/24.jpg)
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](https://reader034.vdocuments.mx/reader034/viewer/2022052423/5f0a8cb27e708231d42c2ea0/html5/thumbnails/25.jpg)
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](https://reader034.vdocuments.mx/reader034/viewer/2022052423/5f0a8cb27e708231d42c2ea0/html5/thumbnails/26.jpg)
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](https://reader034.vdocuments.mx/reader034/viewer/2022052423/5f0a8cb27e708231d42c2ea0/html5/thumbnails/27.jpg)
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](https://reader034.vdocuments.mx/reader034/viewer/2022052423/5f0a8cb27e708231d42c2ea0/html5/thumbnails/28.jpg)
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](https://reader034.vdocuments.mx/reader034/viewer/2022052423/5f0a8cb27e708231d42c2ea0/html5/thumbnails/29.jpg)
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](https://reader034.vdocuments.mx/reader034/viewer/2022052423/5f0a8cb27e708231d42c2ea0/html5/thumbnails/30.jpg)
2020-02-15 Greenfox 30
Thank you.