7

We used probatron and saxon to validate a test xml using a given sch file in our java application. Recently, a new rule has been added to the sch file such as

<let name="foo" value="base-uri()">

and some rules use that value, but $foo contains empty string and the rules fail. Where do I have to set this value? I added xml:base tags to the test xml as stated in https://www.w3.org/TR/xmlbase/ but it did not worked. Do I have to set sth in the java side?

vvvvv
  • 25,404
  • 19
  • 49
  • 81
benchpresser
  • 2,171
  • 2
  • 23
  • 41

1 Answers1

0

We used probatron4j for java based schematron handling:

Java source part:

javax.xml.transform.TransformerFactory t = org.probatron.Utils.getTransformerFactory();
// create xml readers, perfor template processing, apply xslt
// as stated in the probatron4j examples
// ...

t.transform(getCandidateSource(), new StreamResult(baos));

our fix includes:

Source source = new StreamSource(new FileInputStream(..

// or

Source source = new StreamSource(canditateURL.openStream()..

// depending on whether input source is file or url based

// below is the fix, we set path of file or exteral form of the url

source.setSystemId(pathOrUrl);

Final result: The value we set as systemid is set into the return value of the base-uri() function val in the schema.


This answer was posted ahttps://stackoverflow.com/questions/45692818/base-uri-function-in-schematron-for-validating-xml-probatron-saxon by the OP benchpresser under CC BY-SA 3.0.

vvvvv
  • 25,404
  • 19
  • 49
  • 81