SlideShare una empresa de Scribd logo
1 de 28
Descargar para leer sin conexión
Business Load Balancing by Complex 
Message Validation with the Oracle 
SOA Suite 
Schematron 
Emiel Paasschens, AMIS - 7 december UKOUG
Emiel Paasschens 
1996 August 13,1973 
Amarin, 3 months 
June 7, 2013 Aran, 3 years
AMIS 
Aircraft Maintenance Information System 
1991 
technology.amis.nl 
90
Agenda 
• Early fault detection 
• Current solution: XSD validation 
• Validation Gap 
• Schematron 
• Schematron in SOA Suite 
• Simple use case example 
• Demo
Fault Detection 
The earlier the better! 
• Reduces load 
• Decreases monitor ‘pollution’ 
(logs, monitor screens) 
• May even prevent system crashes 
• Response earlier (back to customer) 
• Lower costs
Early Fault Detection in SOA 
SOA: Webservices, SOAP 
Early fault detection: 
The 1st possibility is error detection 
in accepting the request message. 
 Validating the request message 
Request message is XML (SOAP) 
 XML Validation  XSD (Schema)
Current solution: XSD validation 
XML Schema (XSD): 
Defines structure of XML including data type of elements and constraints. 
1. Structure 
Element “Person” contains child element “Name” and “Birthdate” in this 
order. 
2. Data type 
Element “Name” is of String type and element “Birthdate” is of type date. 
3. Constraints 
Element “Name” is at least two characters long. 
• XSD can be seen as the “ERD” or “DB Design” for XML documents
XSD Validation 
<?xml version="1.0" encoding="UTF-8" ?> 
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
xmlns="http://amis.nl/schematrondemo/common" 
targetNamespace="http://amis.nl/schematrondemo/common" 
elementFormDefault="qualified"> 
<xsd:element name="Person"> 
<xsd:complexType> 
<xsd:sequence> 
<xsd:element name="Name"> 
<xsd:simpleType> 
<xsd:restriction base="xsd:string"> 
<xsd:minLength value="2"/> 
</xsd:restriction> 
</xsd:simpleType> 
</xsd:element> 
<xsd:element name="Birthdate" type="xsd:date"/> 
</xsd:sequence> 
</xsd:complexType> 
</xsd:element> 
</xsd:schema> 
Structure
XSD Validation 
<?xml version="1.0" encoding="UTF-8" ?> 
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
xmlns="http://amis.nl/schematrondemo/common" 
targetNamespace="http://amis.nl/schematrondemo/common" 
elementFormDefault="qualified"> 
<xsd:element name="Person"> 
<xsd:complexType> 
<xsd:sequence> 
<xsd:element name="Name"> 
<xsd:simpleType> 
<xsd:restriction base="xsd:string"> 
<xsd:minLength value="2"/> 
</xsd:restriction> 
</xsd:simpleType> 
</xsd:element> 
<xsd:element name="Birthdate" type="xsd:date"/> 
</xsd:sequence> 
</xsd:complexType> 
</xsd:element> 
</xsd:schema> 
Type
XSD Validation 
<?xml version="1.0" encoding="UTF-8" ?> 
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
xmlns="http://amis.nl/schematrondemo/common" 
targetNamespace="http://amis.nl/schematrondemo/common" 
elementFormDefault="qualified"> 
<xsd:element name="Person"> 
<xsd:complexType> 
<xsd:sequence> 
<xsd:element name="Name"> 
<xsd:simpleType> 
<xsd:restriction base="xsd:string"> 
<xsd:minLength value="2"/> 
</xsd:restriction> 
</xsd:simpleType> 
</xsd:element> 
<xsd:element name="Birthdate" type="xsd:date"/> 
</xsd:sequence> 
</xsd:complexType> 
</xsd:element> 
</xsd:schema> 
Constraints
Validation Gap 
Three types of XML Business Rule Validation: 
1. On data / element itself: 
Data type and (data) constraints 
 XSD (Even complex data constraints with regular expressions) 
2. XML structure: 
Element names & Hierarchy (child-parent) constraints 
XSD?  Partial! Optional combinations are difficult (choice combinations) 
or even impossible. 
3. Constraints between elements 
Typically more Business Rules validations 
e.g. sum of all percentage attributes in the XML document must be 100. 
?? 

Schematron 
• Used for validating an XML Document 
• Validation of (conditional) structure 
• Validation between nodes (elements/attributes), Business Rules 
• Rules are defined in Schematron format which is ‘just’ an XML document 
• Is built upon XPath expressions 
 so no new language, only XML and XPath knowledge required! 
• Specifies the error message (so you are in control of the output) 
• Is an ISO/IEC Standard: 19757-3 (2006) 
• Basically is a double XSTL transformation (under the hood)
Schematron 
How does it work: 
1. Define the validations with the usage of XPath expressions in an XML 
document in a fixed format and structure (according to the Schematron 
XSD). 
2. Transform this validations XML with a specific Schematron XSLT into a 
new XSLT, which ‘contains/implements’ the validations of step 1. 
(In the SOA Suite this is done ,‘under the hood’, by the Runtime Engine) 
3. This generated XSLT (containing the validations) can be used to validate 
XML data/payload by executing a transformation on it. 
(In the SOA Suite this is done ,‘under the hood’, by the Runtime Engine) 
Any output are errors! (these error messages were also specified in step 
1). 
So no output means the data is valid.
Schematron 
Double XSLT transformation: 
1. Rules.xml with Schematron.xslt  Rules.xslt 
2. Data.xml with Rules.xslt  Result
Schematron XML 
<?xml version="1.0" encoding="UTF-8" ?> 
<schema xmlns="http://www.ascc.net/xml/schematron"> 
<pattern name="patternName"> 
<rule context="x-path"> 
<assert test="x-path condition">Error message</assert> 
<report test="x-path condition">Error message</report> 
... 
</rule> 
</pattern> 
<pattern name="patternName"> 
... 
</schema>
Schematron Example 
Attribute “abb” of all “Department” elements must be 2 or 3 
long. 
<?xml version="1.0" encoding="UTF-8" ?> 
<schema xmlns="http://www.ascc.net/xml/schematron"> 
<pattern name="Number of characters in an abbreviation"> 
<rule context="//Department"> 
<report test="string-length(@abb) &lt; 2">There are not enough 
characters in the abbreviation</report> 
<report test="string-length(@abb) > 3">There are too much 
characters in the abbreviation</report> 
</rule> 
</pattern> 
</schema> 
Just a name 
Context: ‘starting point’ for the conditions 
Conditions Error messages
Schematron Example 
The sum of all direct child elements “Percent” under element 
“Total” must be 100. 
<?xml version="1.0" encoding="UTF-8" ?> 
<schema xmlns="http://www.ascc.net/xml/schematron" > 
<pattern name="Sum equals 100%."> 
<rule context="//Total"> 
<assert test="sum(./Percent) = 100">Sum is not 100%.</assert> 
</rule> 
</pattern> 
</schema>
Schematron in the SOA Suite 
• Default filename extension “sch” 
• Only assert tag, no report tag! 
 assert=not(report) 
• Define namespace prefixes with uri tag: 
<ns uri="http://amis.nl/schematrondemo/company" prefix="cmp" /> 
• Implemented in Mediator:
Use Case Example 
Company HRM XML file: 
Company element contains departments which contains 
employees: 
• An employee may not be the manager of himself. 
• All normal employees (so not a manager) must have a 
manager. 
• There is only one manager without a manager 
(so there is only one president). 
• All employees should have less salary than any manager 
(manager = employee in department named “Managers”). 
• The relation of manager and employee is a valid one. 
This means that the manager of an employee must exist.
Use Case Example 
<Company><Department name="Ground One" abbr="GR1">...</Department> 
<Department name="Ground Two" abbr="GR2"> 
<Employees> 
<Employee id="13" manager_id="20"> 
<Name>P. Pietersen</Name> 
<Salary>1550</Salary> 
</Employee> 
<Employee id="14" manager_id="20"> 
<Name>S. Smit</Name> 
<Salary>1600</Salary> 
</Employee> 
</Employees> 
</Department> 
<Department name="Managers" abbr="MAN"> 
<Employees> 
<Employee id="15"> 
<Name>M.A. Nager</Name> 
<Salary>1700</Salary> 
</Employee> 
<Employee id="20" manager_id="25"> 
<Name>L.E. Ader</Name> 
<Salary>1600</Salary>
Use Case Example 
An employee may not be the manager of himself. 
<pattern name="Employee may not be the manager of himself"> 
<rule context="//com:Employee[@manager_id]"> 
<assert test="@manager_id != @id">Employee may not manage himself</assert> 
</rule> 
</pattern>
Use Case Example 
All normal employees (so not a manager) must have a 
manager. 
<pattern name="All normal employees have a manager"> 
<rule context="//cmp:Department[@name!='Managers']/cmp:Employees/com:Employee"> 
<assert test="@manager_id">Employee must have a manager</assert> 
</rule> 
</pattern>
Use Case Example 
There is only one manager without a manager 
(only one president). 
<pattern name="Only one manager without manager, mr president"> 
<rule context="//cmp:Department[@name='Managers']/cmp:Employees"> 
<assert test="count(com:Employee[not(@manager_id)]) = 1">There should be 
only one president</assert> 
</rule> 
</pattern>
Use Case Example 
All employees should have less salary than any manager 
(manager = employee in department “Managers”). 
<pattern name="Managers earn more than normal employees"> 
<rule 
context="//cmp:Department[@name!='Managers']/cmp:Employees/com:Employee"> 
<assert test="com:Salary &lt; 
min(//cmp:Department[@name='Managers']/cmp:Employees/com:Employee/com:Salary)"> 
Employee earns too much</assert> 
</rule> 
</pattern>
Use Case Example 
The relation manager and employee is a valid one, so the 
manager of an employee must exist. 
Keep in mind that the president doesn’t have manager! 
<pattern name="Manager does not exist"> 
<rule context="//com:Employee[@manager_id]"> 
<assert test= 
"//cmp:Company/cmp:Department[@name='Managers']/cmp:Employees/com:Employee[@id=c 
urrent()/@manager_id]">No valid manager</assert> 
</rule> 
</pattern>
Use Case Example 
<?xml version="1.0" encoding="UTF-8" ?> 
<schema xmlns="http://www.ascc.net/xml/schematron"> 
<ns uri="http://amis.nl/schematrondemo/company" prefix="cmp" /> 
<ns uri="http://amis.nl/schematrondemo/common" prefix="com" /> 
<pattern name="Managers earn more than normal employees"> 
<rule context= "//cmp:Department[@name!='Managers']/cmp:Employees/com:Employee"> 
<assert test="com:Salary &lt; 
min(//cmp:Department[@name='Managers']/cmp:Employees/com:Employee/com:Salary)">Employee 
earns too much: <value-of select="com:Salary"/></assert> 
</rule> 
</pattern> 
<pattern name="Employee may not be the manager of himself"> 
<rule context="//com:Employee[@manager_id]"> 
<assert test="@manager_id != @id">Employee may not manage himself</assert> 
</rule> 
</pattern> 
<pattern name="All normal employees have a manager"> 
<rule context= 
"//cmp:Company/cmp:Department[@name!='Managers']/cmp:Employees/com:Employee"> 
<assert test="@manager_id">Employee must have a manager</assert> 
</rule> 
</pattern> 
<pattern name="Only one manager without manager, the president"> 
<rule context="//cmp:Company/cmp:Department[@name='Managers']/cmp:Employees"> 
<assert test="count(com:Employee[not(@manager_id)]) = 1">There should be only one 
president</assert> 
...
Demo
28

Más contenido relacionado

Similar a Schematron

SAPS - Semantic AtomPub-based Services
SAPS - Semantic AtomPub-based ServicesSAPS - Semantic AtomPub-based Services
SAPS - Semantic AtomPub-based ServicesMarkus Lanthaler
 
[제1회 루씬 한글분석기 기술세미나] solr로 나만의 검색엔진을 만들어보자
[제1회 루씬 한글분석기 기술세미나] solr로 나만의 검색엔진을 만들어보자[제1회 루씬 한글분석기 기술세미나] solr로 나만의 검색엔진을 만들어보자
[제1회 루씬 한글분석기 기술세미나] solr로 나만의 검색엔진을 만들어보자Donghyeok Kang
 
Spring Web Service, Spring Integration and Spring Batch
Spring Web Service, Spring Integration and Spring BatchSpring Web Service, Spring Integration and Spring Batch
Spring Web Service, Spring Integration and Spring BatchEberhard Wolff
 
Beyond full-text searches with Lucene and Solr
Beyond full-text searches with Lucene and SolrBeyond full-text searches with Lucene and Solr
Beyond full-text searches with Lucene and SolrBertrand Delacretaz
 
Java Web Development with Stripes
Java Web Development with StripesJava Web Development with Stripes
Java Web Development with StripesSamuel Santos
 
Introduction to Prototype JS Framework
Introduction to Prototype JS FrameworkIntroduction to Prototype JS Framework
Introduction to Prototype JS FrameworkMohd Imran
 
Microsoft Accademic Cloud Tour Genova
Microsoft Accademic Cloud Tour GenovaMicrosoft Accademic Cloud Tour Genova
Microsoft Accademic Cloud Tour Genovaantimo musone
 
Java Web Programming [5/9] : EL, JSTL and Custom Tags
Java Web Programming [5/9] : EL, JSTL and Custom TagsJava Web Programming [5/9] : EL, JSTL and Custom Tags
Java Web Programming [5/9] : EL, JSTL and Custom TagsIMC Institute
 
130919 jim cordy - when is a clone not a clone
130919   jim cordy - when is a clone not a clone130919   jim cordy - when is a clone not a clone
130919 jim cordy - when is a clone not a clonePtidej Team
 
Source Code Analysis with SAST
Source Code Analysis with SASTSource Code Analysis with SAST
Source Code Analysis with SASTBlueinfy Solutions
 
Session 2
Session 2Session 2
Session 2alfador
 
Mazda Use of Third Generation Xml Tools
Mazda Use of Third Generation Xml ToolsMazda Use of Third Generation Xml Tools
Mazda Use of Third Generation Xml ToolsCardinaleWay Mazda
 
Rails, Postgres, Angular, and Bootstrap: The Power Stack
Rails, Postgres, Angular, and Bootstrap: The Power StackRails, Postgres, Angular, and Bootstrap: The Power Stack
Rails, Postgres, Angular, and Bootstrap: The Power StackDavid Copeland
 
Red Hat Agile integration Workshop Labs
Red Hat Agile integration Workshop LabsRed Hat Agile integration Workshop Labs
Red Hat Agile integration Workshop LabsJudy Breedlove
 

Similar a Schematron (20)

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
 
SAPS - Semantic AtomPub-based Services
SAPS - Semantic AtomPub-based ServicesSAPS - Semantic AtomPub-based Services
SAPS - Semantic AtomPub-based Services
 
Web based development
Web based developmentWeb based development
Web based development
 
Xsd tutorial
Xsd tutorialXsd tutorial
Xsd tutorial
 
[제1회 루씬 한글분석기 기술세미나] solr로 나만의 검색엔진을 만들어보자
[제1회 루씬 한글분석기 기술세미나] solr로 나만의 검색엔진을 만들어보자[제1회 루씬 한글분석기 기술세미나] solr로 나만의 검색엔진을 만들어보자
[제1회 루씬 한글분석기 기술세미나] solr로 나만의 검색엔진을 만들어보자
 
Spring Web Service, Spring Integration and Spring Batch
Spring Web Service, Spring Integration and Spring BatchSpring Web Service, Spring Integration and Spring Batch
Spring Web Service, Spring Integration and Spring Batch
 
Beyond full-text searches with Lucene and Solr
Beyond full-text searches with Lucene and SolrBeyond full-text searches with Lucene and Solr
Beyond full-text searches with Lucene and Solr
 
Java Web Development with Stripes
Java Web Development with StripesJava Web Development with Stripes
Java Web Development with Stripes
 
Introduction to Prototype JS Framework
Introduction to Prototype JS FrameworkIntroduction to Prototype JS Framework
Introduction to Prototype JS Framework
 
Xml 2
Xml  2 Xml  2
Xml 2
 
Microsoft Accademic Cloud Tour Genova
Microsoft Accademic Cloud Tour GenovaMicrosoft Accademic Cloud Tour Genova
Microsoft Accademic Cloud Tour Genova
 
Java Web Programming [5/9] : EL, JSTL and Custom Tags
Java Web Programming [5/9] : EL, JSTL and Custom TagsJava Web Programming [5/9] : EL, JSTL and Custom Tags
Java Web Programming [5/9] : EL, JSTL and Custom Tags
 
130919 jim cordy - when is a clone not a clone
130919   jim cordy - when is a clone not a clone130919   jim cordy - when is a clone not a clone
130919 jim cordy - when is a clone not a clone
 
Schemas 2 - Restricting Values
Schemas 2 - Restricting ValuesSchemas 2 - Restricting Values
Schemas 2 - Restricting Values
 
Source Code Analysis with SAST
Source Code Analysis with SASTSource Code Analysis with SAST
Source Code Analysis with SAST
 
Session 2
Session 2Session 2
Session 2
 
Mazda Use of Third Generation Xml Tools
Mazda Use of Third Generation Xml ToolsMazda Use of Third Generation Xml Tools
Mazda Use of Third Generation Xml Tools
 
Rails, Postgres, Angular, and Bootstrap: The Power Stack
Rails, Postgres, Angular, and Bootstrap: The Power StackRails, Postgres, Angular, and Bootstrap: The Power Stack
Rails, Postgres, Angular, and Bootstrap: The Power Stack
 
Red Hat Agile integration Workshop Labs
Red Hat Agile integration Workshop LabsRed Hat Agile integration Workshop Labs
Red Hat Agile integration Workshop Labs
 
Introduction to Html5
Introduction to Html5Introduction to Html5
Introduction to Html5
 

Último

COMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online CollaborationCOMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online Collaborationbruanjhuli
 
Building Your Own AI Instance (TBLC AI )
Building Your Own AI Instance (TBLC AI )Building Your Own AI Instance (TBLC AI )
Building Your Own AI Instance (TBLC AI )Brian Pichman
 
Nanopower In Semiconductor Industry.pdf
Nanopower  In Semiconductor Industry.pdfNanopower  In Semiconductor Industry.pdf
Nanopower In Semiconductor Industry.pdfPedro Manuel
 
AI Fame Rush Review – Virtual Influencer Creation In Just Minutes
AI Fame Rush Review – Virtual Influencer Creation In Just MinutesAI Fame Rush Review – Virtual Influencer Creation In Just Minutes
AI Fame Rush Review – Virtual Influencer Creation In Just MinutesMd Hossain Ali
 
OpenShift Commons Paris - Choose Your Own Observability Adventure
OpenShift Commons Paris - Choose Your Own Observability AdventureOpenShift Commons Paris - Choose Your Own Observability Adventure
OpenShift Commons Paris - Choose Your Own Observability AdventureEric D. Schabell
 
AI You Can Trust - Ensuring Success with Data Integrity Webinar
AI You Can Trust - Ensuring Success with Data Integrity WebinarAI You Can Trust - Ensuring Success with Data Integrity Webinar
AI You Can Trust - Ensuring Success with Data Integrity WebinarPrecisely
 
UiPath Platform: The Backend Engine Powering Your Automation - Session 1
UiPath Platform: The Backend Engine Powering Your Automation - Session 1UiPath Platform: The Backend Engine Powering Your Automation - Session 1
UiPath Platform: The Backend Engine Powering Your Automation - Session 1DianaGray10
 
Linked Data in Production: Moving Beyond Ontologies
Linked Data in Production: Moving Beyond OntologiesLinked Data in Production: Moving Beyond Ontologies
Linked Data in Production: Moving Beyond OntologiesDavid Newbury
 
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve DecarbonizationUsing IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve DecarbonizationIES VE
 
NIST Cybersecurity Framework (CSF) 2.0 Workshop
NIST Cybersecurity Framework (CSF) 2.0 WorkshopNIST Cybersecurity Framework (CSF) 2.0 Workshop
NIST Cybersecurity Framework (CSF) 2.0 WorkshopBachir Benyammi
 
Designing A Time bound resource download URL
Designing A Time bound resource download URLDesigning A Time bound resource download URL
Designing A Time bound resource download URLRuncy Oommen
 
Salesforce Miami User Group Event - 1st Quarter 2024
Salesforce Miami User Group Event - 1st Quarter 2024Salesforce Miami User Group Event - 1st Quarter 2024
Salesforce Miami User Group Event - 1st Quarter 2024SkyPlanner
 
Basic Building Blocks of Internet of Things.
Basic Building Blocks of Internet of Things.Basic Building Blocks of Internet of Things.
Basic Building Blocks of Internet of Things.YounusS2
 
Secure your environment with UiPath and CyberArk technologies - Session 1
Secure your environment with UiPath and CyberArk technologies - Session 1Secure your environment with UiPath and CyberArk technologies - Session 1
Secure your environment with UiPath and CyberArk technologies - Session 1DianaGray10
 
Crea il tuo assistente AI con lo Stregatto (open source python framework)
Crea il tuo assistente AI con lo Stregatto (open source python framework)Crea il tuo assistente AI con lo Stregatto (open source python framework)
Crea il tuo assistente AI con lo Stregatto (open source python framework)Commit University
 
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPA
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPAAnypoint Code Builder , Google Pub sub connector and MuleSoft RPA
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPAshyamraj55
 
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCostKubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCostMatt Ray
 
Building AI-Driven Apps Using Semantic Kernel.pptx
Building AI-Driven Apps Using Semantic Kernel.pptxBuilding AI-Driven Apps Using Semantic Kernel.pptx
Building AI-Driven Apps Using Semantic Kernel.pptxUdaiappa Ramachandran
 
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...UbiTrack UK
 

Último (20)

COMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online CollaborationCOMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online Collaboration
 
Building Your Own AI Instance (TBLC AI )
Building Your Own AI Instance (TBLC AI )Building Your Own AI Instance (TBLC AI )
Building Your Own AI Instance (TBLC AI )
 
Nanopower In Semiconductor Industry.pdf
Nanopower  In Semiconductor Industry.pdfNanopower  In Semiconductor Industry.pdf
Nanopower In Semiconductor Industry.pdf
 
AI Fame Rush Review – Virtual Influencer Creation In Just Minutes
AI Fame Rush Review – Virtual Influencer Creation In Just MinutesAI Fame Rush Review – Virtual Influencer Creation In Just Minutes
AI Fame Rush Review – Virtual Influencer Creation In Just Minutes
 
OpenShift Commons Paris - Choose Your Own Observability Adventure
OpenShift Commons Paris - Choose Your Own Observability AdventureOpenShift Commons Paris - Choose Your Own Observability Adventure
OpenShift Commons Paris - Choose Your Own Observability Adventure
 
AI You Can Trust - Ensuring Success with Data Integrity Webinar
AI You Can Trust - Ensuring Success with Data Integrity WebinarAI You Can Trust - Ensuring Success with Data Integrity Webinar
AI You Can Trust - Ensuring Success with Data Integrity Webinar
 
UiPath Platform: The Backend Engine Powering Your Automation - Session 1
UiPath Platform: The Backend Engine Powering Your Automation - Session 1UiPath Platform: The Backend Engine Powering Your Automation - Session 1
UiPath Platform: The Backend Engine Powering Your Automation - Session 1
 
Linked Data in Production: Moving Beyond Ontologies
Linked Data in Production: Moving Beyond OntologiesLinked Data in Production: Moving Beyond Ontologies
Linked Data in Production: Moving Beyond Ontologies
 
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve DecarbonizationUsing IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
 
NIST Cybersecurity Framework (CSF) 2.0 Workshop
NIST Cybersecurity Framework (CSF) 2.0 WorkshopNIST Cybersecurity Framework (CSF) 2.0 Workshop
NIST Cybersecurity Framework (CSF) 2.0 Workshop
 
Designing A Time bound resource download URL
Designing A Time bound resource download URLDesigning A Time bound resource download URL
Designing A Time bound resource download URL
 
Salesforce Miami User Group Event - 1st Quarter 2024
Salesforce Miami User Group Event - 1st Quarter 2024Salesforce Miami User Group Event - 1st Quarter 2024
Salesforce Miami User Group Event - 1st Quarter 2024
 
Basic Building Blocks of Internet of Things.
Basic Building Blocks of Internet of Things.Basic Building Blocks of Internet of Things.
Basic Building Blocks of Internet of Things.
 
Secure your environment with UiPath and CyberArk technologies - Session 1
Secure your environment with UiPath and CyberArk technologies - Session 1Secure your environment with UiPath and CyberArk technologies - Session 1
Secure your environment with UiPath and CyberArk technologies - Session 1
 
Crea il tuo assistente AI con lo Stregatto (open source python framework)
Crea il tuo assistente AI con lo Stregatto (open source python framework)Crea il tuo assistente AI con lo Stregatto (open source python framework)
Crea il tuo assistente AI con lo Stregatto (open source python framework)
 
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPA
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPAAnypoint Code Builder , Google Pub sub connector and MuleSoft RPA
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPA
 
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCostKubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
 
Building AI-Driven Apps Using Semantic Kernel.pptx
Building AI-Driven Apps Using Semantic Kernel.pptxBuilding AI-Driven Apps Using Semantic Kernel.pptx
Building AI-Driven Apps Using Semantic Kernel.pptx
 
20230104 - machine vision
20230104 - machine vision20230104 - machine vision
20230104 - machine vision
 
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...
 

Schematron

  • 1. Business Load Balancing by Complex Message Validation with the Oracle SOA Suite Schematron Emiel Paasschens, AMIS - 7 december UKOUG
  • 2. Emiel Paasschens 1996 August 13,1973 Amarin, 3 months June 7, 2013 Aran, 3 years
  • 3. AMIS Aircraft Maintenance Information System 1991 technology.amis.nl 90
  • 4. Agenda • Early fault detection • Current solution: XSD validation • Validation Gap • Schematron • Schematron in SOA Suite • Simple use case example • Demo
  • 5. Fault Detection The earlier the better! • Reduces load • Decreases monitor ‘pollution’ (logs, monitor screens) • May even prevent system crashes • Response earlier (back to customer) • Lower costs
  • 6. Early Fault Detection in SOA SOA: Webservices, SOAP Early fault detection: The 1st possibility is error detection in accepting the request message.  Validating the request message Request message is XML (SOAP)  XML Validation  XSD (Schema)
  • 7. Current solution: XSD validation XML Schema (XSD): Defines structure of XML including data type of elements and constraints. 1. Structure Element “Person” contains child element “Name” and “Birthdate” in this order. 2. Data type Element “Name” is of String type and element “Birthdate” is of type date. 3. Constraints Element “Name” is at least two characters long. • XSD can be seen as the “ERD” or “DB Design” for XML documents
  • 8. XSD Validation <?xml version="1.0" encoding="UTF-8" ?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://amis.nl/schematrondemo/common" targetNamespace="http://amis.nl/schematrondemo/common" elementFormDefault="qualified"> <xsd:element name="Person"> <xsd:complexType> <xsd:sequence> <xsd:element name="Name"> <xsd:simpleType> <xsd:restriction base="xsd:string"> <xsd:minLength value="2"/> </xsd:restriction> </xsd:simpleType> </xsd:element> <xsd:element name="Birthdate" type="xsd:date"/> </xsd:sequence> </xsd:complexType> </xsd:element> </xsd:schema> Structure
  • 9. XSD Validation <?xml version="1.0" encoding="UTF-8" ?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://amis.nl/schematrondemo/common" targetNamespace="http://amis.nl/schematrondemo/common" elementFormDefault="qualified"> <xsd:element name="Person"> <xsd:complexType> <xsd:sequence> <xsd:element name="Name"> <xsd:simpleType> <xsd:restriction base="xsd:string"> <xsd:minLength value="2"/> </xsd:restriction> </xsd:simpleType> </xsd:element> <xsd:element name="Birthdate" type="xsd:date"/> </xsd:sequence> </xsd:complexType> </xsd:element> </xsd:schema> Type
  • 10. XSD Validation <?xml version="1.0" encoding="UTF-8" ?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://amis.nl/schematrondemo/common" targetNamespace="http://amis.nl/schematrondemo/common" elementFormDefault="qualified"> <xsd:element name="Person"> <xsd:complexType> <xsd:sequence> <xsd:element name="Name"> <xsd:simpleType> <xsd:restriction base="xsd:string"> <xsd:minLength value="2"/> </xsd:restriction> </xsd:simpleType> </xsd:element> <xsd:element name="Birthdate" type="xsd:date"/> </xsd:sequence> </xsd:complexType> </xsd:element> </xsd:schema> Constraints
  • 11. Validation Gap Three types of XML Business Rule Validation: 1. On data / element itself: Data type and (data) constraints  XSD (Even complex data constraints with regular expressions) 2. XML structure: Element names & Hierarchy (child-parent) constraints XSD?  Partial! Optional combinations are difficult (choice combinations) or even impossible. 3. Constraints between elements Typically more Business Rules validations e.g. sum of all percentage attributes in the XML document must be 100. ?? 
  • 12. Schematron • Used for validating an XML Document • Validation of (conditional) structure • Validation between nodes (elements/attributes), Business Rules • Rules are defined in Schematron format which is ‘just’ an XML document • Is built upon XPath expressions  so no new language, only XML and XPath knowledge required! • Specifies the error message (so you are in control of the output) • Is an ISO/IEC Standard: 19757-3 (2006) • Basically is a double XSTL transformation (under the hood)
  • 13. Schematron How does it work: 1. Define the validations with the usage of XPath expressions in an XML document in a fixed format and structure (according to the Schematron XSD). 2. Transform this validations XML with a specific Schematron XSLT into a new XSLT, which ‘contains/implements’ the validations of step 1. (In the SOA Suite this is done ,‘under the hood’, by the Runtime Engine) 3. This generated XSLT (containing the validations) can be used to validate XML data/payload by executing a transformation on it. (In the SOA Suite this is done ,‘under the hood’, by the Runtime Engine) Any output are errors! (these error messages were also specified in step 1). So no output means the data is valid.
  • 14. Schematron Double XSLT transformation: 1. Rules.xml with Schematron.xslt  Rules.xslt 2. Data.xml with Rules.xslt  Result
  • 15. Schematron XML <?xml version="1.0" encoding="UTF-8" ?> <schema xmlns="http://www.ascc.net/xml/schematron"> <pattern name="patternName"> <rule context="x-path"> <assert test="x-path condition">Error message</assert> <report test="x-path condition">Error message</report> ... </rule> </pattern> <pattern name="patternName"> ... </schema>
  • 16. Schematron Example Attribute “abb” of all “Department” elements must be 2 or 3 long. <?xml version="1.0" encoding="UTF-8" ?> <schema xmlns="http://www.ascc.net/xml/schematron"> <pattern name="Number of characters in an abbreviation"> <rule context="//Department"> <report test="string-length(@abb) &lt; 2">There are not enough characters in the abbreviation</report> <report test="string-length(@abb) > 3">There are too much characters in the abbreviation</report> </rule> </pattern> </schema> Just a name Context: ‘starting point’ for the conditions Conditions Error messages
  • 17. Schematron Example The sum of all direct child elements “Percent” under element “Total” must be 100. <?xml version="1.0" encoding="UTF-8" ?> <schema xmlns="http://www.ascc.net/xml/schematron" > <pattern name="Sum equals 100%."> <rule context="//Total"> <assert test="sum(./Percent) = 100">Sum is not 100%.</assert> </rule> </pattern> </schema>
  • 18. Schematron in the SOA Suite • Default filename extension “sch” • Only assert tag, no report tag!  assert=not(report) • Define namespace prefixes with uri tag: <ns uri="http://amis.nl/schematrondemo/company" prefix="cmp" /> • Implemented in Mediator:
  • 19. Use Case Example Company HRM XML file: Company element contains departments which contains employees: • An employee may not be the manager of himself. • All normal employees (so not a manager) must have a manager. • There is only one manager without a manager (so there is only one president). • All employees should have less salary than any manager (manager = employee in department named “Managers”). • The relation of manager and employee is a valid one. This means that the manager of an employee must exist.
  • 20. Use Case Example <Company><Department name="Ground One" abbr="GR1">...</Department> <Department name="Ground Two" abbr="GR2"> <Employees> <Employee id="13" manager_id="20"> <Name>P. Pietersen</Name> <Salary>1550</Salary> </Employee> <Employee id="14" manager_id="20"> <Name>S. Smit</Name> <Salary>1600</Salary> </Employee> </Employees> </Department> <Department name="Managers" abbr="MAN"> <Employees> <Employee id="15"> <Name>M.A. Nager</Name> <Salary>1700</Salary> </Employee> <Employee id="20" manager_id="25"> <Name>L.E. Ader</Name> <Salary>1600</Salary>
  • 21. Use Case Example An employee may not be the manager of himself. <pattern name="Employee may not be the manager of himself"> <rule context="//com:Employee[@manager_id]"> <assert test="@manager_id != @id">Employee may not manage himself</assert> </rule> </pattern>
  • 22. Use Case Example All normal employees (so not a manager) must have a manager. <pattern name="All normal employees have a manager"> <rule context="//cmp:Department[@name!='Managers']/cmp:Employees/com:Employee"> <assert test="@manager_id">Employee must have a manager</assert> </rule> </pattern>
  • 23. Use Case Example There is only one manager without a manager (only one president). <pattern name="Only one manager without manager, mr president"> <rule context="//cmp:Department[@name='Managers']/cmp:Employees"> <assert test="count(com:Employee[not(@manager_id)]) = 1">There should be only one president</assert> </rule> </pattern>
  • 24. Use Case Example All employees should have less salary than any manager (manager = employee in department “Managers”). <pattern name="Managers earn more than normal employees"> <rule context="//cmp:Department[@name!='Managers']/cmp:Employees/com:Employee"> <assert test="com:Salary &lt; min(//cmp:Department[@name='Managers']/cmp:Employees/com:Employee/com:Salary)"> Employee earns too much</assert> </rule> </pattern>
  • 25. Use Case Example The relation manager and employee is a valid one, so the manager of an employee must exist. Keep in mind that the president doesn’t have manager! <pattern name="Manager does not exist"> <rule context="//com:Employee[@manager_id]"> <assert test= "//cmp:Company/cmp:Department[@name='Managers']/cmp:Employees/com:Employee[@id=c urrent()/@manager_id]">No valid manager</assert> </rule> </pattern>
  • 26. Use Case Example <?xml version="1.0" encoding="UTF-8" ?> <schema xmlns="http://www.ascc.net/xml/schematron"> <ns uri="http://amis.nl/schematrondemo/company" prefix="cmp" /> <ns uri="http://amis.nl/schematrondemo/common" prefix="com" /> <pattern name="Managers earn more than normal employees"> <rule context= "//cmp:Department[@name!='Managers']/cmp:Employees/com:Employee"> <assert test="com:Salary &lt; min(//cmp:Department[@name='Managers']/cmp:Employees/com:Employee/com:Salary)">Employee earns too much: <value-of select="com:Salary"/></assert> </rule> </pattern> <pattern name="Employee may not be the manager of himself"> <rule context="//com:Employee[@manager_id]"> <assert test="@manager_id != @id">Employee may not manage himself</assert> </rule> </pattern> <pattern name="All normal employees have a manager"> <rule context= "//cmp:Company/cmp:Department[@name!='Managers']/cmp:Employees/com:Employee"> <assert test="@manager_id">Employee must have a manager</assert> </rule> </pattern> <pattern name="Only one manager without manager, the president"> <rule context="//cmp:Company/cmp:Department[@name='Managers']/cmp:Employees"> <assert test="count(com:Employee[not(@manager_id)]) = 1">There should be only one president</assert> ...
  • 27. Demo
  • 28. 28

Notas del editor

  1. Emiel Paasschens Graduated Aeronautical Engineering in 1996 Java and Oracle specialist since 1999 Oracle Certified Implementation Specialist for SOA Got married in a tricycle and have a son & daughter
  2. Amis Services, www.amis.nl Founded in 1991 90 employees, 2 Aces, 1 Ace Directors Located in Nieuwegein, The Netherlands Oracle EMEA Middleware partner of the year (2014) Blog: technology.amis.nl