Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Schematron QuickFix
Nico Kutscherauer
contact@schematron-quickfix.com
@nkutsche
Octavian Nadolu
octavian_nadolu@oxygenxml....
Schematron QuickFixSchematron QuickFix
Error Fixes
● Fixing errors has always been a challenge
● Solutions offered by IDEs
Schematron QuickFixSchematron QuickFix
Fix Proposals
● Using fix proposals to solve errors:
– Better understanding of the ...
Schematron QuickFixSchematron QuickFix
XML Validation Errors
● From the user's perspective the validation error
is compose...
Schematron QuickFixSchematron QuickFix
Fixing XML Validation Errors
● Predefined Errors - defined in the validation
engine...
Schematron QuickFixSchematron QuickFix
Schematron Fix Proposals
● User-defined fixes for Schematron errors
● Schematron Qu...
Schematron QuickFixSchematron QuickFix
Schematron Quick Fixes Spec
www.w3.org/community/quickfix
schematron-quickfix.githu...
Schematron QuickFixSchematron QuickFix
SQF Extension of the Schematron
● Associated with assert and report elements
● Adde...
Schematron QuickFixSchematron QuickFix
Schematron QuickFix (SQF)
<sqf:fix id="resolveBold">
<sqf:description>
<sqf:title>C...
Schematron QuickFixSchematron QuickFix
SQF Benefits
● Create custom quick fixes for errors
Schematron QuickFixSchematron QuickFix
SQF Benefits
● Create custom quick fixes for errors
● Use the power of Schematron a...
Schematron QuickFixSchematron QuickFix
SQF Benefits
● Create custom quick fixes for errors
● Use the power of Schematron a...
Schematron QuickFixSchematron QuickFix
SQF Benefits
● Create custom quick fixes for errors
● Use the power of Schematron a...
Schematron QuickFixSchematron QuickFix
SQF Benefits
● Create custom quick fixes for errors
● Use the power of Schematron a...
Schematron QuickFixSchematron QuickFix
Language Overview
● Small language
● Keep it easy, but extensible
● No knowledge of...
Schematron QuickFixSchematron QuickFix
Language Overview
● Small language
● Keep it easy, but extensible
● No knowledge of...
Schematron QuickFixSchematron QuickFix
Language Structure
● Reference / structure
● User interface
● Activity Elements (op...
Schematron QuickFixSchematron QuickFix
Language Structure
● Reference / structure
● User interface
● Activity Elements (op...
Schematron QuickFixSchematron QuickFix
Learning By Examples
● Five examples are shown
● All to find on
https://github.com/...
Schematron QuickFixSchematron QuickFix
1. Simple Replace
● Replace or unwrap a node
<sch:rule context="b">
<sch:report tes...
Schematron QuickFixSchematron QuickFix
1. Simple Replace
● Replace or unwrap a node
<sch:rule context="b">
<sch:report tes...
Schematron QuickFixSchematron QuickFix
1. Simple Replace
● Replace or unwrap a node
<sch:rule context="b">
<sch:report tes...
Schematron QuickFixSchematron QuickFix
1. Simple Replace
● Replace or unwrap a node
<sch:rule context="b">
<sch:report tes...
Schematron QuickFixSchematron QuickFix
1. Simple Replace
● Replace or unwrap a node
<sch:rule context="b">
<sch:report tes...
Schematron QuickFixSchematron QuickFix
1. Simple Replace
● Replace or unwrap a node
<sch:rule context="b">
<sch:report tes...
Schematron QuickFixSchematron QuickFix
1. Simple Replace
● Replace or unwrap a node
<sch:rule context="b">
<sch:report tes...
Schematron QuickFixSchematron QuickFix
2. User Entries
● User Entry – parameter of the QuickFix
<sch:rule context="title">...
Schematron QuickFixSchematron QuickFix
2. User Entries
● User Entry – parameter of the QuickFix
<sch:rule context="title">...
Schematron QuickFixSchematron QuickFix
3. QuickFix Conditions
● Conditions – provide a QuickFix only if it makes
sense
<sc...
Schematron QuickFixSchematron QuickFix
3. QuickFix Conditions
● Conditions – provide a QuickFix only if it makes
sense
<sc...
Schematron QuickFixSchematron QuickFix
3. QuickFix Conditions
● Conditions – provide a QuickFix only if it makes
sense
<sc...
Schematron QuickFixSchematron QuickFix
4. Dynamic QuickFixes
● Dynamic QuickFixes – in the future
<sch:rule context="head/...
Schematron QuickFixSchematron QuickFix
5. Call QuickFixes
<sqf:fix id="title">
<sqf:call-fix ref="createElementRowAsFirstC...
Schematron QuickFixSchematron QuickFix
Call QuickFixes
● In the first draft:
● Just a prototype
● Not really functional
● ...
Schematron QuickFixSchematron QuickFix
Review
● Structure / Reference
● sqf:fix, @id, @use-when, @sqf:fix, sqf:group, sqf:...
Schematron QuickFixSchematron QuickFix
SQF Implementations
● <oXygen/> XML Editor validation engine
http://www.oxygenxml.c...
Schematron QuickFixSchematron QuickFix
Projects using SQF
● Thieme - publishing company uses a custom
framework to create ...
Schematron QuickFixSchematron QuickFix
Projects using SQF
● Dynamic Information Model (DIM) - an
implementation of an inte...
Schematron QuickFixSchematron QuickFix
Conclusions and Future Plans
● SQF is a simple and useful language
● Helps users to...
Schematron QuickFixSchematron QuickFix
Thank you!
Questions?
contact@schematron-quickfix.com
@nkutsche
octavian_nadolu@oxy...
Upcoming SlideShare
Loading in …5
×

Schematron QuickFix

574 views

Published on

Schematron QuickFix – a simple language to specify the actions that will be used to fix the Schematron detected issues, layered on top of XPath and XSLT, and integrated within Schematron schemas through the annotation support.

The idea of Schematron QuickFix (SQF) was discussed during the XML Prague conference and it started to take shape. It has now reached a point where we have a draft specification available, a W3C community group dedicated to XML Quick Fixes, and two independent SQF implementations. The first draft of the Schematron QuickFix specification was published in April 2015 and it is now available on GitHub (http://schematron-quickfix.github.io/sqf) and within the W3C “Quick-Fix Support for XML Community Group” (https://www.w3.org/community/quickfix/). Schematron QuickFix defines a simple language to specify the actions that are used to fix the detected issues, layered on top of XPath and XSLT, and integrated within Schematron schemas through the Schematron annotation support. In this session, we will present various use cases that are solved with Schematron QuickFixes, ranging from simple to complex, sometimes involving changes in multiple locations within a document, or even in external documents. We will also discuss the language and challenges related to the SQF implementation.

  • Be the first to comment

  • Be the first to like this

Schematron QuickFix

  1. 1. Schematron QuickFix Nico Kutscherauer contact@schematron-quickfix.com @nkutsche Octavian Nadolu octavian_nadolu@oxygenxml.com @OctavianNadolu
  2. 2. Schematron QuickFixSchematron QuickFix Error Fixes ● Fixing errors has always been a challenge ● Solutions offered by IDEs
  3. 3. Schematron QuickFixSchematron QuickFix Fix Proposals ● Using fix proposals to solve errors: – Better understanding of the problem – Fewer (no) mistakes – Saves time (money)
  4. 4. Schematron QuickFixSchematron QuickFix XML Validation Errors ● From the user's perspective the validation error is composed by three things LocationLocation How toHow to fix it ?fix it ? MessageMessage
  5. 5. Schematron QuickFixSchematron QuickFix Fixing XML Validation Errors ● Predefined Errors - defined in the validation engine – Fixes generated from the validation engine – Fixes based on the message (error code) and location ● Custom Errors - defined by the user – Difficult to generate fixes based on message and location – A language to create fixes is more appropriate How toHow to fix it ?fix it ?
  6. 6. Schematron QuickFixSchematron QuickFix Schematron Fix Proposals ● User-defined fixes for Schematron errors ● Schematron QuickFix (SQF) language – Extends the Schematron language – SQF initiated by Nico Kutscherauer www.schematron-quickfix.com github.com/schematron-quickfix/sqf
  7. 7. Schematron QuickFixSchematron QuickFix Schematron Quick Fixes Spec www.w3.org/community/quickfix schematron-quickfix.github.io/sqf
  8. 8. Schematron QuickFixSchematron QuickFix SQF Extension of the Schematron ● Associated with assert and report elements ● Added as Schematron annotations <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>
  9. 9. Schematron QuickFixSchematron QuickFix 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
  10. 10. Schematron QuickFixSchematron QuickFix SQF Benefits ● Create custom quick fixes for errors
  11. 11. Schematron QuickFixSchematron QuickFix SQF Benefits ● Create custom quick fixes for errors ● Use the power of Schematron and XSLT
  12. 12. Schematron QuickFixSchematron QuickFix SQF Benefits ● Create custom quick fixes for errors ● Use the power of Schematron and XSLT ● Create refactoring actions using SQF
  13. 13. Schematron QuickFixSchematron QuickFix SQF Benefits ● Create custom quick fixes for errors ● Use the power of Schematron and XSLT ● Create refactoring actions using SQF ● Fix problems in external documents
  14. 14. Schematron QuickFixSchematron QuickFix SQF Benefits ● Create custom quick fixes for errors ● Use the power of Schematron and XSLT ● Create refactoring actions using SQF ● Fix problems in external documents ● Fixes for any XML documents
  15. 15. Schematron QuickFixSchematron QuickFix Language Overview ● Small language ● Keep it easy, but extensible ● No knowledge of XSLT is needed for simple cases ● Integration of well-known standards for more complex things
  16. 16. Schematron QuickFixSchematron QuickFix Language Overview ● Small language ● Keep it easy, but extensible ● No knowledge of XSLT is needed for simple cases ● Integration of well-known standards for more complex things ● Own Namespace with prefix sqf: http://www.schematron-quickfix.com/validator/process
  17. 17. Schematron QuickFixSchematron QuickFix Language Structure ● Reference / structure ● User interface ● Activity Elements (operations)
  18. 18. Schematron QuickFixSchematron QuickFix Language Structure ● Reference / structure ● User interface ● Activity Elements (operations) ● Generic features
  19. 19. Schematron QuickFixSchematron QuickFix Learning By Examples ● Five examples are shown ● All to find on https://github.com/octavianN/SQFPresentation/tree/master/Samples ● Additional Examples http://www.schematron-quickfix.com/examples.html ● Tutorial http://www.schematron-quickfix.com/quickFix/guide.html
  20. 20. Schematron QuickFixSchematron QuickFix 1. Simple Replace ● Replace or unwrap a node <sch:rule context="b"> <sch:report test="ancestor::b" sqf:fix="italic unwrap"> Bold in bold is not allowed.</sch:report> <sqf:fix id="italic"> <sqf:description> <sqf:title>Change it to italic.</sqf:title> </sqf:description> <sqf:replace match="." node-type="element" target="i" select="node()"/> </sqf:fix> <sqf:fix id="unwrap"> <sqf:description> <sqf:title>Unwrap <sch:name/> element</sqf:title> </sqf:description> <sqf:replace select="node()"/> </sqf:fix> </sch:rule>
  21. 21. Schematron QuickFixSchematron QuickFix 1. Simple Replace ● Replace or unwrap a node <sch:rule context="b"> <sch:report test="ancestor::b" sqf:fix="italic unwrap"> Bold in bold is not allowed.</sch:report> <sqf:fix id="italic"> <sqf:description> <sqf:title>Change it to italic.</sqf:title> </sqf:description> <sqf:replace match="." node-type="element" target="i" select="node()"/> </sqf:fix> <sqf:fix id="unwrap"> <sqf:description> <sqf:title>Unwrap <sch:name/> element</sqf:title> </sqf:description> <sqf:replace select="node()"/> </sqf:fix> </sch:rule>
  22. 22. Schematron QuickFixSchematron QuickFix 1. Simple Replace ● Replace or unwrap a node <sch:rule context="b"> <sch:report test="ancestor::b" sqf:fix="italic unwrap"> Bold in bold is not allowed.</sch:report> <sqf:fix id="italic"> <sqf:description> <sqf:title>Change it to italic.</sqf:title> </sqf:description> <sqf:replace match="." node-type="element" target="i" select="node()"/> </sqf:fix> <sqf:fix id="unwrap"> <sqf:description> <sqf:title>Unwrap <sch:name/> element</sqf:title> </sqf:description> <sqf:replace select="node()"/> </sqf:fix> </sch:rule>
  23. 23. Schematron QuickFixSchematron QuickFix 1. Simple Replace ● Replace or unwrap a node <sch:rule context="b"> <sch:report test="ancestor::b" sqf:fix="italic unwrap"> Bold in bold is not allowed.</sch:report> <sqf:fix id="italic"> <sqf:description> <sqf:title>Change it to italic.</sqf:title> </sqf:description> <sqf:replace match="." node-type="element" target="i" select="node()"/> </sqf:fix> <sqf:fix id="unwrap"> <sqf:description> <sqf:title>Unwrap <sch:name/> element</sqf:title> </sqf:description> <sqf:replace select="node()"/> </sqf:fix> </sch:rule>
  24. 24. Schematron QuickFixSchematron QuickFix 1. Simple Replace ● Replace or unwrap a node <sch:rule context="b"> <sch:report test="ancestor::b" sqf:fix="italic unwrap"> Bold in bold is not allowed.</sch:report> <sqf:fix id="italic"> <sqf:description> <sqf:title>Change it to italic.</sqf:title> </sqf:description> <sqf:replace match="." node-type="element" target="i" select="node()"/> </sqf:fix> <sqf:fix id="unwrap"> <sqf:description> <sqf:title>Unwrap <sch:name/> element</sqf:title> </sqf:description> <sqf:replace select="node()"/> </sqf:fix> </sch:rule>
  25. 25. Schematron QuickFixSchematron QuickFix 1. Simple Replace ● Replace or unwrap a node <sch:rule context="b"> <sch:report test="ancestor::b" sqf:fix="italic unwrap"> Bold in bold is not allowed.</sch:report> <sqf:fix id="italic"> <sqf:description> <sqf:title>Change it to italic.</sqf:title> </sqf:description> <sqf:replace match="." node-type="element" target="i" select="node()"/> </sqf:fix> <sqf:fix id="unwrap"> <sqf:description> <sqf:title>Unwrap <sch:name/> element</sqf:title> </sqf:description> <sqf:replace select="node()"/> </sqf:fix> </sch:rule>
  26. 26. Schematron QuickFixSchematron QuickFix 1. Simple Replace ● Replace or unwrap a node <sch:rule context="b"> <sch:report test="ancestor::b" sqf:fix="italic unwrap"> Bold in bold is not allowed.</sch:report> <sqf:fix id="italic"> <sqf:description> <sqf:title>Change it to italic.</sqf:title> </sqf:description> <sqf:replace match="." node-type="element" target="i" select="node()"/> </sqf:fix> <sqf:fix id="unwrap"> <sqf:description> <sqf:title>Unwrap <sch:name/> element</sqf:title> </sqf:description> <sqf:replace select="node()"/> </sqf:fix> </sch:rule>
  27. 27. Schematron QuickFixSchematron QuickFix 2. User Entries ● User Entry – parameter of the QuickFix <sch:rule context="title"> <sch:assert test="normalize-space(.) != '' " sqf:fix="title" >A title shouldn't be empty.</sch:assert> <sqf:fix id="title"> <sqf:description> <sqf:title>Set a title</sqf:title> <sqf:p>This QuickFix will set a title by using a User Entry.</sqf:p> </sqf:description> <sqf:user-entry name="title" type="xs:string"> <sqf:description> <sqf:title>Please enter the new title.</sqf:title> </sqf:description> </sqf:user-entry> <sqf:replace target="{name()}" node-type="element" select="$title" /> </sqf:fix> </sch:rule>
  28. 28. Schematron QuickFixSchematron QuickFix 2. User Entries ● User Entry – parameter of the QuickFix <sch:rule context="title"> <sch:assert test="normalize-space(.) != '' " sqf:fix="title" >A title shouldn't be empty.</sch:assert> <sqf:fix id="title"> <sqf:description> <sqf:title>Set a title</sqf:title> <sqf:p>This QuickFix will set a title by using a User Entry.</sqf:p> </sqf:description> <sqf:user-entry name="title" type="xs:string"> <sqf:description> <sqf:title>Please enter the new title.</sqf:title> </sqf:description> </sqf:user-entry> <sqf:replace target="{name()}" node-type="element" select="$title" /> </sqf:fix> </sch:rule>
  29. 29. Schematron QuickFixSchematron QuickFix 3. QuickFix Conditions ● Conditions – provide a QuickFix only if it makes sense <sch:rule context="head/title"> <sch:assert test="string-length(normalize-space(.)) le 20 " sqf:fix="title"> A title shouldn't have more than 20 characters.</sch:assert> <sqf:fix id="title" use-when="//h1[1][string-length(.) le 20]"> <sqf:description> <sqf:title> Set the title to "<sch:value-of select="//h1[1]"/>". </sqf:title> </sqf:description> <sqf:replace target="title" node-type="element"> <sch:value-of select="//h1[1]"/> </sqf:replace> </sqf:fix> </sch:rule>
  30. 30. Schematron QuickFixSchematron QuickFix 3. QuickFix Conditions ● Conditions – provide a QuickFix only if it makes sense <sch:rule context="head/title"> <sch:assert test="string-length(normalize-space(.)) le 20 " sqf:fix="title"> A title shouldn't have more than 20 characters.</sch:assert> <sqf:fix id="title" use-when="//h1[1][string-length(.) le 20]"> <sqf:description> <sqf:title> Set the title to "<sch:value-of select="//h1[1]"/>". </sqf:title> </sqf:description> <sqf:replace target="title" node-type="element"> <sch:value-of select="//h1[1]"/> </sqf:replace> </sqf:fix> </sch:rule>
  31. 31. Schematron QuickFixSchematron QuickFix 3. QuickFix Conditions ● Conditions – provide a QuickFix only if it makes sense <sch:rule context="head/title"> <sch:assert test="string-length(normalize-space(.)) le 20 " sqf:fix="title"> A title shouldn't have more than 20 characters.</sch:assert> <sqf:fix id="title" use-when="//h1[1][string-length(.) le 20]"> <sqf:description> <sqf:title> Set the title to "<sch:value-of select="//h1[1]"/>". </sqf:title> </sqf:description> <sqf:replace target="title" node-type="element"> <sch:value-of select="//h1[1]"/> </sqf:replace> </sqf:fix> </sch:rule>
  32. 32. Schematron QuickFixSchematron QuickFix 4. Dynamic QuickFixes ● Dynamic QuickFixes – in the future <sch:rule context="head/title"> <sch:assert test="string-length(normalize-space(.)) le 20 " sqf:fix="title"> A title shouldn't have more than 20 characters.</sch:assert> <sqf:fix id="title" use-for-each="//h1[string-length(.) le 20]"> <sqf:description> <sqf:title> Set the title to "<sch:value-of select="$sqf:current"/>". </sqf:title> </sqf:description> <sqf:replace target="title" node-type="element"> <sch:value-of select="$sqf:current"/> </sqf:replace> </sqf:fix> </sch:rule>
  33. 33. Schematron QuickFixSchematron QuickFix 5. Call QuickFixes <sqf:fix id="title"> <sqf:call-fix ref="createElementRowAsFirstChild"> <sqf:with-param name="match" select="."/> <sqf:with-param name="el" select=" 'col' "/> <sqf:with-param name="count" select="count(max(.//tr/count(td|th)))"/> </sqf:call-fix> </sqf:fix> <sqf:fix id="createElementRowAsFirstChild"> <sqf:param name="match" type="node()*"/> <sqf:param name="el" type="xs:QName"/> <sqf:param name="count" type="xs:integer"/> <sqf:description> <sqf:title>Create a row of <sch:value-of select="$count"/> <sch:name path="$el"/> elements as a first child of the <sch:name path="$match"/> element(s).</sqf:title> </sqf:description> <sqf:add match="$match" position="first-child"> <xsl:for-each select="1 to $count"> <xsl:element name="{$el}"/> </xsl:for-each> </sqf:add> </sqf:fix>
  34. 34. Schematron QuickFixSchematron QuickFix Call QuickFixes ● In the first draft: ● Just a prototype ● Not really functional ● Improvements of the second draft: ● Multiple sqf:call-fix in one sqf:fix ● Use the description of the called fix → Open discussion
  35. 35. Schematron QuickFixSchematron QuickFix Review ● Structure / Reference ● sqf:fix, @id, @use-when, @sqf:fix, sqf:group, sqf:fixes ● Description ● sqf:description, sqf:title, sqf:p ● Activity ● sqf:delete, sqf:replace, sqf:add, sqf:keep, sqf:stringReplace ● Generic ● sqf:call-fix, sqf:with-param, sqf:param, sqf:user-entry, @use-for-each → Only 15 Elements (XSLT 2: 49, Schematron: 21)
  36. 36. Schematron QuickFixSchematron QuickFix 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. 37. Schematron QuickFixSchematron QuickFix 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 producer
  38. 38. Schematron QuickFixSchematron QuickFix 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. 39. Schematron QuickFixSchematron QuickFix Conclusions and Future Plans ● SQF is a simple and useful language ● Helps users to solve the problems in less time and with fewer (no) errors ● Update the SQF specification ● Publish the second draft of the Schematron QuickFix specification
  40. 40. Schematron QuickFixSchematron QuickFix Thank you! Questions? contact@schematron-quickfix.com @nkutsche octavian_nadolu@oxygenxml.com @OctavianNadolu

×