Unable to use variable in href for sch:include
This should cover W3C XML Schema, Relax NG and DTD related problems.
-
- Posts: 16
- Joined: Tue Jan 12, 2016 9:41 pm
Unable to use variable in href for sch:include
Post by Richard_Wood »
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
-
- Posts: 388
- Joined: Thu Jul 01, 2004 12:29 pm
Re: Unable to use variable in href for sch:include
Hello,
Yes, it is not possible to use a variable in the value of the href attribute of an include element. The value of the href attribute must be an URI reference.
More information about Schematron you can find on http://www.schematron.com/ website.
ISO Schematron specification: http://www.schematron.com/iso/Schematron.html
There are also some tutorials:
Best Regards,
Octavian
Yes, it is not possible to use a variable in the value of the href attribute of an include element. The value of the href attribute must be an URI reference.
More information about Schematron you can find on http://www.schematron.com/ website.
ISO Schematron specification: http://www.schematron.com/iso/Schematron.html
There are also some tutorials:
- ISO Schematron tutorial (Dave Pawson ) - http://www.dpawson.co.uk/schematron/
Tutorials on Schematron (Roger Costello) - http://www.xfront.com/schematron/index.html
Introducing the Schematron (Uche Ogbuji) - http://uche.ogbuji.net/articles/schematron.xhtml
Best Regards,
Octavian
Octavian Nadolu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service