SlideShare une entreprise Scribd logo
1  sur  40
Télécharger pour lire hors ligne
Enforcing Business Rules
Automatic Fixes
Understanding and Developing Schematron Quick Fixes
Octavian Nadolu
octavian_nadolu@oxygenxml.com
@OctavianNadolu
Business Rules FixesBusiness Rules Fixes
Overview
● Using Schematron to automatically check
business rules
● Fix proposals for business rules using
Schematron Quick Fix language (SQF)
● How SQF integrates with Schematron
● Introduction to SQF through examples
● SQF use-cases (error correction, refactoring,
automatic tagging, etc.)
Business Rules FixesBusiness Rules Fixes
Enforcing Editing Rules
Business Rules FixesBusiness Rules Fixes
Guiding the User
Business Rules FixesBusiness Rules Fixes
Business Rules
Rules for your documents that cannot be
imposed by the schema
Examples:
● Titles should have content
● Consecutive lists are not allowed
● IDs must follow a certain pattern
● Consecutive notes of a same type
● Too many entries in a table row
● Sections must have IDs
● Titles are too long
● ...
Business Rules FixesBusiness Rules Fixes
Business Rule Types
Various types of business rules:
● Simple style rules
– Styling is not allowed in titles
– Semicolon is not allowed at the end of a list item
– Text in the link and the value of the @href are the same
● Editing consistency rules
– Topic ID must be equal to file name
– All sections should have an @id
– Consecutive lists are not allowed
● Structure rules
– Missing cells in a table
– Too many nested lists
– List contains only one item
● Output related rules
– Lines in codeblocks should not exceed 80 characters.
Business Rules FixesBusiness Rules Fixes
Business Rules Check
● Hard for your team members to remember all
business rules
Business Rules FixesBusiness Rules Fixes
Business Rules Automatic Check
Implement automatic checks for business rules
using Schematron
Business Rules FixesBusiness Rules Fixes
Example
● Implement automatic business rules check in a
simple DITA project
Business Rules FixesBusiness Rules Fixes
Conclusions
● Use Schematron to check the business rules
● Schematron is a ISO standard, can be used in
any other application
● Each project can have its own custom checks
● Extend the framework and add custom rules
Business Rules FixesBusiness Rules Fixes
Business Rules Fix Proposals
● Business rule messages are not always enough
for the user to find a solution
● Solutions to automatically apply business rule
constraints
Business Rules FixesBusiness Rules Fixes
Business Rule Fixes
Implement fix proposals using Schematron
QuickFix (SQF) language
Business Rules FixesBusiness Rules Fixes
Schematron QuickFix Proposals
● User-defined fixes for Schematron errors
● Schematron QuickFix (SQF) language
– Extension of the Schematron language
– SQF initiated by Nico Kutscherauer
www.schematron-quickfix.com
github.com/schematron-quickfix/sqf
Business Rules FixesBusiness Rules Fixes
Schematron Quick Fixes Spec
www.w3.org/community/quickfix
schematron-quickfix.github.io/sqf
Business Rules FixesBusiness Rules Fixes
SQF Extension of Schematron
● Added as Schematron annotations
● Associate fixes with assert and report elements
<rule context="html">
<report test="//comment()" sqf:fix="removeComments">
Comments are not allowed in document.</report>
<sqf:fix id="removeComments" role="delete">
<sqf:description>
<sqf:title>Remove all comments</sqf:title>
<sqf:p>Remove all comment nodes from the current document</sqf:p>
</sqf:description>
<sqf:delete match="//comment()"/>
</sqf:fix>
</rule>
Business Rules FixesBusiness Rules Fixes
Schematron QuickFix (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="text()"/>
</sqf:fix>
Operation
ID
Description
Title
Business Rules FixesBusiness Rules Fixes
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
Business Rules FixesBusiness Rules Fixes
Introduction to SQF through
examples
Business Rules FixesBusiness Rules Fixes
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
Business Rules FixesBusiness Rules Fixes
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>
Business Rules FixesBusiness Rules Fixes
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
Business Rules FixesBusiness Rules Fixes
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>
Business Rules FixesBusiness Rules Fixes
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
Business Rules FixesBusiness Rules Fixes
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>
Business Rules FixesBusiness Rules Fixes
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
Business Rules FixesBusiness Rules Fixes
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>
Business Rules FixesBusiness Rules Fixes
Conclusions
● Schematron QuickFix language is simple
● You can define custom fixes for your project
● Just 4 types of operations
Business Rules FixesBusiness Rules Fixes
User Entry
● Ask the user what value to insert
The list must have an ID
Specify an ID for the list
Business Rules FixesBusiness Rules Fixes
User Entry
● <sqf:user-entry> - defines a value that must be
set manually by the user
<rule context="ul">
<assert test="@id" sqf:fix="addID">The list must have an ID</assert>
<sqf:fix id="addID">
<sqf:description><sqf:title>Specify an ID for the list</sqf:title></sqf:description>
<sqf:user-entry name="listID">
<sqf:description>sqf:title>Enter the ID</sqf:title></sqf:description>
</sqf:user-entry>
<sqf:add node-type="attribute" target="id" select="$listID"/>
</sqf:fix>
</rule>
Business Rules FixesBusiness Rules Fixes
Complex Operations
● Use SQF, Schematron and XSLT to create
complex operations
Business Rules FixesBusiness Rules Fixes
Complex Operation Example 1
● Missing cells in a table
Add enough empty cells on each row
Cells are missing from table
Business Rules FixesBusiness Rules Fixes
Complex Operation Example 1
● Add the missing cells from a table
<sqf:fix id="addCells">
<sqf:description>
<sqf:title>Add enough empty cells on each row</sqf:title>
</sqf:description>
<sqf:add match="//row" position="last-child">
<sch:let name="columnNo" value="count(entry)"/>
<xsl:for-each select="1 to ($reqColumsNo - $columnNo)">
<entry/>
</xsl:for-each>
</sqf:add>
</sqf:fix>
Business Rules FixesBusiness Rules Fixes
Complex Operation Example 2
● Automatic tagging Link detected in the current element
Convert text link to xref
Business Rules FixesBusiness Rules Fixes
Complex Operation Example 2
● Convert text link to 'xref'
<sqf:fix id="convertToLink">
<xsl:variable name="linkValue">
<xsl:analyze-string select="." regex="(http|www)S+">
<xsl:matching-substring>
<xsl:value-of select="regex-group(0)"/>
</xsl:matching-substring>
</xsl:analyze-string>
</xsl:variable>
<sqf:description>
<sqf:title>Convert '<sch:value-of select="$linkValue"/>' text to xref</sqf:title>
</sqf:description>
<sqf:stringReplace regex="(http|www)S+">
<xref href="{$linkValue}" format="html"/>
</sqf:stringReplace>
</sqf:fix>
Business Rules FixesBusiness Rules Fixes
Other SQF Elements
● call-fix – calls another fix within a fix
● with-param – refers to a parameter of the called fix
● param – defines a parameter for a fix
● fixes – global element that contains fixes
● group – defines a group of fixes that can be referenced
● keep – used to copy the selected nodes
schematron-quickfix.github.io/sqf
Business Rules FixesBusiness Rules Fixes
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
Business Rules FixesBusiness Rules Fixes
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
Business Rules FixesBusiness Rules Fixes
Projects Using SQF
● Dynamic Information Model (DIM) - an
implementation of an intelligent style guide
● Schematron for TEI - collection of Schematron
and SQF resources for TEI
● <oXygen/> DITA framework - built-in framework
in <oXygen/> XML Editor for DITA documents
● <oXygen/> XML userguide - the public version of
the <oXygen/> User Manual
Business Rules FixesBusiness Rules Fixes
Conclusions
● Business rules can be signaled automatically
● Fix proposals created using SQF, a simple and
useful language
● SQF helps users to solve the problems in less
time and with no errors
Business Rules FixesBusiness Rules Fixes
Thank you!
Questions?
<oXygen/> XML Editor
http://www.oxygenxml.com
octavian_nadolu@oxygenxml.com
@OctavianNadolu

Contenu connexe

Similaire à Enforcing Business Rules - Automatic Fixes

Easy migration to a new Chart of Accounts
Easy migration to a new Chart of AccountsEasy migration to a new Chart of Accounts
Easy migration to a new Chart of Accounts
Chitra Kanakaraj
 
MVC & SQL_In_1_Hour
MVC & SQL_In_1_HourMVC & SQL_In_1_Hour
MVC & SQL_In_1_Hour
Dilip Patel
 
TechDays 2013 Jari Kallonen: What's New WebForms 4.5
TechDays 2013 Jari Kallonen: What's New WebForms 4.5TechDays 2013 Jari Kallonen: What's New WebForms 4.5
TechDays 2013 Jari Kallonen: What's New WebForms 4.5
Tieturi Oy
 
Profiling its okay in sql server
Profiling its okay in sql serverProfiling its okay in sql server
Profiling its okay in sql server
unclebiguns
 

Similaire à Enforcing Business Rules - Automatic Fixes (20)

SQL Server 2008 certification
SQL Server 2008 certificationSQL Server 2008 certification
SQL Server 2008 certification
 
Modeling and Testing Dovetail in MagicDraw
Modeling and Testing Dovetail in MagicDrawModeling and Testing Dovetail in MagicDraw
Modeling and Testing Dovetail in MagicDraw
 
Aspects of 10 Tuning
Aspects of 10 TuningAspects of 10 Tuning
Aspects of 10 Tuning
 
Angular 2 at solutions.hamburg
Angular 2 at solutions.hamburgAngular 2 at solutions.hamburg
Angular 2 at solutions.hamburg
 
Easy migration to a new Chart of Accounts
Easy migration to a new Chart of AccountsEasy migration to a new Chart of Accounts
Easy migration to a new Chart of Accounts
 
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
 
Building an Angular 2 App
Building an Angular 2 AppBuilding an Angular 2 App
Building an Angular 2 App
 
MVC & SQL_In_1_Hour
MVC & SQL_In_1_HourMVC & SQL_In_1_Hour
MVC & SQL_In_1_Hour
 
Angular - Chapter 4 - Data and Event Handling
 Angular - Chapter 4 - Data and Event Handling Angular - Chapter 4 - Data and Event Handling
Angular - Chapter 4 - Data and Event Handling
 
Simplifying the Complexity of Salesforce CPQ: Tips & Best Practices
Simplifying the Complexity of Salesforce CPQ: Tips & Best PracticesSimplifying the Complexity of Salesforce CPQ: Tips & Best Practices
Simplifying the Complexity of Salesforce CPQ: Tips & Best Practices
 
QQ And Advance Query
QQ And Advance QueryQQ And Advance Query
QQ And Advance Query
 
Build your website with angularjs and web apis
Build your website with angularjs and web apisBuild your website with angularjs and web apis
Build your website with angularjs and web apis
 
WCF - In a Week
WCF - In a WeekWCF - In a Week
WCF - In a Week
 
Smu bscit sem 4 spring 2015 assignments copy
Smu bscit sem 4 spring 2015 assignments   copySmu bscit sem 4 spring 2015 assignments   copy
Smu bscit sem 4 spring 2015 assignments copy
 
TechDays 2013 Jari Kallonen: What's New WebForms 4.5
TechDays 2013 Jari Kallonen: What's New WebForms 4.5TechDays 2013 Jari Kallonen: What's New WebForms 4.5
TechDays 2013 Jari Kallonen: What's New WebForms 4.5
 
Schematron business rules checks and corrections - updates
Schematron business rules checks and corrections - updatesSchematron business rules checks and corrections - updates
Schematron business rules checks and corrections - updates
 
Primavera integration possibilities Technical overview - Oracle Primavera Col...
Primavera integration possibilities Technical overview - Oracle Primavera Col...Primavera integration possibilities Technical overview - Oracle Primavera Col...
Primavera integration possibilities Technical overview - Oracle Primavera Col...
 
Profiling its okay in sql server
Profiling its okay in sql serverProfiling its okay in sql server
Profiling its okay in sql server
 
TSQL Coding Guidelines
TSQL Coding GuidelinesTSQL Coding Guidelines
TSQL Coding Guidelines
 
Intro to PowerShell Workflow
Intro to PowerShell WorkflowIntro to PowerShell Workflow
Intro to PowerShell Workflow
 

Plus de Octavian Nadolu

Schematron step-by-step
Schematron step-by-stepSchematron step-by-step
Schematron step-by-step
Octavian Nadolu
 

Plus de 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
 
Introduction to Schematron
Introduction to SchematronIntroduction to Schematron
Introduction to 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
 
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
 
Schematron step-by-step
Schematron step-by-stepSchematron step-by-step
Schematron step-by-step
 
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
 

Dernier

introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
VishalKumarJha10
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
mohitmore19
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
VictorSzoltysek
 

Dernier (20)

introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
ManageIQ - Sprint 236 Review - Slide Deck
ManageIQ - Sprint 236 Review - Slide DeckManageIQ - Sprint 236 Review - Slide Deck
ManageIQ - Sprint 236 Review - Slide Deck
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024
 
LEVEL 5 - SESSION 1 2023 (1).pptx - PDF 123456
LEVEL 5   - SESSION 1 2023 (1).pptx - PDF 123456LEVEL 5   - SESSION 1 2023 (1).pptx - PDF 123456
LEVEL 5 - SESSION 1 2023 (1).pptx - PDF 123456
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verifiedSector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdf
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 

Enforcing Business Rules - Automatic Fixes

  • 1. Enforcing Business Rules Automatic Fixes Understanding and Developing Schematron Quick Fixes Octavian Nadolu octavian_nadolu@oxygenxml.com @OctavianNadolu
  • 2. Business Rules FixesBusiness Rules Fixes Overview ● Using Schematron to automatically check business rules ● Fix proposals for business rules using Schematron Quick Fix language (SQF) ● How SQF integrates with Schematron ● Introduction to SQF through examples ● SQF use-cases (error correction, refactoring, automatic tagging, etc.)
  • 3. Business Rules FixesBusiness Rules Fixes Enforcing Editing Rules
  • 4. Business Rules FixesBusiness Rules Fixes Guiding the User
  • 5. Business Rules FixesBusiness Rules Fixes Business Rules Rules for your documents that cannot be imposed by the schema Examples: ● Titles should have content ● Consecutive lists are not allowed ● IDs must follow a certain pattern ● Consecutive notes of a same type ● Too many entries in a table row ● Sections must have IDs ● Titles are too long ● ...
  • 6. Business Rules FixesBusiness Rules Fixes Business Rule Types Various types of business rules: ● Simple style rules – Styling is not allowed in titles – Semicolon is not allowed at the end of a list item – Text in the link and the value of the @href are the same ● Editing consistency rules – Topic ID must be equal to file name – All sections should have an @id – Consecutive lists are not allowed ● Structure rules – Missing cells in a table – Too many nested lists – List contains only one item ● Output related rules – Lines in codeblocks should not exceed 80 characters.
  • 7. Business Rules FixesBusiness Rules Fixes Business Rules Check ● Hard for your team members to remember all business rules
  • 8. Business Rules FixesBusiness Rules Fixes Business Rules Automatic Check Implement automatic checks for business rules using Schematron
  • 9. Business Rules FixesBusiness Rules Fixes Example ● Implement automatic business rules check in a simple DITA project
  • 10. Business Rules FixesBusiness Rules Fixes Conclusions ● Use Schematron to check the business rules ● Schematron is a ISO standard, can be used in any other application ● Each project can have its own custom checks ● Extend the framework and add custom rules
  • 11. Business Rules FixesBusiness Rules Fixes Business Rules Fix Proposals ● Business rule messages are not always enough for the user to find a solution ● Solutions to automatically apply business rule constraints
  • 12. Business Rules FixesBusiness Rules Fixes Business Rule Fixes Implement fix proposals using Schematron QuickFix (SQF) language
  • 13. Business Rules FixesBusiness Rules Fixes Schematron QuickFix Proposals ● User-defined fixes for Schematron errors ● Schematron QuickFix (SQF) language – Extension of the Schematron language – SQF initiated by Nico Kutscherauer www.schematron-quickfix.com github.com/schematron-quickfix/sqf
  • 14. Business Rules FixesBusiness Rules Fixes Schematron Quick Fixes Spec www.w3.org/community/quickfix schematron-quickfix.github.io/sqf
  • 15. Business Rules FixesBusiness Rules Fixes SQF Extension of Schematron ● Added as Schematron annotations ● Associate fixes with assert and report elements <rule context="html"> <report test="//comment()" sqf:fix="removeComments"> Comments are not allowed in document.</report> <sqf:fix id="removeComments" role="delete"> <sqf:description> <sqf:title>Remove all comments</sqf:title> <sqf:p>Remove all comment nodes from the current document</sqf:p> </sqf:description> <sqf:delete match="//comment()"/> </sqf:fix> </rule>
  • 16. Business Rules FixesBusiness Rules Fixes Schematron QuickFix (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="text()"/> </sqf:fix> Operation ID Description Title
  • 17. Business Rules FixesBusiness Rules Fixes 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
  • 18. Business Rules FixesBusiness Rules Fixes Introduction to SQF through examples
  • 19. Business Rules FixesBusiness Rules Fixes 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
  • 20. Business Rules FixesBusiness Rules Fixes 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>
  • 21. Business Rules FixesBusiness Rules Fixes 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
  • 22. Business Rules FixesBusiness Rules Fixes 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>
  • 23. Business Rules FixesBusiness Rules Fixes 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
  • 24. Business Rules FixesBusiness Rules Fixes 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>
  • 25. Business Rules FixesBusiness Rules Fixes 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
  • 26. Business Rules FixesBusiness Rules Fixes 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>
  • 27. Business Rules FixesBusiness Rules Fixes Conclusions ● Schematron QuickFix language is simple ● You can define custom fixes for your project ● Just 4 types of operations
  • 28. Business Rules FixesBusiness Rules Fixes User Entry ● Ask the user what value to insert The list must have an ID Specify an ID for the list
  • 29. Business Rules FixesBusiness Rules Fixes User Entry ● <sqf:user-entry> - defines a value that must be set manually by the user <rule context="ul"> <assert test="@id" sqf:fix="addID">The list must have an ID</assert> <sqf:fix id="addID"> <sqf:description><sqf:title>Specify an ID for the list</sqf:title></sqf:description> <sqf:user-entry name="listID"> <sqf:description>sqf:title>Enter the ID</sqf:title></sqf:description> </sqf:user-entry> <sqf:add node-type="attribute" target="id" select="$listID"/> </sqf:fix> </rule>
  • 30. Business Rules FixesBusiness Rules Fixes Complex Operations ● Use SQF, Schematron and XSLT to create complex operations
  • 31. Business Rules FixesBusiness Rules Fixes Complex Operation Example 1 ● Missing cells in a table Add enough empty cells on each row Cells are missing from table
  • 32. Business Rules FixesBusiness Rules Fixes Complex Operation Example 1 ● Add the missing cells from a table <sqf:fix id="addCells"> <sqf:description> <sqf:title>Add enough empty cells on each row</sqf:title> </sqf:description> <sqf:add match="//row" position="last-child"> <sch:let name="columnNo" value="count(entry)"/> <xsl:for-each select="1 to ($reqColumsNo - $columnNo)"> <entry/> </xsl:for-each> </sqf:add> </sqf:fix>
  • 33. Business Rules FixesBusiness Rules Fixes Complex Operation Example 2 ● Automatic tagging Link detected in the current element Convert text link to xref
  • 34. Business Rules FixesBusiness Rules Fixes Complex Operation Example 2 ● Convert text link to 'xref' <sqf:fix id="convertToLink"> <xsl:variable name="linkValue"> <xsl:analyze-string select="." regex="(http|www)S+"> <xsl:matching-substring> <xsl:value-of select="regex-group(0)"/> </xsl:matching-substring> </xsl:analyze-string> </xsl:variable> <sqf:description> <sqf:title>Convert '<sch:value-of select="$linkValue"/>' text to xref</sqf:title> </sqf:description> <sqf:stringReplace regex="(http|www)S+"> <xref href="{$linkValue}" format="html"/> </sqf:stringReplace> </sqf:fix>
  • 35. Business Rules FixesBusiness Rules Fixes Other SQF Elements ● call-fix – calls another fix within a fix ● with-param – refers to a parameter of the called fix ● param – defines a parameter for a fix ● fixes – global element that contains fixes ● group – defines a group of fixes that can be referenced ● keep – used to copy the selected nodes schematron-quickfix.github.io/sqf
  • 36. Business Rules FixesBusiness Rules Fixes 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
  • 37. Business Rules FixesBusiness Rules Fixes 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
  • 38. Business Rules FixesBusiness Rules Fixes Projects Using SQF ● Dynamic Information Model (DIM) - an implementation of an intelligent style guide ● Schematron for TEI - collection of Schematron and SQF resources for TEI ● <oXygen/> DITA framework - built-in framework in <oXygen/> XML Editor for DITA documents ● <oXygen/> XML userguide - the public version of the <oXygen/> User Manual
  • 39. Business Rules FixesBusiness Rules Fixes Conclusions ● Business rules can be signaled automatically ● Fix proposals created using SQF, a simple and useful language ● SQF helps users to solve the problems in less time and with no errors
  • 40. Business Rules FixesBusiness Rules Fixes Thank you! Questions? <oXygen/> XML Editor http://www.oxygenxml.com octavian_nadolu@oxygenxml.com @OctavianNadolu