Unable to use variable in href for sch:include
Posted: Fri May 13, 2016 7:58 pm
I am trying to make our schema's easier to use on mirrored/chached sites with multiple different URLs.
I realized that one way to do this might be to use relative path hrefs.
I am trying to use a variable, that could be set once in a schema, essentially a $baseURL variable, then to use that in the href attribute for include elements.
When I do this, I get the following errors on include href's using variables constructed with the $baseURL:
Unable to open referenced included file: $path1
Unable to open referenced included file: $path2
I use variables for paths in other scenarios that work fine:
Below is the example of what I am trying to do. Is my syntax wrong or is it not possible to use a variable for the href on an include?
I have commented out the include statements that use $path1 and $path2 because I can't execute with those present as they yield the errors listed above.
I also listed, in comments, the output of the report element in variableDemo.sch showing that the $path1 and $path2 variables are set correctly.
So, specifying the href on an include w/o using a variable works, but using a variable doesn't.
Help please!
Also, so you know of any document or online resource that has really thorough documentation on Schematron Syntax?
I have looked at a lot of places and there are snippets here and there, but to try to find and example of something like this that tells you when to use single quotes, double quotes or single quotes wrapped in double qoutes, I have not been able to find.
Here is the included schema:
Thanks for your help.
Rich Wood
I realized that one way to do this might be to use relative path hrefs.
I am trying to use a variable, that could be set once in a schema, essentially a $baseURL variable, then to use that in the href attribute for include elements.
When I do this, I get the following errors on include href's using variables constructed with the $baseURL:
Unable to open referenced included file: $path1
Unable to open referenced included file: $path2
I use variables for paths in other scenarios that work fine:
Code: Select all
<sch:let name="refPath"
value="'http://docs.ca.myCompany.com:8180/DDMFRegistryService/registry/XML/dataProviders'"/>
<sch:let name="refXmlFilename"
value="document($refPath)"/>
I have commented out the include statements that use $path1 and $path2 because I can't execute with those present as they yield the errors listed above.
I also listed, in comments, the output of the report element in variableDemo.sch showing that the $path1 and $path2 variables are set correctly.
So, specifying the href on an include w/o using a variable works, but using a variable doesn't.
Help please!
Also, so you know of any document or online resource that has really thorough documentation on Schematron Syntax?
I have looked at a lot of places and there are snippets here and there, but to try to find and example of something like this that tells you when to use single quotes, double quotes or single quotes wrapped in double qoutes, I have not been able to find.
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<sch:schema xmlns:sch="http://purl.oclc.org/dsdl/schematron" queryBinding="xslt2">
<sch:ns uri="http://www.w3.org/2001/XMLSchema-instance" prefix="isx"/>
<sch:let name="baseURL" value="'//nw/data/dast/documentation/Projects/DDMF/Schematron/SchematronSchemasEtc/base'"/>
<sch:let name="path1"
value="concat($baseURL,'/variableDemo.sch#variableDemo')"/>
<sch:let name="path2"
value="'//nw/data/dast/documentation/Projects/DDMF/Schematron/SchematronSchemasEtc/base/variableDemo.sch#variableDemo'"/>
<!--
<sch:include href="$path1"/>
<sch:include href="$path2"/>
-->
<sch:include
href="//nw/data/dast/documentation/Projects/DDMF/Schematron/SchematronSchemasEtc/base/variableDemo.sch#variableDemo"/>
<!--
The value of $path1 is: //nw/data/dast/documentation/Projects/DDMF/Schematron/SchematronSchemasEtc/base/variableDemo.sch#variableDemo :
The value of $path2 is: //nw/data/dast/documentation/Projects/DDMF/Schematron/SchematronSchemasEtc/base/variableDemo.sch#variableDemo :
-->
</sch:schema>
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<sch:schema xmlns:sch="http://purl.oclc.org/dsdl/schematron" queryBinding="xslt2">
<sch:ns uri="http://www.w3.org/2001/XMLSchema-instance" prefix="isx"/>
<sch:pattern id="variableDemo">
<sch:rule context="/">
<sch:report test="true()">
The value of $path1 is:
<sch:value-of select="$path1"/> :
The value of $path2 is:
<sch:value-of select="$path2"/> :
</sch:report>
</sch:rule>
</sch:pattern>
</sch:schema>
Thanks for your help.
Rich Wood