OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]
The awesome power of Schematron: using user-defined XSLT functions inSchematron

Hi Folks,

Did you know that Schematron rules and assertions can call user-defined XSLT functions?

That capability enormously enhances the power of Schematron. It brings the power of a programming language to the task of validating XML instances.


Example: I created a function that, when called with an item in an XML tree, returns the path to that item. For example, call my function with the second <Title> element in this XML instance:

<Title>The First and Last Freedom</Title>
<Title>A book that has influenced me since I was a child</Title>
<Author>J. Krishnamurti</Author>
<Publisher>Harper &amp; Row</Publisher>

and it returns this path: /Book/Title[2]


I can use that function in Schematron.

I want to create a Schematron assertion which checks that the name of each child element of <Book> is unique. If that assertion is violated, I call my function to show the location of the offending child element. Below is the entire Schematron, including my function. The above XML instance violates the assertion and so this is output of Schematron validation:

            Oops! Duplicate element name: /Book/Title[2]

Schematron rocks!











[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 1993-2007 XML.org. This site is hosted by OASIS