0

I would like to dynamically generate the Schematron see attribute based on the the user home's directory. I could not get this working. Do you have an idea if this is possible? It needs to work in Oxygen XML. I am not sure if this is technically not possible in Schematron, or if this is a bug in Oxygen XML.

<?xml version="1.0" encoding="UTF-8"?>
<sch:schema xmlns:sch="http://purl.oclc.org/dsdl/schematron" queryBinding="xslt2"
    xmlns:sqf="http://www.schematron-quickfix.com/validator/process">
    <sch:pattern>
        <sch:rule context="/">
            <sch:let name="x" value="if (contains(base-uri(), 'myname')) 
                then 'http://www.a.com' 
                else 'http://www.b.com'"/>
            <sch:report test="'a' = 'a'">
                Hello world: "<sch:value-of select="$x"/>"
            </sch:report>
        </sch:rule>
    </sch:pattern>
</sch:schema>

My goal is to generate a user-specific link to a locally deployed style guide, but, as you can see in the screenshot, the variable x is not resolved.

Oxygen XML Results Window

Stefan Jung
  • 1,209
  • 11
  • 20
  • Where is the XSLT code you try to implement? What do you have as input? What is the corresponding output you want and what did you get instead? – Pierre François Feb 06 '23 at 11:58
  • You can test any XML document with this Schematron file, because it matches on the root node and has a dummy rule. Schematron is a dialect of XSLT for validate files, not for transform them. – Stefan Jung Feb 06 '23 at 12:01
  • It sounds like you are trying to use the Schematron validation feature in Oxygen XML to run Schematron validation on an XML document, using the Schematron schema you provided. Is that correct? What output are you seeing vs. expecting? – Joshua Legler Feb 06 '23 at 20:10
  • Hi @JoshuaLegler, I have updated the description and added a screenshot, with some further explanations. – Stefan Jung Feb 07 '23 at 08:49

3 Answers3

1

Maybe you can try to read the “user.home” system property: https://www.saxonica.com/html/documentation12/functions/fn/system-property.html

Radu Coravu
  • 1,754
  • 1
  • 9
  • 8
  • Hi @radu-coravu, Oxygen does not resolve variables in `see` at all. – Stefan Jung Feb 07 '23 at 08:50
  • I looked and I can confirm that it seems we do not expand any type of variable reference or xpath expression inside the @see attribute. I'll add an internal issue for this. If it did wok, the syntax would need to look like what Martin Honnen mentioned "see="{$x}"". – Radu Coravu Feb 08 '23 at 06:53
  • Thank you, Radu. I have fixed this in my question and accept your response as the best answer. – Stefan Jung Feb 09 '23 at 14:27
1

Using Schxslt it seems the syntax of an XSLT attribute value template in the form of e.g. see="{$x}" in Schematron then generates an SVRL report having the URI in the form of e.g.

<svrl:successful-report location="/" see="http://www.b.com" test="'a' = 'a'">
  <svrl:text>
            Hello world
        </svrl:text>
</svrl:successful-report>

I don't know whether oXygen has any integration for Schxslt as a Schematron validator and for rendering the validation result in the form of SVRL.

Martin Honnen
  • 160,499
  • 6
  • 90
  • 110
1

To build on the answer by @radu-coravu, you might be able to get the 'user.home' value by using a function in an external XSLT file:

  1. Use xsl:include in your Schematron file to include the XSLT. See, e.g., https://github.com/AntennaHouse/focheck/blob/43bd5d491d8b985395c94c3c53083770d8c461b6/schematron/fo-property.sch#L23
  2. Write a function in the external XSLT that returns the "user.home" system property value
  3. In your rule in your Schematron, use let to get the return value of the function as a variable value. See, e.g., https://github.com/AntennaHouse/focheck/blob/43bd5d491d8b985395c94c3c53083770d8c461b6/schematron/fo-property.sch#L31
  4. Use the Schematron variable in your assert and report just like any other variable
Tony Graham
  • 7,306
  • 13
  • 20
  • Hello Tony, this can be done without including other stylesheets. This also works, but does not fix my problem with the `see` attribute. `` I have updated my question. – Stefan Jung Feb 09 '23 at 14:25