Customer function in schematron

Here should go questions about transforming XML with XSLT and FOP.
Posts: 11
Joined: Mon Mar 21, 2016 4:08 pm

Customer function in schematron

Post by cjhukill » Mon Mar 21, 2016 4:26 pm

I am attempting to add a custom function to my schematron rule stylesheet to aid in looking up values in code tables. I continue to receive an error message: "unrecognized element xsl:function from namespace''

At the top of the file, I have the following declarations:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns=""

<sch:ns uri="functions:1.0" prefix="local-fn" />
and the function declaration as:

Code: Select all

<!-- *********************************** Functions *********************** -->
<!-- special variables for lookup table -->
<xsl:key name="Code-Lookup" match="CodeTable" use="Code"/>
<xsl:variable name="codeTables" select="document('LookupCodes.xml')/CodeTable"/>
<!-- function to return an expression to be evaluated in the rule containing the codes from the given code table -->
<xsl:function name="local-fn:BuildLookupExpression" as="xs:string">
<xsl:param name="TableName" as="xs:string"/>
<xsl:for-each select="key('Code-Lookup', $TableName)/Code">
<xsl:value-of select="."/>
<xsl:if test="position() != last()">
<xsl:if test="position() = last()">

in the body, I use the rule:

Code: Select all

<sch:pattern id="SEXValue">
<sch:title>Person Sex</sch:title>
<sch:p class="description">
This field is used to report the gender of the subject.
See SEX Table: [F, G, M, N, X, Y, Z]

<let name="SEXExpression" value="local-fn:BuildLookupExpression('SEX')"/>
<sch:rule context="nc:PersonSexCode">
<let name="SEXString" value="string(.)"/>
<sch:assert test="matches($SEXString, $SEXExpression)">
<sch:value-of select="name(.)" /> must be in the set of: [F, G, M, N, X, Y, Z]
What am I missing?

Posts: 377
Joined: Thu Aug 21, 2003 11:36 am
Location: Craiova

Re: Customer function in schematron

Post by radu_pisoi » Tue Mar 22, 2016 11:47 am


Thank you for contacting us.

You should activate the option 'Allow foreign elements (allow-foreign)' from the 'XML / XML Parser / Schematron' option page. This option is used to pass non-Schematron elements to the generated stylesheet.
Radu Pisoi
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger

Posts: 11
Joined: Mon Mar 21, 2016 4:08 pm

Re: Customer function in schematron

Post by cjhukill » Tue Mar 22, 2016 9:26 pm

Thank for you quick reply. I set that in my environment and all is working as planned. THANK YOU!!

Post Reply