SlideShare a Scribd company logo
Introduction to
ISO SCHEMATRON
© 2019 Syncro Soft SRL. All rights reserved
Octavian Nadolu, Syncro Soft
octavian_nadolu@oxygenxml.com
@OctavianNadolu
Introduction to ISO SchematronIntroduction to ISO Schematron
Software Architect at Syncro Soft
octavian.nadolu@oxygenxml.com
• 15+ years of XML technology experience
• Contributor for various XML-related open source projects
• Editor of Schematron QuickFix specification developed by a W3C
community group
About me
Introduction to ISO SchematronIntroduction to ISO Schematron
Agenda
● ISO Schematron history
● ISO Schematron introduction
● XPath in ISO Schematron
● Schematron in the development process
● Schematron for technical and non-
technical users
● Schematron Quick Fixes
Introduction to ISO SchematronIntroduction to ISO Schematron
What is Schematron?
A natural language for making assertions in documents
Introduction to ISO SchematronIntroduction to ISO Schematron
Schematron is an ISO Standard
Schematron is an ISO standard adopted by hundreds of major
projects in the past decade
Introduction to ISO SchematronIntroduction to ISO Schematron
Schematron History
Schematron was invented by
Rick Jelliffe
● Schematron 1.0 (1999), 1.3
(2000), 1.5 (2001)
● ISO Schematron (2006, 2010,
2016)
Introduction to ISO SchematronIntroduction to ISO Schematron
Why Schematron?
You can express constraints in a way that
you cannot perform with other schemas
(like XSD, RNG, or DTD).
● XSD, RNG, and DTD schemas define
structural aspects and data types of
the XML documents
● Schematron allows you to create
custom rules specific to your project
Introduction to ISO SchematronIntroduction to ISO Schematron
Schematron Usage
● Verify data inter-dependencies
● Check data cardinality
● Perform algorithmic checks
Introduction to ISO SchematronIntroduction to ISO Schematron
Used in Multiple Domains
● Financial
● Insurance
● Government
● Technical publishing
Introduction to ISO SchematronIntroduction to ISO Schematron
Schematron is Very Simple
There are only 6 basic elements:
assert
report
rule
pattern
schema
ns
Introduction to ISO SchematronIntroduction to ISO Schematron
Schematron Step-by-Step
Introduction to ISO SchematronIntroduction to ISO Schematron
XML
A list of books from a bookstore:
...
<book price="7">
<title>XSLT 2.0 Programmer's Reference</title>
<author>Michael Kay</author>
<isbn>0764569090</isbn>
</book>
<book price="1100">
<title>XSLT and XPath On The Edge</title>
<author>Jeni Tennison</author>
<isbn>0764547763 </isbn>
</book>
...
Introduction to ISO SchematronIntroduction to ISO Schematron
<assert>
An assert generates a message when a test statement evaluates
to false
<assert test="@price > 10">The book price is too small</assert>
Introduction to ISO SchematronIntroduction to ISO Schematron
<report>
A report generates a message when a test statement evaluate
to true.
<report test="@price > 1000">The book price is too big</report>
Introduction to ISO SchematronIntroduction to ISO Schematron
<rule>
A rule defines a context on which a list of assertions will be
tested, and is comprised of one or more assert or report
elements.
<rule context="book">
<assert test="@price > 10">The book price is too small</assert>
<report test="@price > 1000">The book price is too big</report>
</rule>
Introduction to ISO SchematronIntroduction to ISO Schematron
<pattern>
A set of rules giving constraints that are in some way related
<pattern>
<rule context="book">
<assert test="@price > 10">The book price is too small</assert>
<report test="@price > 1000">The book price is too big</report>
</rule>
</pattern>
Introduction to ISO SchematronIntroduction to ISO Schematron
<schema>
The top-level element of a Schematron schema.
<schema xmlns="http://purl.oclc.org/dsdl/schematron">
<pattern>
<rule context="book">
<assert test="@price > 10">The book price is too small</assert>
<report test="@price > 1000">The book price is too big</report>
</rule>
</pattern>
</schema>
Introduction to ISO SchematronIntroduction to ISO Schematron
Apply Schematron
<schema xmlns="http://purl.oclc.org/dsdl/schematron">
<pattern>
<rule context="book">
<assert test="@price > 10">The book price is too small</assert>
<report test="@price > 1000">The book price is too big</report>
</rule>
</pattern>
</schema>
...
<book price="7">
<title>XSLT 2.0 Programmer's Reference</title>
<author>Michael Kay</author>
<isbn>0764569090</isbn>
</book>
<book price="1100">
<title>XSLT and XPath On The Edge</title>
<author>Jeni Tennison</author>
<isbn>0764547763</isbn>
</book>
...
The price is too small
The book price is too big
Validate
Introduction to ISO SchematronIntroduction to ISO Schematron
<ns>
Defines a namespace prefix and URI
<schema xmlns="http://purl.oclc.org/dsdl/schematron">
<ns uri="http://book.example.com" prefix="b"/>
<pattern>
<rule context="b:book">
<assert test="@price > 10">The book price is too small</assert>
<report test="@price > 1000">The book price is too big</report>
</rule>
</pattern>
</schema>
Introduction to ISO SchematronIntroduction to ISO Schematron
Conclusion
● Schematron is simple (6 basic elements)
● Used in multiple domains
● Schematron uses XPath
Introduction to ISO SchematronIntroduction to ISO Schematron
//* XPath in Schematron
Introduction to ISO SchematronIntroduction to ISO Schematron
What is XPath?
● A language for addressing parts of an
XML document (XML Path Language)
● A W3C Recommendation in 1999
www.w3.org/TR/xpath
● XPath versions 1.0, 2.0, 3.0, 3.1 (2017)
Introduction to ISO SchematronIntroduction to ISO Schematron
Schematron Uses XPath
● XPath in Schematron:
– Rule context is expressed using an XPath expression
<rule context="book">
– Assertions are expressed using XPath expressions that are
evaluated as true or false
<assert test="@price > 10">
Introduction to ISO SchematronIntroduction to ISO Schematron
Basic XPath Syntax
● nodeName – select node with a specific name
● / - level selector
● // - multi-level selector
● ../ - level up selector
● @ - attribute selector
Introduction to ISO SchematronIntroduction to ISO Schematron
Examples
● book – select all nodes with the name “book”
● /books/book – selects all the “book” elements that are in the
“books” root element
● book/title – selects the “title” elements for all the books
● /books//title – selects all the “title” elements from the “books”
● @price – selects all the price attributes
Introduction to ISO SchematronIntroduction to ISO Schematron
Schematron Example
<rule context="/books/book">
<assert test="@price > 10">The book price is too small</assert>
</rule>
<rule context="/books/book/@price">
<assert test=". > 10">The book price is too small</assert>
</rule>
Introduction to ISO SchematronIntroduction to ISO Schematron
Predicates
Condition in square brakes
● //book[2] – selects the second book element
● book[@price &lt; 10] – selects all the book elements with
the price less than(lt) 10
● book[last()] - selects the last book element
● book[@price>1000]/author - selects all the “author”
elements that are in a book with the price grater than(gt)
1000
Introduction to ISO SchematronIntroduction to ISO Schematron
Schematron Example
<rule context="book[@price>1000]/author">
<assert test="text() = 'Jeni Tennison'">
Only 'Jeni Tennison' books can have bigger price</assert>
</rule>
<rule context="book[@price lt 10] ">
<assert test="false()">The book price is too small</assert>
</rule>
Introduction to ISO SchematronIntroduction to ISO Schematron
Wildcards
* - any element node selector
@* - any attribute node selector
node() - any node selector
Introduction to ISO SchematronIntroduction to ISO Schematron
Wildcards Examples
//* - selects all the elements from the document
//book[@*] - selects all the book elements that have an
attribute
//book/* - selects all the elements from the book
Introduction to ISO SchematronIntroduction to ISO Schematron
XPath Functions
● For strings: concat(), substring(), contains(), substring-before(),
substring-after(), translate(), normalize-space(), string-length()
● For numbers: sum(), round(), floor(), ceiling()
● Node Properties: name(), local-name(), namespace-uri()
Introduction to ISO SchematronIntroduction to ISO Schematron
Schematron Example
<rule context="book/title">
<assert test="string-length(text()) lt 30">
Titles should be less than 30 characters</assert>
</rule>
<rule context="books">
<report test="sum(book/@price) > 10000">
The books price is too big</report>
</rule>
Introduction to ISO SchematronIntroduction to ISO Schematron
XPath Version in Schematron
● @queryBinding – determines the XPath version
<schema queryBinding="xslt2">
Possible values: xslt, xslt2, xslt3
Introduction to ISO SchematronIntroduction to ISO Schematron
Conclusion
● XPath it is very important in Schematron
● Used in rule context and assertions
● Different XPath versions
● Tutorials:
– www.data2type.de/en/xml-xslt-xslfo/xpath/
– www.xfront.com/xpath/
– www.zvon.org/comp/m/xpath.html
Introduction to ISO SchematronIntroduction to ISO Schematron
Examples of Rules
Introduction to ISO SchematronIntroduction to ISO Schematron
Check Number of List Items
● Example of a rule that checks the number of list items in a
list
A list must have more than one item
Introduction to ISO SchematronIntroduction to ISO Schematron
Check Number of List Items
● The number of list items from an unordered list should be
greater than one
<sch:rule context="ul">
<sch:assert test="count(li) > 1">
A list must have more than one item</sch:assert>
</sch:rule>
Introduction to ISO SchematronIntroduction to ISO Schematron
Styling in Titles
● Example rule that checks for styling in titles
Bold is not allowed in title element
Introduction to ISO SchematronIntroduction to ISO Schematron
Styling in Titles
● The b element should not be used in a title or short
description
<sch:rule context="title | shortdesc">
<sch:report test="b">
Bold is not allowed in <sch:name/> element</sch:report>
</sch:rule>
Introduction to ISO SchematronIntroduction to ISO Schematron
Semicolon at End of List Items
● Example of rule that checks if a semicolon is at the end of a
list item
Semicolon is not allowed at the end of a list item
Introduction to ISO SchematronIntroduction to ISO Schematron
Semicolon at End of List Items
● The last text from a list item should not end with semicolon
<sch:rule context="li">
<sch:report test="ends-with(text()[last()], ';')">
Semicolon is not allowed after list item</sch:report>
</sch:rule>
Introduction to ISO SchematronIntroduction to ISO Schematron
Check External Link Protocol
● Example of rule that check the external link protocol
The external link should start with http(s)
Introduction to ISO SchematronIntroduction to ISO Schematron
Check External Link Protocol
● The @href attribute value it is an external link and
should start with http or https.
<rule context="xref">
<sch:assert test="matches(@href, '^http(s?)://')">
An link should start with http(s).</sch:assert>
</rule>
Introduction to ISO SchematronIntroduction to ISO Schematron
Missing Tables Cells
● Missing cells in a table
Cells are missing from table
Introduction to ISO SchematronIntroduction to ISO Schematron
Missing Tables Cells
● Check that are the same number of cells on each row
<sch:rule context="table">
<sch:let name="minColumsNo" value="min(.//row/count(entry))"/>
<sch:let name="reqColumsNo" value="max(.//row/count(entry))"/>
<sch:assert test="$minColumsNo >= $reqColumsNo">
Cells are missing. (The number of cells for each row must be
<sch:value-of select="$reqColumsNo"/>)
</sch:assert>
</sch:rule>
Introduction to ISO SchematronIntroduction to ISO Schematron
Link in Text Content
● Links are added directly in text content
Link detected in the current element
Introduction to ISO SchematronIntroduction to ISO Schematron
Link in Text Content
● Check if a link is added in text content but is not tagged as a
link
<sch:rule context="text()">
<sch:report test="matches(., '(http|www)S+')
and local-name(parent::node()) != 'xref'">
The link should be a xref element</sch:report>
</sch:rule>
Introduction to ISO SchematronIntroduction to ISO Schematron
Conclusion
● Simple to complex
Schematron rules
● Additional Schematron
elements
<let> - A declaration of a named
variable
<value-of> - Finds or calculates
values from the instance
document
<name> - Provides the names of
nodes from the instance
document
Introduction to ISO SchematronIntroduction to ISO Schematron
Integrating Schematron in the Development Process
Introduction to ISO SchematronIntroduction to ISO Schematron
Validate XML with Schematron
● Associate Schematron in the XML file
● Use tool-specific association options
– Associate Schematron file with a set of XML files (all files with a
specific namespace, or from a directory)
– Associate Schematron with all XML files from a project
<?xml-model href="books.sch" type="application/xml"
schematypens="http://purl.oclc.org/dsdl/schematron"?>
Introduction to ISO SchematronIntroduction to ISO Schematron
Embed Schematron in XSD or RNG
● Schematron can be added in the XSD appinfo element
● Add Schematron checks in any element on any level of an
RNG schema
Introduction to ISO SchematronIntroduction to ISO Schematron
Run Schematron Validation
● From an XML editing framework
– Check the XML files as you type
– Run the Schematron validation on multiple files
● Using W3C's XProc pipeline language through its "validate-
with-schematron" step
● Using Apache Ant, from bat/shell
https://github.com/Schematron/ant-schematron
Introduction to ISO SchematronIntroduction to ISO Schematron
Schematron Validation Result
● Messages presented in the editing framework
● As an XML file describing the validation errors, normally in
Schematron Validation Reporting Language (SVRL)
<svrl:failed-assert test="matches(@href, '^http(s?)://')" role="warn"
location="/topic[1]/body[1]/section[1]/p[3]/xref[1]">
<svrl:text>An external link should start with http(s).</svrl:text>
</svrl:failed-assert>
Introduction to ISO SchematronIntroduction to ISO Schematron
Schematron Messages Severity
● Severity level can be set in the value of the @role attribute from
an assert or report element (fatal, error, warn, or info)
● Depending on the severity, the message can be rendered
differently in an editing framework
Introduction to ISO SchematronIntroduction to ISO Schematron
Multilingual Support in Schematron
● Based on the Schematron diagnostic element
● A diagnostic element is used for each language
● Multilingual support defined in the Schematron
specification
<sch:assert test="bone" diagnostics="d_en d_de">
A dog should have a bone.
</sch:assert>
….
<sch:diagnostics xml:lang="en">
<sch:diagnostic id="d_en">A dog should have a bone.<sch:diagnostic>
</sch:diagnostics>
<sch:diagnostics xml:lang="de">
<sch:diagnostic id="d_de">Das Hund muss ein Bein haben.</sch:diagnostic>
</sch:diagnostics>
Introduction to ISO SchematronIntroduction to ISO Schematron
Conclusion
● Multiple ways to associate and apply the
validation
● Validation results as you type or in a
report
● Messages with different severity
● Multilingual support
Introduction to ISO SchematronIntroduction to ISO Schematron
Schematron for
Non-Technical Users
Introduction to ISO SchematronIntroduction to ISO Schematron
Create Rules
● There are more and more non-technical users that want to
develop their own rules
● Providing a user interface to create the Schematron rules will
be more appropriate for them
Introduction to ISO SchematronIntroduction to ISO Schematron
Auto-Generate Schematron Rules
● A style guide can contain information to automate the style
guide checks
● An automated rule is an instantiation of a generic rule
Introduction to ISO SchematronIntroduction to ISO Schematron
Intelligent Integrated Style Guide
● An implementation of an intelligent style guide
● Describes and enforces rules
● Open-source project is available on GitHub
github.com/oxygenxml/integrated-styleguide
Introduction to ISO SchematronIntroduction to ISO Schematron
Library of Rules
● Generic rules can be created using a library of rules
● The user can choose the rule that he wants to add
Avoid a word in a certain element
Limit the number of words
Avoid duplicate content
Introduction to ISO SchematronIntroduction to ISO Schematron
Abstract Patterns
Library of rules implemented using abstract patterns
AvoidWordInElement
LimitNoCharacters
AvoidDuplicateContent
Schematron rules
generate
Introduction to ISO SchematronIntroduction to ISO Schematron
Abstract Pattern
● Allows to reuse patterns by making them generic
<pattern id="LimitNoOfWords" abstract="true">
<rule context="$parentElement">
<let name="words" value="count(tokenize(normalize-space(.), ' '))"/>
<assert test="$words le $maxWords">
$message You have <value-of select="$words"/> word(s).
</assert>
<assert test="$words ge $minWords">
$message You have <value-of select="$words"/> word(s).
</assert>
</rule>
</pattern>
Introduction to ISO SchematronIntroduction to ISO Schematron
Pattern Instantiation
● Refer an abstract pattern and specifies values for
parameters
<pattern is-a="LimitNoOfWords">
<param name="parentElement" value="shortdesc"/>
<param name="minWords" value="1"/>
<param name="maxWords" value="50"/>
<param name="message" value="Keep short descriptions between 1 and 50 words!"/>
</pattern>
<pattern is-a="LimitNoOfWords">
<param name="parentElement" value="title"/>
<param name="minWords" value="1"/>
<param name="maxWords" value="8"/>
<param name="message" value="Keep titles between 1 and 8 words."/>
</pattern>
Introduction to ISO SchematronIntroduction to ISO Schematron
Chatbot to Generate Schematron
Introduction to ISO SchematronIntroduction to ISO Schematron
Generate Schematron Patterns
66
<sch:pattern is-a="limitElement">
<sch:param name="element" value="p"/>
<sch:param name="limit" value="maximum"/>
<sch:param name="size" value="100"/>
<sch:param name="unit" value="words"/>
<sch:param name="message" value="p should contain maximum 100 words"/>
</sch:pattern>
l
“Paragraphs should have less than 100 words”
Introduction to ISO SchematronIntroduction to ISO Schematron
Schematron for Technical Users
Introduction to ISO SchematronIntroduction to ISO Schematron
Environment to Develop Schematron Schemas
– Editor
– Validation
– Search and refactoring
– Working with modules
– Unit testing
Introduction to ISO SchematronIntroduction to ISO Schematron
Editor
● Syntax highlighting - to improve the readability of the
content
● Content completion assistant - offering proposals that are
valid at the cursor position
● Documentation - with information about the particular
proposal
Introduction to ISO SchematronIntroduction to ISO Schematron
Validate
● Validate Schematron schemas, and highlight problems
directly in the editor
● Validate Schematron modules in context
● Support for validation as you type
Introduction to ISO SchematronIntroduction to ISO Schematron
Search and Refactoring
● Find references to variables, pattern, phases, or diagnostics
● Support for renaming all references from the current
document, or in the entire hierarchy
● Preview the changes
Introduction to ISO SchematronIntroduction to ISO Schematron
Working with Modules
● Visualize the hierarchy of modules
● Support for editing a Schematron module in the context
● Moving and renaming modules
Introduction to ISO SchematronIntroduction to ISO Schematron
Test Schematron Rules
● Developing Schematron schema also involves testing
● Make sure Schematron rules work as expected
● Apply multiple XML examples over the Schematron rules and
check the results
Introduction to ISO SchematronIntroduction to ISO Schematron
XSpec
● Solution to create Schematron unit tests
● Unit test and BDD (Behaviour Driven Development )
framework
● https://github.com/xspec/xspec/
● Oxygen XSpec Helper View plugin
● github.com/xspec/oXygen-XML-editor-xspec-support
● Tutorials
– github.com/xspec/xspec/wiki/Getting-Started-with-XSpec-and-Schematron
– oxygenxml.com/events/2018/webinar_xspec_unit_testing_for_xslt_and_schematron.h
tml
Introduction to ISO SchematronIntroduction to ISO Schematron
Conclusion
● User interface for non-technical users
● Library of rules using abstract patterns
● Editing, validation, and refactoring for
technical users
● Test cases for Schematron
Introduction to ISO SchematronIntroduction to ISO Schematron
Schematron Quick Fixes
Introduction to ISO SchematronIntroduction to ISO Schematron
Schematron Fix Proposals
● Schematron assertion messages are not always enough for
the user to find a solution
● It is better to have some proposals to correct the
Schematron reported problem
● Similar to spell check proposals
Introduction to ISO SchematronIntroduction to ISO Schematron
Schematron Quick Fix Proposals
● User-defined fixes for Schematron errors
● Schematron Quick Fix (SQF) language
– Extension of the Schematron language
– SQF initiated by Nico Kutscherauer
www.schematron-quickfix.com
github.com/schematron-quickfix/sqf
Introduction to ISO SchematronIntroduction to ISO Schematron
Schematron Quick Fixes Spec
www.w3.org/community/quickfix
schematron-quickfix.github.io/sqf
Introduction to ISO SchematronIntroduction to ISO Schematron
SQF Extension of Schematron
● Added as Schematron annotations
● Associate fixes with assert and report elements
<rule context="title">
<report test="b" sqf:fix="resolveBold">
Bold is not allowed in title element</report>
<sqf:fix id="resolveBold">
<sqf:description>
<sqf:title>Change the bold element into text</sqf:title>
<sqf:p>Removes the bold (b) markup and keeps the text content.</sqf:p>
</sqf:description>
<sqf:replace match="b" select="node()"/>
</sqf:fix>
</rule>
Introduction to ISO SchematronIntroduction to ISO Schematron
Schematron Quick Fix (SQF)
<sqf:fix id="resolveBold">
<sqf:description>
<sqf:title>Change the bold element into text</sqf:title>
<sqf:p>Removes the bold (b) markup and keeps the text content.</sqf:p>
</sqf:description>
<sqf:replace match="b" select="node()"/>
</sqf:fix>
Operation
ID
Description
Title
Introduction to ISO SchematronIntroduction to ISO Schematron
SQF Operations
The following 4 types of operations are supported:
● <sqf:add> - To add a new node or fragment in the document
● <sqf:delete> - To remove a node from the document
● <sqf:replace> - To replace a node with another node or fragment
● <sqf:stringReplace> - To replace text content with other text or a fragment
Introduction to ISO SchematronIntroduction to ISO Schematron
Introduction to SQF Through Examples
Introduction to ISO SchematronIntroduction to ISO Schematron
1. SQF “add” Operation
● Example of using the “add” operation: add new list item in
a list
List contains only one item
Add new list item
Introduction to ISO SchematronIntroduction to ISO Schematron
1. SQF “add” Operation
● <sqf:add> element allows you to add one or more nodes to
the XML instance
<rule context="ul">
<assert test="count(li) > 1" sqf:fix="addListItem">A list must have more
than one item.</assert>
<sqf:fix id="addListItem">
<sqf:description>
<sqf:title>Add new list item</sqf:title>
</sqf:description>
<sqf:add node-type="element" target="li" position="last-child"/>
</sqf:fix>
</rule>
Introduction to ISO SchematronIntroduction to ISO Schematron
2. SQF “delete” Operation
● Example of using the “delete” operation: remove redundant
link text
Remove redundant link text
Text in the link and the value of the @href are the same
Introduction to ISO SchematronIntroduction to ISO Schematron
2. SQF “delete” Operation
● <sqf:delete> element specifies the nodes for the deletion
<rule context="xref">
<report test="@href = text()" sqf:fix="removeText">
Link text is same as @href attribute value. Please remove.</report>
<sqf:fix id="removeText">
<sqf:description>
<sqf:title>Remove redundant link text</sqf:title>
</sqf:description>
<sqf:delete match="text()"/>
</sqf:fix>
</rule>
Introduction to ISO SchematronIntroduction to ISO Schematron
3. SQF “replace” Operation
● Example of using the “replace” operation: replace bold
element with text
Change the bold into text
Styling is not allowed in titles
Introduction to ISO SchematronIntroduction to ISO Schematron
3. SQF “replace” Operation
● <sqf:replace> element specifies the nodes to be replaced
and the replacing content
<rule context="title">
<report test="b" sqf:fix="resolveBold">
Bold is not allowed in title element.</report>
<sqf:fix id="resolveBold">
<sqf:description>
<sqf:title>Change the bold into text</sqf:title>
</sqf:description>
<sqf:replace match="b" select="node()"/>
</sqf:fix>
</rule>
Introduction to ISO SchematronIntroduction to ISO Schematron
4. SQF “stringReplace” Operation
● Example of using the “stringReplace” operation: replace
semicolon with full stop
Replace semicolon with full stop
Semicolon is not allowed at the end of a list item
Introduction to ISO SchematronIntroduction to ISO Schematron
4. SQF “stringReplace” Operation
● <sqf:stringReplace> element defines the nodes that will
replace the substrings
<rule context="li">
<report test="ends-with(text()[last()], ';')" sqf:fix="replaceSemicolon">
Semicolon is not allowed after list item</report>
<sqf:fix id="replaceSemicolon">
<sqf:description>
<sqf:title>Replace semicolon with full stop</sqf:title>
</sqf:description>
<sqf:stringReplace match="text()[last()]" regex=";$" select="'.'"/>
</sqf:fix>
</rule>
Introduction to ISO SchematronIntroduction to ISO Schematron
Conclusions
● Schematron Quick Fix language is simple
● You can define custom fixes for your project
● Just 4 types of operations
Introduction to ISO SchematronIntroduction to ISO Schematron
SQF Implementations
● <oXygen/> XML Editor validation engine
http://www.oxygenxml.com
● Escali Schematron engine
http://schematron-quickfix.com/escali_xsm.html
– Escali Schematron command-line tool
– Oxygen plugin for invoking Escali Schematron
Introduction to ISO SchematronIntroduction to ISO Schematron
Projects Using SQF
● Thieme - publishing company uses a custom framework to
create and edit XML documents
● parsX - a product developed by pagina GmbH used to
facilitate EPUB production
● ART-DECOR - an open-source tool suite that supports SDOs
active in the healthcare industry
Sample SQF embedded in XSD
● ATX custom framework – used by a major automotive
manufacturer
Introduction to ISO SchematronIntroduction to ISO Schematron
Resources
● Schematron official site
● Schematron specification
● Schematron Quick Fix specification
Sample files:
github.com/octavianN/Schematron-step-by-step
Questions?
Octavian Nadolu
Software Architect at Syncro Soft
octavian.nadolu@oxygenxml.com
Twitter: @OctavianNadolu
LinkedIn: octaviannadolu
https://sundt04.honestly.de

More Related Content

What's hot

Java Multithreading Using Executors Framework
Java Multithreading Using Executors FrameworkJava Multithreading Using Executors Framework
Java Multithreading Using Executors Framework
Arun Mehra
 
How to GraphQL
How to GraphQLHow to GraphQL
How to GraphQL
Tomasz Bak
 
Form認証で学ぶSpring Security入門
Form認証で学ぶSpring Security入門Form認証で学ぶSpring Security入門
Form認証で学ぶSpring Security入門
Ryosuke Uchitate
 
RESTful Web アプリの設計レビューの話
RESTful Web アプリの設計レビューの話RESTful Web アプリの設計レビューの話
RESTful Web アプリの設計レビューの話
Takuto Wada
 
Spring boot
Spring bootSpring boot
Spring boot
Bhagwat Kumar
 
Spring Interview Questions and Answers | Spring Tutorial | Spring Framework T...
Spring Interview Questions and Answers | Spring Tutorial | Spring Framework T...Spring Interview Questions and Answers | Spring Tutorial | Spring Framework T...
Spring Interview Questions and Answers | Spring Tutorial | Spring Framework T...
Edureka!
 
Python File Handling | File Operations in Python | Learn python programming |...
Python File Handling | File Operations in Python | Learn python programming |...Python File Handling | File Operations in Python | Learn python programming |...
Python File Handling | File Operations in Python | Learn python programming |...
Edureka!
 
Helidon 概要
Helidon 概要Helidon 概要
Introduction to Javascript
Introduction to JavascriptIntroduction to Javascript
Introduction to Javascript
Amit Tyagi
 
Spring Bootでチャットツールを作りながらWebの仕組みを理解しよう!
Spring Bootでチャットツールを作りながらWebの仕組みを理解しよう!Spring Bootでチャットツールを作りながらWebの仕組みを理解しよう!
Spring Bootでチャットツールを作りながらWebの仕組みを理解しよう!
Java女子部
 
JJUG CCC 2015 Spring 「新人エンジニア奮闘記 - Javaって何?からwebサービスを公開するまで -」発表スライド
JJUG CCC 2015 Spring 「新人エンジニア奮闘記 - Javaって何?からwebサービスを公開するまで -」発表スライドJJUG CCC 2015 Spring 「新人エンジニア奮闘記 - Javaって何?からwebサービスを公開するまで -」発表スライド
JJUG CCC 2015 Spring 「新人エンジニア奮闘記 - Javaって何?からwebサービスを公開するまで -」発表スライド
ToshiakiArai
 
Php.ppt
Php.pptPhp.ppt
Php.ppt
Nidhi mishra
 
JSRとJEPとJBSの見方や調べ方について
JSRとJEPとJBSの見方や調べ方についてJSRとJEPとJBSの見方や調べ方について
JSRとJEPとJBSの見方や調べ方について
Aya Ebata
 
Django Rest Framework | How to Create a RESTful API Using Django | Django Tut...
Django Rest Framework | How to Create a RESTful API Using Django | Django Tut...Django Rest Framework | How to Create a RESTful API Using Django | Django Tut...
Django Rest Framework | How to Create a RESTful API Using Django | Django Tut...
Edureka!
 
Object Oriented Programming In JavaScript
Object Oriented Programming In JavaScriptObject Oriented Programming In JavaScript
Object Oriented Programming In JavaScript
Forziatech
 
スローダウン、ハングを一発解決 スレッドダンプはトラブルシューティングの味方 #wlstudy
スローダウン、ハングを一発解決 スレッドダンプはトラブルシューティングの味方 #wlstudyスローダウン、ハングを一発解決 スレッドダンプはトラブルシューティングの味方 #wlstudy
スローダウン、ハングを一発解決 スレッドダンプはトラブルシューティングの味方 #wlstudyYusuke Yamamoto
 
What Is Spring Framework In Java | Spring Framework Tutorial For Beginners Wi...
What Is Spring Framework In Java | Spring Framework Tutorial For Beginners Wi...What Is Spring Framework In Java | Spring Framework Tutorial For Beginners Wi...
What Is Spring Framework In Java | Spring Framework Tutorial For Beginners Wi...
Edureka!
 
初心者向けMroonga・PGroonga情報
初心者向けMroonga・PGroonga情報初心者向けMroonga・PGroonga情報
初心者向けMroonga・PGroonga情報
Kouhei Sutou
 
L13 string handling(string class)
L13 string handling(string class)L13 string handling(string class)
L13 string handling(string class)
teach4uin
 
Files and streams In Java
Files and streams In JavaFiles and streams In Java
Files and streams In Java
Rajan Shah
 

What's hot (20)

Java Multithreading Using Executors Framework
Java Multithreading Using Executors FrameworkJava Multithreading Using Executors Framework
Java Multithreading Using Executors Framework
 
How to GraphQL
How to GraphQLHow to GraphQL
How to GraphQL
 
Form認証で学ぶSpring Security入門
Form認証で学ぶSpring Security入門Form認証で学ぶSpring Security入門
Form認証で学ぶSpring Security入門
 
RESTful Web アプリの設計レビューの話
RESTful Web アプリの設計レビューの話RESTful Web アプリの設計レビューの話
RESTful Web アプリの設計レビューの話
 
Spring boot
Spring bootSpring boot
Spring boot
 
Spring Interview Questions and Answers | Spring Tutorial | Spring Framework T...
Spring Interview Questions and Answers | Spring Tutorial | Spring Framework T...Spring Interview Questions and Answers | Spring Tutorial | Spring Framework T...
Spring Interview Questions and Answers | Spring Tutorial | Spring Framework T...
 
Python File Handling | File Operations in Python | Learn python programming |...
Python File Handling | File Operations in Python | Learn python programming |...Python File Handling | File Operations in Python | Learn python programming |...
Python File Handling | File Operations in Python | Learn python programming |...
 
Helidon 概要
Helidon 概要Helidon 概要
Helidon 概要
 
Introduction to Javascript
Introduction to JavascriptIntroduction to Javascript
Introduction to Javascript
 
Spring Bootでチャットツールを作りながらWebの仕組みを理解しよう!
Spring Bootでチャットツールを作りながらWebの仕組みを理解しよう!Spring Bootでチャットツールを作りながらWebの仕組みを理解しよう!
Spring Bootでチャットツールを作りながらWebの仕組みを理解しよう!
 
JJUG CCC 2015 Spring 「新人エンジニア奮闘記 - Javaって何?からwebサービスを公開するまで -」発表スライド
JJUG CCC 2015 Spring 「新人エンジニア奮闘記 - Javaって何?からwebサービスを公開するまで -」発表スライドJJUG CCC 2015 Spring 「新人エンジニア奮闘記 - Javaって何?からwebサービスを公開するまで -」発表スライド
JJUG CCC 2015 Spring 「新人エンジニア奮闘記 - Javaって何?からwebサービスを公開するまで -」発表スライド
 
Php.ppt
Php.pptPhp.ppt
Php.ppt
 
JSRとJEPとJBSの見方や調べ方について
JSRとJEPとJBSの見方や調べ方についてJSRとJEPとJBSの見方や調べ方について
JSRとJEPとJBSの見方や調べ方について
 
Django Rest Framework | How to Create a RESTful API Using Django | Django Tut...
Django Rest Framework | How to Create a RESTful API Using Django | Django Tut...Django Rest Framework | How to Create a RESTful API Using Django | Django Tut...
Django Rest Framework | How to Create a RESTful API Using Django | Django Tut...
 
Object Oriented Programming In JavaScript
Object Oriented Programming In JavaScriptObject Oriented Programming In JavaScript
Object Oriented Programming In JavaScript
 
スローダウン、ハングを一発解決 スレッドダンプはトラブルシューティングの味方 #wlstudy
スローダウン、ハングを一発解決 スレッドダンプはトラブルシューティングの味方 #wlstudyスローダウン、ハングを一発解決 スレッドダンプはトラブルシューティングの味方 #wlstudy
スローダウン、ハングを一発解決 スレッドダンプはトラブルシューティングの味方 #wlstudy
 
What Is Spring Framework In Java | Spring Framework Tutorial For Beginners Wi...
What Is Spring Framework In Java | Spring Framework Tutorial For Beginners Wi...What Is Spring Framework In Java | Spring Framework Tutorial For Beginners Wi...
What Is Spring Framework In Java | Spring Framework Tutorial For Beginners Wi...
 
初心者向けMroonga・PGroonga情報
初心者向けMroonga・PGroonga情報初心者向けMroonga・PGroonga情報
初心者向けMroonga・PGroonga情報
 
L13 string handling(string class)
L13 string handling(string class)L13 string handling(string class)
L13 string handling(string class)
 
Files and streams In Java
Files and streams In JavaFiles and streams In Java
Files and streams In Java
 

Similar to Introduction to Schematron

03 x files
03 x files03 x files
03 x files
Baskarkncet
 
The Ring programming language version 1.6 book - Part 16 of 189
The Ring programming language version 1.6 book - Part 16 of 189The Ring programming language version 1.6 book - Part 16 of 189
The Ring programming language version 1.6 book - Part 16 of 189
Mahmoud Samir Fayed
 
Xml part1
Xml part1  Xml part1
Xml part1
NOHA AW
 
Processing XML with Java
Processing XML with JavaProcessing XML with Java
Processing XML with Java
BG Java EE Course
 
The Ring programming language version 1.7 book - Part 17 of 196
The Ring programming language version 1.7 book - Part 17 of 196The Ring programming language version 1.7 book - Part 17 of 196
The Ring programming language version 1.7 book - Part 17 of 196
Mahmoud Samir Fayed
 
Transforming xml with XSLT
Transforming  xml with XSLTTransforming  xml with XSLT
Transforming xml with XSLT
Malintha Adikari
 
The Ring programming language version 1.5.1 book - Part 13 of 180
The Ring programming language version 1.5.1 book - Part 13 of 180The Ring programming language version 1.5.1 book - Part 13 of 180
The Ring programming language version 1.5.1 book - Part 13 of 180
Mahmoud Samir Fayed
 
XML Business Rules Validation with Schematron
XML Business Rules Validation with SchematronXML Business Rules Validation with Schematron
XML Business Rules Validation with SchematronEmiel Paasschens
 
SCR Annotations for Fun and Profit
SCR Annotations for Fun and ProfitSCR Annotations for Fun and Profit
SCR Annotations for Fun and Profit
Mike Pfaff
 
Impact 2014 - IIB - selecting the right transformation option
Impact 2014 -  IIB - selecting the right transformation optionImpact 2014 -  IIB - selecting the right transformation option
Impact 2014 - IIB - selecting the right transformation optionAndrew Coleman
 
XPath - XML Path Language
XPath - XML Path LanguageXPath - XML Path Language
XPath - XML Path Language
yht4ever
 
5 xsl (formatting xml documents)
5   xsl (formatting xml documents)5   xsl (formatting xml documents)
5 xsl (formatting xml documents)
gauravashq
 
Expressive objects
Expressive objectsExpressive objects
Expressive objects
Llewellyn Falco
 
XML-Motor
XML-MotorXML-Motor
XML-Motor
Abhishek Kumar
 
Handling XML and JSON in the Database
Handling XML and JSON in the DatabaseHandling XML and JSON in the Database
Handling XML and JSON in the Database
Mike Fowler
 
Xslt by asfak mahamud
Xslt by asfak mahamudXslt by asfak mahamud
Xslt by asfak mahamud
Asfak Mahamud
 
"Getting Started with XSLT" presentation slides
"Getting Started with XSLT" presentation slides"Getting Started with XSLT" presentation slides
"Getting Started with XSLT" presentation slides
Russell Ward
 
Sakai09 Osp Preconference Afternoon Forms
Sakai09 Osp Preconference Afternoon FormsSakai09 Osp Preconference Afternoon Forms
Sakai09 Osp Preconference Afternoon Forms
Sean Keesler
 

Similar to Introduction to Schematron (20)

03 x files
03 x files03 x files
03 x files
 
The Ring programming language version 1.6 book - Part 16 of 189
The Ring programming language version 1.6 book - Part 16 of 189The Ring programming language version 1.6 book - Part 16 of 189
The Ring programming language version 1.6 book - Part 16 of 189
 
Xml part1
Xml part1  Xml part1
Xml part1
 
Processing XML with Java
Processing XML with JavaProcessing XML with Java
Processing XML with Java
 
The Ring programming language version 1.7 book - Part 17 of 196
The Ring programming language version 1.7 book - Part 17 of 196The Ring programming language version 1.7 book - Part 17 of 196
The Ring programming language version 1.7 book - Part 17 of 196
 
Transforming xml with XSLT
Transforming  xml with XSLTTransforming  xml with XSLT
Transforming xml with XSLT
 
The Ring programming language version 1.5.1 book - Part 13 of 180
The Ring programming language version 1.5.1 book - Part 13 of 180The Ring programming language version 1.5.1 book - Part 13 of 180
The Ring programming language version 1.5.1 book - Part 13 of 180
 
XML Business Rules Validation with Schematron
XML Business Rules Validation with SchematronXML Business Rules Validation with Schematron
XML Business Rules Validation with Schematron
 
OOW 2012 XML Business Rules Validation Schematron - Emiel Paasschens
OOW 2012  XML Business Rules Validation Schematron - Emiel PaasschensOOW 2012  XML Business Rules Validation Schematron - Emiel Paasschens
OOW 2012 XML Business Rules Validation Schematron - Emiel Paasschens
 
SCR Annotations for Fun and Profit
SCR Annotations for Fun and ProfitSCR Annotations for Fun and Profit
SCR Annotations for Fun and Profit
 
Impact 2014 - IIB - selecting the right transformation option
Impact 2014 -  IIB - selecting the right transformation optionImpact 2014 -  IIB - selecting the right transformation option
Impact 2014 - IIB - selecting the right transformation option
 
XPath - XML Path Language
XPath - XML Path LanguageXPath - XML Path Language
XPath - XML Path Language
 
5 xsl (formatting xml documents)
5   xsl (formatting xml documents)5   xsl (formatting xml documents)
5 xsl (formatting xml documents)
 
Expressive objects
Expressive objectsExpressive objects
Expressive objects
 
XML-Motor
XML-MotorXML-Motor
XML-Motor
 
Handling XML and JSON in the Database
Handling XML and JSON in the DatabaseHandling XML and JSON in the Database
Handling XML and JSON in the Database
 
Xslt by asfak mahamud
Xslt by asfak mahamudXslt by asfak mahamud
Xslt by asfak mahamud
 
"Getting Started with XSLT" presentation slides
"Getting Started with XSLT" presentation slides"Getting Started with XSLT" presentation slides
"Getting Started with XSLT" presentation slides
 
Scala active record
Scala active recordScala active record
Scala active record
 
Sakai09 Osp Preconference Afternoon Forms
Sakai09 Osp Preconference Afternoon FormsSakai09 Osp Preconference Afternoon Forms
Sakai09 Osp Preconference Afternoon Forms
 

More from Octavian Nadolu

YAML Editing and Validation In Oxygen
YAML Editing and Validation In OxygenYAML Editing and Validation In Oxygen
YAML Editing and Validation In Oxygen
Octavian Nadolu
 
Oxygen JSON Editor
Oxygen JSON EditorOxygen JSON Editor
Oxygen JSON Editor
Octavian Nadolu
 
Leveraging the Power of AI and Schematron for Content Verification and Correc...
Leveraging the Power of AI and Schematron for Content Verification and Correc...Leveraging the Power of AI and Schematron for Content Verification and Correc...
Leveraging the Power of AI and Schematron for Content Verification and Correc...
Octavian Nadolu
 
OpenAPI/AsyncAPI Support in Oxygen
OpenAPI/AsyncAPI Support in OxygenOpenAPI/AsyncAPI Support in Oxygen
OpenAPI/AsyncAPI Support in Oxygen
Octavian Nadolu
 
Validating XML and JSON Documents Using Oxygen Scripting
 Validating XML and JSON Documents Using Oxygen Scripting Validating XML and JSON Documents Using Oxygen Scripting
Validating XML and JSON Documents Using Oxygen Scripting
Octavian Nadolu
 
OpenAPI Editing, Testing, and Documenting
OpenAPI Editing, Testing, and DocumentingOpenAPI Editing, Testing, and Documenting
OpenAPI Editing, Testing, and Documenting
Octavian Nadolu
 
JSON, JSON Schema, and OpenAPI
JSON, JSON Schema, and OpenAPIJSON, JSON Schema, and OpenAPI
JSON, JSON Schema, and OpenAPI
Octavian Nadolu
 
Create an Design JSON Schema
Create an Design JSON SchemaCreate an Design JSON Schema
Create an Design JSON Schema
Octavian Nadolu
 
Compare And Merge Scripts
Compare And Merge ScriptsCompare And Merge Scripts
Compare And Merge Scripts
Octavian Nadolu
 
JSON Schema Design
JSON Schema DesignJSON Schema Design
JSON Schema Design
Octavian Nadolu
 
Schematron For Non-XML Languages
Schematron For Non-XML LanguagesSchematron For Non-XML Languages
Schematron For Non-XML Languages
Octavian Nadolu
 
JSON and JSON Schema in Oxygen
JSON and JSON Schema in OxygenJSON and JSON Schema in Oxygen
JSON and JSON Schema in Oxygen
Octavian Nadolu
 
HTML5 Editing Validation
HTML5 Editing ValidationHTML5 Editing Validation
HTML5 Editing Validation
Octavian Nadolu
 
Documentation Quality Assurance with ISO Schematron
Documentation Quality Assurance with ISO SchematronDocumentation Quality Assurance with ISO Schematron
Documentation Quality Assurance with ISO Schematron
Octavian Nadolu
 
Hands on JSON
Hands on JSONHands on JSON
Hands on JSON
Octavian Nadolu
 
JSON Edit, Validate, Query, Transform, and Convert
JSON Edit, Validate, Query, Transform, and ConvertJSON Edit, Validate, Query, Transform, and Convert
JSON Edit, Validate, Query, Transform, and Convert
Octavian Nadolu
 
The Power Of Schematron Quick Fixes - XML Prague 2019
The Power Of Schematron Quick Fixes - XML Prague 2019The Power Of Schematron Quick Fixes - XML Prague 2019
The Power Of Schematron Quick Fixes - XML Prague 2019
Octavian Nadolu
 
Collaboration Tools to Help Improve Documentation Process
Collaboration Tools to Help Improve Documentation ProcessCollaboration Tools to Help Improve Documentation Process
Collaboration Tools to Help Improve Documentation Process
Octavian Nadolu
 
Exploring the new features in Oxygen XML Editor 20 - Development
Exploring the new features in Oxygen XML Editor 20 - DevelopmentExploring the new features in Oxygen XML Editor 20 - Development
Exploring the new features in Oxygen XML Editor 20 - Development
Octavian Nadolu
 
Comparing and Merging XML Documents in Visual Mode
Comparing and Merging XML Documents in Visual ModeComparing and Merging XML Documents in Visual Mode
Comparing and Merging XML Documents in Visual Mode
Octavian Nadolu
 

More from Octavian Nadolu (20)

YAML Editing and Validation In Oxygen
YAML Editing and Validation In OxygenYAML Editing and Validation In Oxygen
YAML Editing and Validation In Oxygen
 
Oxygen JSON Editor
Oxygen JSON EditorOxygen JSON Editor
Oxygen JSON Editor
 
Leveraging the Power of AI and Schematron for Content Verification and Correc...
Leveraging the Power of AI and Schematron for Content Verification and Correc...Leveraging the Power of AI and Schematron for Content Verification and Correc...
Leveraging the Power of AI and Schematron for Content Verification and Correc...
 
OpenAPI/AsyncAPI Support in Oxygen
OpenAPI/AsyncAPI Support in OxygenOpenAPI/AsyncAPI Support in Oxygen
OpenAPI/AsyncAPI Support in Oxygen
 
Validating XML and JSON Documents Using Oxygen Scripting
 Validating XML and JSON Documents Using Oxygen Scripting Validating XML and JSON Documents Using Oxygen Scripting
Validating XML and JSON Documents Using Oxygen Scripting
 
OpenAPI Editing, Testing, and Documenting
OpenAPI Editing, Testing, and DocumentingOpenAPI Editing, Testing, and Documenting
OpenAPI Editing, Testing, and Documenting
 
JSON, JSON Schema, and OpenAPI
JSON, JSON Schema, and OpenAPIJSON, JSON Schema, and OpenAPI
JSON, JSON Schema, and OpenAPI
 
Create an Design JSON Schema
Create an Design JSON SchemaCreate an Design JSON Schema
Create an Design JSON Schema
 
Compare And Merge Scripts
Compare And Merge ScriptsCompare And Merge Scripts
Compare And Merge Scripts
 
JSON Schema Design
JSON Schema DesignJSON Schema Design
JSON Schema Design
 
Schematron For Non-XML Languages
Schematron For Non-XML LanguagesSchematron For Non-XML Languages
Schematron For Non-XML Languages
 
JSON and JSON Schema in Oxygen
JSON and JSON Schema in OxygenJSON and JSON Schema in Oxygen
JSON and JSON Schema in Oxygen
 
HTML5 Editing Validation
HTML5 Editing ValidationHTML5 Editing Validation
HTML5 Editing Validation
 
Documentation Quality Assurance with ISO Schematron
Documentation Quality Assurance with ISO SchematronDocumentation Quality Assurance with ISO Schematron
Documentation Quality Assurance with ISO Schematron
 
Hands on JSON
Hands on JSONHands on JSON
Hands on JSON
 
JSON Edit, Validate, Query, Transform, and Convert
JSON Edit, Validate, Query, Transform, and ConvertJSON Edit, Validate, Query, Transform, and Convert
JSON Edit, Validate, Query, Transform, and Convert
 
The Power Of Schematron Quick Fixes - XML Prague 2019
The Power Of Schematron Quick Fixes - XML Prague 2019The Power Of Schematron Quick Fixes - XML Prague 2019
The Power Of Schematron Quick Fixes - XML Prague 2019
 
Collaboration Tools to Help Improve Documentation Process
Collaboration Tools to Help Improve Documentation ProcessCollaboration Tools to Help Improve Documentation Process
Collaboration Tools to Help Improve Documentation Process
 
Exploring the new features in Oxygen XML Editor 20 - Development
Exploring the new features in Oxygen XML Editor 20 - DevelopmentExploring the new features in Oxygen XML Editor 20 - Development
Exploring the new features in Oxygen XML Editor 20 - Development
 
Comparing and Merging XML Documents in Visual Mode
Comparing and Merging XML Documents in Visual ModeComparing and Merging XML Documents in Visual Mode
Comparing and Merging XML Documents in Visual Mode
 

Recently uploaded

Acorn Recovery: Restore IT infra within minutes
Acorn Recovery: Restore IT infra within minutesAcorn Recovery: Restore IT infra within minutes
Acorn Recovery: Restore IT infra within minutes
IP ServerOne
 
Doctoral Symposium at the 17th IEEE International Conference on Software Test...
Doctoral Symposium at the 17th IEEE International Conference on Software Test...Doctoral Symposium at the 17th IEEE International Conference on Software Test...
Doctoral Symposium at the 17th IEEE International Conference on Software Test...
Sebastiano Panichella
 
Competition and Regulation in Professional Services – KLEINER – June 2024 OEC...
Competition and Regulation in Professional Services – KLEINER – June 2024 OEC...Competition and Regulation in Professional Services – KLEINER – June 2024 OEC...
Competition and Regulation in Professional Services – KLEINER – June 2024 OEC...
OECD Directorate for Financial and Enterprise Affairs
 
Sharpen existing tools or get a new toolbox? Contemporary cluster initiatives...
Sharpen existing tools or get a new toolbox? Contemporary cluster initiatives...Sharpen existing tools or get a new toolbox? Contemporary cluster initiatives...
Sharpen existing tools or get a new toolbox? Contemporary cluster initiatives...
Orkestra
 
Bitcoin Lightning wallet and tic-tac-toe game XOXO
Bitcoin Lightning wallet and tic-tac-toe game XOXOBitcoin Lightning wallet and tic-tac-toe game XOXO
Bitcoin Lightning wallet and tic-tac-toe game XOXO
Matjaž Lipuš
 
Gregory Harris' Civics Presentation.pptx
Gregory Harris' Civics Presentation.pptxGregory Harris' Civics Presentation.pptx
Gregory Harris' Civics Presentation.pptx
gharris9
 
Announcement of 18th IEEE International Conference on Software Testing, Verif...
Announcement of 18th IEEE International Conference on Software Testing, Verif...Announcement of 18th IEEE International Conference on Software Testing, Verif...
Announcement of 18th IEEE International Conference on Software Testing, Verif...
Sebastiano Panichella
 
Supercharge your AI - SSP Industry Breakout Session 2024-v2_1.pdf
Supercharge your AI - SSP Industry Breakout Session 2024-v2_1.pdfSupercharge your AI - SSP Industry Breakout Session 2024-v2_1.pdf
Supercharge your AI - SSP Industry Breakout Session 2024-v2_1.pdf
Access Innovations, Inc.
 
somanykidsbutsofewfathers-140705000023-phpapp02.pptx
somanykidsbutsofewfathers-140705000023-phpapp02.pptxsomanykidsbutsofewfathers-140705000023-phpapp02.pptx
somanykidsbutsofewfathers-140705000023-phpapp02.pptx
Howard Spence
 
Media as a Mind Controlling Strategy In Old and Modern Era
Media as a Mind Controlling Strategy In Old and Modern EraMedia as a Mind Controlling Strategy In Old and Modern Era
Media as a Mind Controlling Strategy In Old and Modern Era
faizulhassanfaiz1670
 
Bonzo subscription_hjjjjjjjj5hhhhhhh_2024.pdf
Bonzo subscription_hjjjjjjjj5hhhhhhh_2024.pdfBonzo subscription_hjjjjjjjj5hhhhhhh_2024.pdf
Bonzo subscription_hjjjjjjjj5hhhhhhh_2024.pdf
khadija278284
 
Eureka, I found it! - Special Libraries Association 2021 Presentation
Eureka, I found it! - Special Libraries Association 2021 PresentationEureka, I found it! - Special Libraries Association 2021 Presentation
Eureka, I found it! - Special Libraries Association 2021 Presentation
Access Innovations, Inc.
 
Getting started with Amazon Bedrock Studio and Control Tower
Getting started with Amazon Bedrock Studio and Control TowerGetting started with Amazon Bedrock Studio and Control Tower
Getting started with Amazon Bedrock Studio and Control Tower
Vladimir Samoylov
 
Obesity causes and management and associated medical conditions
Obesity causes and management and associated medical conditionsObesity causes and management and associated medical conditions
Obesity causes and management and associated medical conditions
Faculty of Medicine And Health Sciences
 
María Carolina Martínez - eCommerce Day Colombia 2024
María Carolina Martínez - eCommerce Day Colombia 2024María Carolina Martínez - eCommerce Day Colombia 2024
María Carolina Martínez - eCommerce Day Colombia 2024
eCommerce Institute
 
0x01 - Newton's Third Law: Static vs. Dynamic Abusers
0x01 - Newton's Third Law:  Static vs. Dynamic Abusers0x01 - Newton's Third Law:  Static vs. Dynamic Abusers
0x01 - Newton's Third Law: Static vs. Dynamic Abusers
OWASP Beja
 
International Workshop on Artificial Intelligence in Software Testing
International Workshop on Artificial Intelligence in Software TestingInternational Workshop on Artificial Intelligence in Software Testing
International Workshop on Artificial Intelligence in Software Testing
Sebastiano Panichella
 

Recently uploaded (17)

Acorn Recovery: Restore IT infra within minutes
Acorn Recovery: Restore IT infra within minutesAcorn Recovery: Restore IT infra within minutes
Acorn Recovery: Restore IT infra within minutes
 
Doctoral Symposium at the 17th IEEE International Conference on Software Test...
Doctoral Symposium at the 17th IEEE International Conference on Software Test...Doctoral Symposium at the 17th IEEE International Conference on Software Test...
Doctoral Symposium at the 17th IEEE International Conference on Software Test...
 
Competition and Regulation in Professional Services – KLEINER – June 2024 OEC...
Competition and Regulation in Professional Services – KLEINER – June 2024 OEC...Competition and Regulation in Professional Services – KLEINER – June 2024 OEC...
Competition and Regulation in Professional Services – KLEINER – June 2024 OEC...
 
Sharpen existing tools or get a new toolbox? Contemporary cluster initiatives...
Sharpen existing tools or get a new toolbox? Contemporary cluster initiatives...Sharpen existing tools or get a new toolbox? Contemporary cluster initiatives...
Sharpen existing tools or get a new toolbox? Contemporary cluster initiatives...
 
Bitcoin Lightning wallet and tic-tac-toe game XOXO
Bitcoin Lightning wallet and tic-tac-toe game XOXOBitcoin Lightning wallet and tic-tac-toe game XOXO
Bitcoin Lightning wallet and tic-tac-toe game XOXO
 
Gregory Harris' Civics Presentation.pptx
Gregory Harris' Civics Presentation.pptxGregory Harris' Civics Presentation.pptx
Gregory Harris' Civics Presentation.pptx
 
Announcement of 18th IEEE International Conference on Software Testing, Verif...
Announcement of 18th IEEE International Conference on Software Testing, Verif...Announcement of 18th IEEE International Conference on Software Testing, Verif...
Announcement of 18th IEEE International Conference on Software Testing, Verif...
 
Supercharge your AI - SSP Industry Breakout Session 2024-v2_1.pdf
Supercharge your AI - SSP Industry Breakout Session 2024-v2_1.pdfSupercharge your AI - SSP Industry Breakout Session 2024-v2_1.pdf
Supercharge your AI - SSP Industry Breakout Session 2024-v2_1.pdf
 
somanykidsbutsofewfathers-140705000023-phpapp02.pptx
somanykidsbutsofewfathers-140705000023-phpapp02.pptxsomanykidsbutsofewfathers-140705000023-phpapp02.pptx
somanykidsbutsofewfathers-140705000023-phpapp02.pptx
 
Media as a Mind Controlling Strategy In Old and Modern Era
Media as a Mind Controlling Strategy In Old and Modern EraMedia as a Mind Controlling Strategy In Old and Modern Era
Media as a Mind Controlling Strategy In Old and Modern Era
 
Bonzo subscription_hjjjjjjjj5hhhhhhh_2024.pdf
Bonzo subscription_hjjjjjjjj5hhhhhhh_2024.pdfBonzo subscription_hjjjjjjjj5hhhhhhh_2024.pdf
Bonzo subscription_hjjjjjjjj5hhhhhhh_2024.pdf
 
Eureka, I found it! - Special Libraries Association 2021 Presentation
Eureka, I found it! - Special Libraries Association 2021 PresentationEureka, I found it! - Special Libraries Association 2021 Presentation
Eureka, I found it! - Special Libraries Association 2021 Presentation
 
Getting started with Amazon Bedrock Studio and Control Tower
Getting started with Amazon Bedrock Studio and Control TowerGetting started with Amazon Bedrock Studio and Control Tower
Getting started with Amazon Bedrock Studio and Control Tower
 
Obesity causes and management and associated medical conditions
Obesity causes and management and associated medical conditionsObesity causes and management and associated medical conditions
Obesity causes and management and associated medical conditions
 
María Carolina Martínez - eCommerce Day Colombia 2024
María Carolina Martínez - eCommerce Day Colombia 2024María Carolina Martínez - eCommerce Day Colombia 2024
María Carolina Martínez - eCommerce Day Colombia 2024
 
0x01 - Newton's Third Law: Static vs. Dynamic Abusers
0x01 - Newton's Third Law:  Static vs. Dynamic Abusers0x01 - Newton's Third Law:  Static vs. Dynamic Abusers
0x01 - Newton's Third Law: Static vs. Dynamic Abusers
 
International Workshop on Artificial Intelligence in Software Testing
International Workshop on Artificial Intelligence in Software TestingInternational Workshop on Artificial Intelligence in Software Testing
International Workshop on Artificial Intelligence in Software Testing
 

Introduction to Schematron

  • 1. Introduction to ISO SCHEMATRON © 2019 Syncro Soft SRL. All rights reserved Octavian Nadolu, Syncro Soft octavian_nadolu@oxygenxml.com @OctavianNadolu
  • 2. Introduction to ISO SchematronIntroduction to ISO Schematron Software Architect at Syncro Soft octavian.nadolu@oxygenxml.com • 15+ years of XML technology experience • Contributor for various XML-related open source projects • Editor of Schematron QuickFix specification developed by a W3C community group About me
  • 3. Introduction to ISO SchematronIntroduction to ISO Schematron Agenda ● ISO Schematron history ● ISO Schematron introduction ● XPath in ISO Schematron ● Schematron in the development process ● Schematron for technical and non- technical users ● Schematron Quick Fixes
  • 4. Introduction to ISO SchematronIntroduction to ISO Schematron What is Schematron? A natural language for making assertions in documents
  • 5. Introduction to ISO SchematronIntroduction to ISO Schematron Schematron is an ISO Standard Schematron is an ISO standard adopted by hundreds of major projects in the past decade
  • 6. Introduction to ISO SchematronIntroduction to ISO Schematron Schematron History Schematron was invented by Rick Jelliffe ● Schematron 1.0 (1999), 1.3 (2000), 1.5 (2001) ● ISO Schematron (2006, 2010, 2016)
  • 7. Introduction to ISO SchematronIntroduction to ISO Schematron Why Schematron? You can express constraints in a way that you cannot perform with other schemas (like XSD, RNG, or DTD). ● XSD, RNG, and DTD schemas define structural aspects and data types of the XML documents ● Schematron allows you to create custom rules specific to your project
  • 8. Introduction to ISO SchematronIntroduction to ISO Schematron Schematron Usage ● Verify data inter-dependencies ● Check data cardinality ● Perform algorithmic checks
  • 9. Introduction to ISO SchematronIntroduction to ISO Schematron Used in Multiple Domains ● Financial ● Insurance ● Government ● Technical publishing
  • 10. Introduction to ISO SchematronIntroduction to ISO Schematron Schematron is Very Simple There are only 6 basic elements: assert report rule pattern schema ns
  • 11. Introduction to ISO SchematronIntroduction to ISO Schematron Schematron Step-by-Step
  • 12. Introduction to ISO SchematronIntroduction to ISO Schematron XML A list of books from a bookstore: ... <book price="7"> <title>XSLT 2.0 Programmer's Reference</title> <author>Michael Kay</author> <isbn>0764569090</isbn> </book> <book price="1100"> <title>XSLT and XPath On The Edge</title> <author>Jeni Tennison</author> <isbn>0764547763 </isbn> </book> ...
  • 13. Introduction to ISO SchematronIntroduction to ISO Schematron <assert> An assert generates a message when a test statement evaluates to false <assert test="@price > 10">The book price is too small</assert>
  • 14. Introduction to ISO SchematronIntroduction to ISO Schematron <report> A report generates a message when a test statement evaluate to true. <report test="@price > 1000">The book price is too big</report>
  • 15. Introduction to ISO SchematronIntroduction to ISO Schematron <rule> A rule defines a context on which a list of assertions will be tested, and is comprised of one or more assert or report elements. <rule context="book"> <assert test="@price > 10">The book price is too small</assert> <report test="@price > 1000">The book price is too big</report> </rule>
  • 16. Introduction to ISO SchematronIntroduction to ISO Schematron <pattern> A set of rules giving constraints that are in some way related <pattern> <rule context="book"> <assert test="@price > 10">The book price is too small</assert> <report test="@price > 1000">The book price is too big</report> </rule> </pattern>
  • 17. Introduction to ISO SchematronIntroduction to ISO Schematron <schema> The top-level element of a Schematron schema. <schema xmlns="http://purl.oclc.org/dsdl/schematron"> <pattern> <rule context="book"> <assert test="@price > 10">The book price is too small</assert> <report test="@price > 1000">The book price is too big</report> </rule> </pattern> </schema>
  • 18. Introduction to ISO SchematronIntroduction to ISO Schematron Apply Schematron <schema xmlns="http://purl.oclc.org/dsdl/schematron"> <pattern> <rule context="book"> <assert test="@price > 10">The book price is too small</assert> <report test="@price > 1000">The book price is too big</report> </rule> </pattern> </schema> ... <book price="7"> <title>XSLT 2.0 Programmer's Reference</title> <author>Michael Kay</author> <isbn>0764569090</isbn> </book> <book price="1100"> <title>XSLT and XPath On The Edge</title> <author>Jeni Tennison</author> <isbn>0764547763</isbn> </book> ... The price is too small The book price is too big Validate
  • 19. Introduction to ISO SchematronIntroduction to ISO Schematron <ns> Defines a namespace prefix and URI <schema xmlns="http://purl.oclc.org/dsdl/schematron"> <ns uri="http://book.example.com" prefix="b"/> <pattern> <rule context="b:book"> <assert test="@price > 10">The book price is too small</assert> <report test="@price > 1000">The book price is too big</report> </rule> </pattern> </schema>
  • 20. Introduction to ISO SchematronIntroduction to ISO Schematron Conclusion ● Schematron is simple (6 basic elements) ● Used in multiple domains ● Schematron uses XPath
  • 21. Introduction to ISO SchematronIntroduction to ISO Schematron //* XPath in Schematron
  • 22. Introduction to ISO SchematronIntroduction to ISO Schematron What is XPath? ● A language for addressing parts of an XML document (XML Path Language) ● A W3C Recommendation in 1999 www.w3.org/TR/xpath ● XPath versions 1.0, 2.0, 3.0, 3.1 (2017)
  • 23. Introduction to ISO SchematronIntroduction to ISO Schematron Schematron Uses XPath ● XPath in Schematron: – Rule context is expressed using an XPath expression <rule context="book"> – Assertions are expressed using XPath expressions that are evaluated as true or false <assert test="@price > 10">
  • 24. Introduction to ISO SchematronIntroduction to ISO Schematron Basic XPath Syntax ● nodeName – select node with a specific name ● / - level selector ● // - multi-level selector ● ../ - level up selector ● @ - attribute selector
  • 25. Introduction to ISO SchematronIntroduction to ISO Schematron Examples ● book – select all nodes with the name “book” ● /books/book – selects all the “book” elements that are in the “books” root element ● book/title – selects the “title” elements for all the books ● /books//title – selects all the “title” elements from the “books” ● @price – selects all the price attributes
  • 26. Introduction to ISO SchematronIntroduction to ISO Schematron Schematron Example <rule context="/books/book"> <assert test="@price > 10">The book price is too small</assert> </rule> <rule context="/books/book/@price"> <assert test=". > 10">The book price is too small</assert> </rule>
  • 27. Introduction to ISO SchematronIntroduction to ISO Schematron Predicates Condition in square brakes ● //book[2] – selects the second book element ● book[@price &lt; 10] – selects all the book elements with the price less than(lt) 10 ● book[last()] - selects the last book element ● book[@price>1000]/author - selects all the “author” elements that are in a book with the price grater than(gt) 1000
  • 28. Introduction to ISO SchematronIntroduction to ISO Schematron Schematron Example <rule context="book[@price>1000]/author"> <assert test="text() = 'Jeni Tennison'"> Only 'Jeni Tennison' books can have bigger price</assert> </rule> <rule context="book[@price lt 10] "> <assert test="false()">The book price is too small</assert> </rule>
  • 29. Introduction to ISO SchematronIntroduction to ISO Schematron Wildcards * - any element node selector @* - any attribute node selector node() - any node selector
  • 30. Introduction to ISO SchematronIntroduction to ISO Schematron Wildcards Examples //* - selects all the elements from the document //book[@*] - selects all the book elements that have an attribute //book/* - selects all the elements from the book
  • 31. Introduction to ISO SchematronIntroduction to ISO Schematron XPath Functions ● For strings: concat(), substring(), contains(), substring-before(), substring-after(), translate(), normalize-space(), string-length() ● For numbers: sum(), round(), floor(), ceiling() ● Node Properties: name(), local-name(), namespace-uri()
  • 32. Introduction to ISO SchematronIntroduction to ISO Schematron Schematron Example <rule context="book/title"> <assert test="string-length(text()) lt 30"> Titles should be less than 30 characters</assert> </rule> <rule context="books"> <report test="sum(book/@price) > 10000"> The books price is too big</report> </rule>
  • 33. Introduction to ISO SchematronIntroduction to ISO Schematron XPath Version in Schematron ● @queryBinding – determines the XPath version <schema queryBinding="xslt2"> Possible values: xslt, xslt2, xslt3
  • 34. Introduction to ISO SchematronIntroduction to ISO Schematron Conclusion ● XPath it is very important in Schematron ● Used in rule context and assertions ● Different XPath versions ● Tutorials: – www.data2type.de/en/xml-xslt-xslfo/xpath/ – www.xfront.com/xpath/ – www.zvon.org/comp/m/xpath.html
  • 35. Introduction to ISO SchematronIntroduction to ISO Schematron Examples of Rules
  • 36. Introduction to ISO SchematronIntroduction to ISO Schematron Check Number of List Items ● Example of a rule that checks the number of list items in a list A list must have more than one item
  • 37. Introduction to ISO SchematronIntroduction to ISO Schematron Check Number of List Items ● The number of list items from an unordered list should be greater than one <sch:rule context="ul"> <sch:assert test="count(li) > 1"> A list must have more than one item</sch:assert> </sch:rule>
  • 38. Introduction to ISO SchematronIntroduction to ISO Schematron Styling in Titles ● Example rule that checks for styling in titles Bold is not allowed in title element
  • 39. Introduction to ISO SchematronIntroduction to ISO Schematron Styling in Titles ● The b element should not be used in a title or short description <sch:rule context="title | shortdesc"> <sch:report test="b"> Bold is not allowed in <sch:name/> element</sch:report> </sch:rule>
  • 40. Introduction to ISO SchematronIntroduction to ISO Schematron Semicolon at End of List Items ● Example of rule that checks if a semicolon is at the end of a list item Semicolon is not allowed at the end of a list item
  • 41. Introduction to ISO SchematronIntroduction to ISO Schematron Semicolon at End of List Items ● The last text from a list item should not end with semicolon <sch:rule context="li"> <sch:report test="ends-with(text()[last()], ';')"> Semicolon is not allowed after list item</sch:report> </sch:rule>
  • 42. Introduction to ISO SchematronIntroduction to ISO Schematron Check External Link Protocol ● Example of rule that check the external link protocol The external link should start with http(s)
  • 43. Introduction to ISO SchematronIntroduction to ISO Schematron Check External Link Protocol ● The @href attribute value it is an external link and should start with http or https. <rule context="xref"> <sch:assert test="matches(@href, '^http(s?)://')"> An link should start with http(s).</sch:assert> </rule>
  • 44. Introduction to ISO SchematronIntroduction to ISO Schematron Missing Tables Cells ● Missing cells in a table Cells are missing from table
  • 45. Introduction to ISO SchematronIntroduction to ISO Schematron Missing Tables Cells ● Check that are the same number of cells on each row <sch:rule context="table"> <sch:let name="minColumsNo" value="min(.//row/count(entry))"/> <sch:let name="reqColumsNo" value="max(.//row/count(entry))"/> <sch:assert test="$minColumsNo >= $reqColumsNo"> Cells are missing. (The number of cells for each row must be <sch:value-of select="$reqColumsNo"/>) </sch:assert> </sch:rule>
  • 46. Introduction to ISO SchematronIntroduction to ISO Schematron Link in Text Content ● Links are added directly in text content Link detected in the current element
  • 47. Introduction to ISO SchematronIntroduction to ISO Schematron Link in Text Content ● Check if a link is added in text content but is not tagged as a link <sch:rule context="text()"> <sch:report test="matches(., '(http|www)S+') and local-name(parent::node()) != 'xref'"> The link should be a xref element</sch:report> </sch:rule>
  • 48. Introduction to ISO SchematronIntroduction to ISO Schematron Conclusion ● Simple to complex Schematron rules ● Additional Schematron elements <let> - A declaration of a named variable <value-of> - Finds or calculates values from the instance document <name> - Provides the names of nodes from the instance document
  • 49. Introduction to ISO SchematronIntroduction to ISO Schematron Integrating Schematron in the Development Process
  • 50. Introduction to ISO SchematronIntroduction to ISO Schematron Validate XML with Schematron ● Associate Schematron in the XML file ● Use tool-specific association options – Associate Schematron file with a set of XML files (all files with a specific namespace, or from a directory) – Associate Schematron with all XML files from a project <?xml-model href="books.sch" type="application/xml" schematypens="http://purl.oclc.org/dsdl/schematron"?>
  • 51. Introduction to ISO SchematronIntroduction to ISO Schematron Embed Schematron in XSD or RNG ● Schematron can be added in the XSD appinfo element ● Add Schematron checks in any element on any level of an RNG schema
  • 52. Introduction to ISO SchematronIntroduction to ISO Schematron Run Schematron Validation ● From an XML editing framework – Check the XML files as you type – Run the Schematron validation on multiple files ● Using W3C's XProc pipeline language through its "validate- with-schematron" step ● Using Apache Ant, from bat/shell https://github.com/Schematron/ant-schematron
  • 53. Introduction to ISO SchematronIntroduction to ISO Schematron Schematron Validation Result ● Messages presented in the editing framework ● As an XML file describing the validation errors, normally in Schematron Validation Reporting Language (SVRL) <svrl:failed-assert test="matches(@href, '^http(s?)://')" role="warn" location="/topic[1]/body[1]/section[1]/p[3]/xref[1]"> <svrl:text>An external link should start with http(s).</svrl:text> </svrl:failed-assert>
  • 54. Introduction to ISO SchematronIntroduction to ISO Schematron Schematron Messages Severity ● Severity level can be set in the value of the @role attribute from an assert or report element (fatal, error, warn, or info) ● Depending on the severity, the message can be rendered differently in an editing framework
  • 55. Introduction to ISO SchematronIntroduction to ISO Schematron Multilingual Support in Schematron ● Based on the Schematron diagnostic element ● A diagnostic element is used for each language ● Multilingual support defined in the Schematron specification <sch:assert test="bone" diagnostics="d_en d_de"> A dog should have a bone. </sch:assert> …. <sch:diagnostics xml:lang="en"> <sch:diagnostic id="d_en">A dog should have a bone.<sch:diagnostic> </sch:diagnostics> <sch:diagnostics xml:lang="de"> <sch:diagnostic id="d_de">Das Hund muss ein Bein haben.</sch:diagnostic> </sch:diagnostics>
  • 56. Introduction to ISO SchematronIntroduction to ISO Schematron Conclusion ● Multiple ways to associate and apply the validation ● Validation results as you type or in a report ● Messages with different severity ● Multilingual support
  • 57. Introduction to ISO SchematronIntroduction to ISO Schematron Schematron for Non-Technical Users
  • 58. Introduction to ISO SchematronIntroduction to ISO Schematron Create Rules ● There are more and more non-technical users that want to develop their own rules ● Providing a user interface to create the Schematron rules will be more appropriate for them
  • 59. Introduction to ISO SchematronIntroduction to ISO Schematron Auto-Generate Schematron Rules ● A style guide can contain information to automate the style guide checks ● An automated rule is an instantiation of a generic rule
  • 60. Introduction to ISO SchematronIntroduction to ISO Schematron Intelligent Integrated Style Guide ● An implementation of an intelligent style guide ● Describes and enforces rules ● Open-source project is available on GitHub github.com/oxygenxml/integrated-styleguide
  • 61. Introduction to ISO SchematronIntroduction to ISO Schematron Library of Rules ● Generic rules can be created using a library of rules ● The user can choose the rule that he wants to add Avoid a word in a certain element Limit the number of words Avoid duplicate content
  • 62. Introduction to ISO SchematronIntroduction to ISO Schematron Abstract Patterns Library of rules implemented using abstract patterns AvoidWordInElement LimitNoCharacters AvoidDuplicateContent Schematron rules generate
  • 63. Introduction to ISO SchematronIntroduction to ISO Schematron Abstract Pattern ● Allows to reuse patterns by making them generic <pattern id="LimitNoOfWords" abstract="true"> <rule context="$parentElement"> <let name="words" value="count(tokenize(normalize-space(.), ' '))"/> <assert test="$words le $maxWords"> $message You have <value-of select="$words"/> word(s). </assert> <assert test="$words ge $minWords"> $message You have <value-of select="$words"/> word(s). </assert> </rule> </pattern>
  • 64. Introduction to ISO SchematronIntroduction to ISO Schematron Pattern Instantiation ● Refer an abstract pattern and specifies values for parameters <pattern is-a="LimitNoOfWords"> <param name="parentElement" value="shortdesc"/> <param name="minWords" value="1"/> <param name="maxWords" value="50"/> <param name="message" value="Keep short descriptions between 1 and 50 words!"/> </pattern> <pattern is-a="LimitNoOfWords"> <param name="parentElement" value="title"/> <param name="minWords" value="1"/> <param name="maxWords" value="8"/> <param name="message" value="Keep titles between 1 and 8 words."/> </pattern>
  • 65. Introduction to ISO SchematronIntroduction to ISO Schematron Chatbot to Generate Schematron
  • 66. Introduction to ISO SchematronIntroduction to ISO Schematron Generate Schematron Patterns 66 <sch:pattern is-a="limitElement"> <sch:param name="element" value="p"/> <sch:param name="limit" value="maximum"/> <sch:param name="size" value="100"/> <sch:param name="unit" value="words"/> <sch:param name="message" value="p should contain maximum 100 words"/> </sch:pattern> l “Paragraphs should have less than 100 words”
  • 67. Introduction to ISO SchematronIntroduction to ISO Schematron Schematron for Technical Users
  • 68. Introduction to ISO SchematronIntroduction to ISO Schematron Environment to Develop Schematron Schemas – Editor – Validation – Search and refactoring – Working with modules – Unit testing
  • 69. Introduction to ISO SchematronIntroduction to ISO Schematron Editor ● Syntax highlighting - to improve the readability of the content ● Content completion assistant - offering proposals that are valid at the cursor position ● Documentation - with information about the particular proposal
  • 70. Introduction to ISO SchematronIntroduction to ISO Schematron Validate ● Validate Schematron schemas, and highlight problems directly in the editor ● Validate Schematron modules in context ● Support for validation as you type
  • 71. Introduction to ISO SchematronIntroduction to ISO Schematron Search and Refactoring ● Find references to variables, pattern, phases, or diagnostics ● Support for renaming all references from the current document, or in the entire hierarchy ● Preview the changes
  • 72. Introduction to ISO SchematronIntroduction to ISO Schematron Working with Modules ● Visualize the hierarchy of modules ● Support for editing a Schematron module in the context ● Moving and renaming modules
  • 73. Introduction to ISO SchematronIntroduction to ISO Schematron Test Schematron Rules ● Developing Schematron schema also involves testing ● Make sure Schematron rules work as expected ● Apply multiple XML examples over the Schematron rules and check the results
  • 74. Introduction to ISO SchematronIntroduction to ISO Schematron XSpec ● Solution to create Schematron unit tests ● Unit test and BDD (Behaviour Driven Development ) framework ● https://github.com/xspec/xspec/ ● Oxygen XSpec Helper View plugin ● github.com/xspec/oXygen-XML-editor-xspec-support ● Tutorials – github.com/xspec/xspec/wiki/Getting-Started-with-XSpec-and-Schematron – oxygenxml.com/events/2018/webinar_xspec_unit_testing_for_xslt_and_schematron.h tml
  • 75. Introduction to ISO SchematronIntroduction to ISO Schematron Conclusion ● User interface for non-technical users ● Library of rules using abstract patterns ● Editing, validation, and refactoring for technical users ● Test cases for Schematron
  • 76. Introduction to ISO SchematronIntroduction to ISO Schematron Schematron Quick Fixes
  • 77. Introduction to ISO SchematronIntroduction to ISO Schematron Schematron Fix Proposals ● Schematron assertion messages are not always enough for the user to find a solution ● It is better to have some proposals to correct the Schematron reported problem ● Similar to spell check proposals
  • 78. Introduction to ISO SchematronIntroduction to ISO Schematron Schematron Quick Fix Proposals ● User-defined fixes for Schematron errors ● Schematron Quick Fix (SQF) language – Extension of the Schematron language – SQF initiated by Nico Kutscherauer www.schematron-quickfix.com github.com/schematron-quickfix/sqf
  • 79. Introduction to ISO SchematronIntroduction to ISO Schematron Schematron Quick Fixes Spec www.w3.org/community/quickfix schematron-quickfix.github.io/sqf
  • 80. Introduction to ISO SchematronIntroduction to ISO Schematron SQF Extension of Schematron ● Added as Schematron annotations ● Associate fixes with assert and report elements <rule context="title"> <report test="b" sqf:fix="resolveBold"> Bold is not allowed in title element</report> <sqf:fix id="resolveBold"> <sqf:description> <sqf:title>Change the bold element into text</sqf:title> <sqf:p>Removes the bold (b) markup and keeps the text content.</sqf:p> </sqf:description> <sqf:replace match="b" select="node()"/> </sqf:fix> </rule>
  • 81. Introduction to ISO SchematronIntroduction to ISO Schematron Schematron Quick Fix (SQF) <sqf:fix id="resolveBold"> <sqf:description> <sqf:title>Change the bold element into text</sqf:title> <sqf:p>Removes the bold (b) markup and keeps the text content.</sqf:p> </sqf:description> <sqf:replace match="b" select="node()"/> </sqf:fix> Operation ID Description Title
  • 82. Introduction to ISO SchematronIntroduction to ISO Schematron SQF Operations The following 4 types of operations are supported: ● <sqf:add> - To add a new node or fragment in the document ● <sqf:delete> - To remove a node from the document ● <sqf:replace> - To replace a node with another node or fragment ● <sqf:stringReplace> - To replace text content with other text or a fragment
  • 83. Introduction to ISO SchematronIntroduction to ISO Schematron Introduction to SQF Through Examples
  • 84. Introduction to ISO SchematronIntroduction to ISO Schematron 1. SQF “add” Operation ● Example of using the “add” operation: add new list item in a list List contains only one item Add new list item
  • 85. Introduction to ISO SchematronIntroduction to ISO Schematron 1. SQF “add” Operation ● <sqf:add> element allows you to add one or more nodes to the XML instance <rule context="ul"> <assert test="count(li) > 1" sqf:fix="addListItem">A list must have more than one item.</assert> <sqf:fix id="addListItem"> <sqf:description> <sqf:title>Add new list item</sqf:title> </sqf:description> <sqf:add node-type="element" target="li" position="last-child"/> </sqf:fix> </rule>
  • 86. Introduction to ISO SchematronIntroduction to ISO Schematron 2. SQF “delete” Operation ● Example of using the “delete” operation: remove redundant link text Remove redundant link text Text in the link and the value of the @href are the same
  • 87. Introduction to ISO SchematronIntroduction to ISO Schematron 2. SQF “delete” Operation ● <sqf:delete> element specifies the nodes for the deletion <rule context="xref"> <report test="@href = text()" sqf:fix="removeText"> Link text is same as @href attribute value. Please remove.</report> <sqf:fix id="removeText"> <sqf:description> <sqf:title>Remove redundant link text</sqf:title> </sqf:description> <sqf:delete match="text()"/> </sqf:fix> </rule>
  • 88. Introduction to ISO SchematronIntroduction to ISO Schematron 3. SQF “replace” Operation ● Example of using the “replace” operation: replace bold element with text Change the bold into text Styling is not allowed in titles
  • 89. Introduction to ISO SchematronIntroduction to ISO Schematron 3. SQF “replace” Operation ● <sqf:replace> element specifies the nodes to be replaced and the replacing content <rule context="title"> <report test="b" sqf:fix="resolveBold"> Bold is not allowed in title element.</report> <sqf:fix id="resolveBold"> <sqf:description> <sqf:title>Change the bold into text</sqf:title> </sqf:description> <sqf:replace match="b" select="node()"/> </sqf:fix> </rule>
  • 90. Introduction to ISO SchematronIntroduction to ISO Schematron 4. SQF “stringReplace” Operation ● Example of using the “stringReplace” operation: replace semicolon with full stop Replace semicolon with full stop Semicolon is not allowed at the end of a list item
  • 91. Introduction to ISO SchematronIntroduction to ISO Schematron 4. SQF “stringReplace” Operation ● <sqf:stringReplace> element defines the nodes that will replace the substrings <rule context="li"> <report test="ends-with(text()[last()], ';')" sqf:fix="replaceSemicolon"> Semicolon is not allowed after list item</report> <sqf:fix id="replaceSemicolon"> <sqf:description> <sqf:title>Replace semicolon with full stop</sqf:title> </sqf:description> <sqf:stringReplace match="text()[last()]" regex=";$" select="'.'"/> </sqf:fix> </rule>
  • 92. Introduction to ISO SchematronIntroduction to ISO Schematron Conclusions ● Schematron Quick Fix language is simple ● You can define custom fixes for your project ● Just 4 types of operations
  • 93. Introduction to ISO SchematronIntroduction to ISO Schematron SQF Implementations ● <oXygen/> XML Editor validation engine http://www.oxygenxml.com ● Escali Schematron engine http://schematron-quickfix.com/escali_xsm.html – Escali Schematron command-line tool – Oxygen plugin for invoking Escali Schematron
  • 94. Introduction to ISO SchematronIntroduction to ISO Schematron Projects Using SQF ● Thieme - publishing company uses a custom framework to create and edit XML documents ● parsX - a product developed by pagina GmbH used to facilitate EPUB production ● ART-DECOR - an open-source tool suite that supports SDOs active in the healthcare industry Sample SQF embedded in XSD ● ATX custom framework – used by a major automotive manufacturer
  • 95. Introduction to ISO SchematronIntroduction to ISO Schematron Resources ● Schematron official site ● Schematron specification ● Schematron Quick Fix specification Sample files: github.com/octavianN/Schematron-step-by-step
  • 96. Questions? Octavian Nadolu Software Architect at Syncro Soft octavian.nadolu@oxygenxml.com Twitter: @OctavianNadolu LinkedIn: octaviannadolu https://sundt04.honestly.de