base-uri function in schematron for validating xml probatron + saxon
Asked Answered
M

1

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?

Muscovite answered 15/8, 2017 at 12:26 Comment(0)
B
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://mcmap.net/q/1575758/-base-uri-function-in-schematron-for-validating-xml-probatron-saxon by the OP benchpresser under CC BY-SA 3.0.

Beker answered 14/12, 2022 at 8:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.