00:00:08This demonstration covers the editing of a
Schematron schema, using oXygen XML Editor's
00:00:13Content Completion Assistant and predefined
00:00:17Due to its complex processing engine, oXygen
is the only XML editor that offers an error
00:00:23management mechanism capable of pinpointing
errors in XPath expressions.
00:00:29This feature coupled with the ability of finding
errors in the included schema modules,
00:00:34make oXygen the best choice for Schematron
00:00:38In our demonstration we need a Schematron
schema which checks a number of rules for
00:00:43a DocBook document.
00:00:45These rules can be classified as:
00:00:471. Critical requirement rules
00:00:49- The number of words from an "abstract" element
should be between 1 and 100.
00:00:56- The number of items in a "list" should be
between 2 and 10.
00:01:012. Best practices rules
00:01:03- The number of words from an "abstract" element
should be between 3 and 80.
00:01:08- The number of items from a "list" should
be between 3 and 8.
00:01:13Now, we'll create a new Schematron schema.
00:01:17We use the New action available on the toolbar...
00:01:20and look for the Schematron document template...
00:01:27then save it.
00:01:31Next, we'll add a Schematron pattern to enforce
the following rule:
00:01:37"The number of words from an abstract element
should be between 1 and 100."
00:01:43We invoke the CC assistant and insert the
"pattern" element... Now we type the id value.
00:01:56Inside the pattern element we add a "rule"
00:02:01The "context" attribute allows us to specify
when the rule becomes active...
00:02:06in our case it's the "abstract" element.
00:02:10And if the condition fails this is considered
00:02:15Next we'll define a variable that counts the
number of words from an abstract element.
00:02:20Its name is wordNumber...
00:02:22oXygen assists us to define the XPath expression
by offering the XPath functions as proposals.
00:02:29Also, to improve the readability of the document
the XPath expressions are highlighted with
00:02:39Finally, the assertion is made using the "assert"
00:02:46When writing the XPath expression in "test"
attribute, note that the CC assistant proposes
00:02:51also the already declared variable.
00:02:54We check that the number of words is greater
than or equals to 1
00:02:59and less than or equals to 100.
00:03:04If the condition fails, oXygen will display
00:03:09The second critical rule to be added is:
00:03:11The number of items from a list should be
between 2 and 10.
00:03:16In this case we'll add a new pattern using
the code templates support.
00:03:20To see all Schematron code templates press
the CTRL and Space keys.
00:03:26In our case, we choose the template that adds
a pattern with an assert.
00:03:31We name the pattern 'critical_check_list_element'.
00:03:35The rule is active for "orderlist" or "itemizedlist"
elements and if the condition fails, this
00:03:43is considered an error.
00:03:46Now we define a variable which counts the
number of listitem elements.
00:04:01The assert specifies that the number of listitems
in the itemizedList element should be between
00:04:062 and 10.
00:04:10In a similar way we add the patterns for the
best practices rules.
00:04:20An important Schematron feature is the progressive
00:04:24or the validation of constraints in stages,
rather than validating everything at once.
00:04:32This feature is accomplished through the phase
element, which allows us to group more patterns.
00:04:38In our case we need to define two phases,
00:04:41one for each group of rules: critical and
00:04:45First, we create a phase for the critical
00:04:48with the help of code templates.
00:04:51We'll name it "phase_critical"...
00:04:55then add the two critical rule patterns.
00:04:58Note that the defined pattern names are proposed
when editing the value of the pattern attribute.
00:05:08Similarly, we define the second phase for
the best practices rules, named phase_best_practices.
00:05:23We add the two best practices rule patterns.
00:05:29Now we'll see how oXygen helps you to manage
the validation errors.
00:05:38To see this we can modify the document by
referring an XPath function that is not defined.
00:05:45We intentionally modify the name of the "count"
00:05:49As you can see, the error is highlighted as
soon as we modify the document because it
00:05:54is being continuously validated.
00:05:57We revert to the initial function name and
now oXygen reports that the schema is valid.
00:06:02At the end of this demonstration we'll validate
the XML document against the Schematron schema
00:06:07we just created.
00:06:09We choose "Validate with..." from the application
00:06:13and choose docbook_rules.sch.
00:06:17oXygen already analyzed the schema and allows
us to choose from the phases declared in the
00:06:25We choose to apply only the best practices
00:06:29oXygen displays a message in the results view,
which warns us that the XML sample file contains
00:06:34too many list items
00:06:36and one of the best practices rules is broken.
00:06:39To correct the problem, we delete one of the
list items.... and validate again.
00:06:53This time, the document conforms with the
00:06:58And this concludes our demonstration.
00:07:00For more details about the Schematron support
in oXygen XML, make sure you check the related
00:07:05Schematron video demonstrations.
00:07:07Thanks for watching.