XML.orgXML.org
FOCUS AREAS |XML-DEV |XML.org DAILY NEWSLINK |REGISTRY |RESOURCES |ABOUT
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.

Wow!

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:

<Book>
               
<Title>The First and Last Freedom</Title>
               
<Title>A book that has influenced me since I was a child</Title>
               
<Author>J. Krishnamurti</Author>
               
<Date>1954</Date>
               
<ISBN>0-06-064831-7</ISBN>
               
<Publisher>Harper &amp; Row</Publisher>
</Book>

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

Neat!

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