Re: Setting a Schematron 'let' variable via XProc

Hi Phil,

The issue seems to be that Calabash (if that's what you are using) only 
passes the p:with-params to the iso_svrl_for_xslt2.xsl stylesheet.

Calabash relies on the default ISO Schematron implementation with XSLT2 
binding for Saxon. Validation takes four passes:

1. Transform schema with iso_dsdl_include.xsl => schema with expanded 
inclusions
2. Transform result with iso_abstract_expand.xsl => schema with expanded 
abstract patterns
3. Transform result with iso_svrl_for_xslt2.xsl => XSLT 2 stylesheet
4. Apply stylesheet to document to be validated => SVRL

Apparently, anything that is in a p:with-param will only be passed as an 
xsl:param to pass 3 (iso_svrl_for_xslt2.xsl).

For example, you may specify
<p:with-param name="full-path-notation" select="'2'"/>
in order to get human-friendly location paths in the SVRL.

If you specify
<p:with-param name="allow-foreign" select="'true'"/>
any xsl:* element (in particular) that you use in your schema will be 
forwarded to the result of step 3.

Only then are you – in principle – able to supply parameters to step 4.

If you use this schema (on any document):

   <p:validate-with-schematron name="sch" assert-valid="false">
     <p:input port="schema">
       <p:inline>
         <sch:schema xmlns:sch="http://purl.oclc.org/dsdl/schematron">
           <xsl:param name="foo" select="'bar'"/>
           <sch:pattern>
             <sch:rule id="r1" context="/*">
               <sch:assert test="false()">Value of param: <sch:value-of 
select="$foo"/>
               <!-- might also use xsl:value-of -->
               </sch:assert>
             </sch:rule>
           </sch:pattern>
         </sch:schema>
       </p:inline>
     </p:input>
     <p:input port="parameters">
       <p:empty/>
     </p:input>
     <p:with-param name="allow-foreign" select="'true'"/>
     <p:with-param name="full-path-notation" select="'2'"/>
     <p:with-param name="foo" select="'baz'"/>
   </p:validate-with-schematron>

you would see 'Value of param: baz' in the SVRL if this parameter was 
actually passed in step 4. But it isn’t, not by Calabash, not yet (see 
below).

I see that this xsl:param mechanism is not exactly what you were aiming 
at – which is assigning an externally supplied value instead of a 
default value in a sch:let expression.

But Schematron is not specified like that, and I'm afraid that the 
xsl:param mechanism will get you closest to your target.

It can be enabled by inserting
 for (QName name : params.keySet()) {
             RuntimeValue v = params.get(name);
             transformer.setParameter(name, new 
XdmAtomicValue(v.getString()));
         }
before 
https://github.com/ndw/xmlcalabash1/blob/saxon95/src/com/xmlcalabash/library/ValidateWithSCH.java#L154

I'm not sure whether I should send Norm a pull request for this.

The spec is kind of fuzzy about how Schematron should deal with params:
"The parameters port provides name/value pairs which correspond to 
Schematron external variables."
Try to Google "Schematron external variables" and you'll probably see 
that it's not very well defined.
So I think it is not verboten to pass the same params that have been 
used for step 3 also to step 4, so that people who enabled foreign 
markup can make use of them via xsl:param.

A couple steps back to what you were trying to achieve: have you thought 
about reading the current file path from the input file's base-uri()?

Gerrit


On 08.04.2014 14:14, GOOCH, Phil wrote:
> Hi all
>
> I am trying to set the value of a ‘let’ variable in Schematron via XProc
> without success. Can anyone provide any hints?
>
> My Schematron has the following defined at the top:
>
> <letname="basedir"value="'/'"/>
> <letname="mappings"value="document(concat($basedir,
> 'xsl/mappings/controlled-vocab.xml'))"/>
>
> And I am trying to set the value of the basedir variable via the XProc task:
>
> <p:validate-with-schematronassert-valid="false"name="intermediate-validation"phase="intermediate">
> <p:logport="report"/>
> <p:inputport="schema">
> <p:documenthref="schematron.sch"/>
> </p:input>
> <p:with-paramname="basedir"select="'foo/bar'"/>
> </p:validate-with-schematron>
>
> But this fails to set the value, and basedir remains at its default value.
>
> Is there a way to set Schematron variables via XProc?
>
> Many thanks
>
> Phil
>
> *Phil Gooch*
>
> Senior Language Technologist
>
> Language Technology Group
>
> Global Academic Business, Dictionaries
>
> Oxford University Press | Great Clarendon Street | Oxford OX2 6DP
>
> E: phil.gooch@oup.com
>
> T: +44 (0)1865 354987
>
> M: +44 (0)7876 881998
>
> Oxford University Press (UK) Disclaimer
>
> This message is confidential. You should not copy it or disclose its
> contents to anyone. You may use and apply the information for the
> intended purpose only. OUP does not accept legal responsibility for the
> contents of this message. Any views or opinions presented are those of
> the author only and not of OUP. If this email has come to you in error,
> please delete it, along with any attachments. Please note that OUP may
> intercept incoming and outgoing email communications.
>

-- 
Gerrit Imsieke
Geschäftsführer / Managing Director
le-tex publishing services GmbH
Weissenfelser Str. 84, 04229 Leipzig, Germany
Phone +49 341 355356 110, Fax +49 341 355356 510
gerrit.imsieke@le-tex.de, http://www.le-tex.de

Registergericht / Commercial Register: Amtsgericht Leipzig
Registernummer / Registration Number: HRB 24930

Geschäftsführer: Gerrit Imsieke, Svea Jelonek,
Thomas Schmidt, Dr. Reinhard Vöckler

Received on Tuesday, 8 April 2014 21:33:04 UTC