Page 1 of 1

Validate filename

Posted: Tue Jul 21, 2015 2:11 pm
by xephon
Hi,

is it possible to detect forbidden chars in filenames, like '(', ')', 'ä', 'ö', 'ü', etc. with an Oxygen validation scenario?

Best regards,
Stefan

Re: Validate filename

Posted: Fri Jul 24, 2015 2:13 pm
by xephon
I still do not know, whether it is possible to validate filenames. But now I validate the attribute value of my referring element with Schematron. The result is the same. :wink:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://purl.oclc.org/dsdl/schematron" queryBinding="xslt2">
<pattern>
<rule context="*">
<report test="contains(@href,'ß')">
Do not use special chars in @href "<value-of select="@href"/>".
</report>
</rule>
</pattern>
</schema>

Re: Validate filename

Posted: Mon Jul 27, 2015 11:44 am
by tavy
Hello,

You can validate also the file names using Schematron. To obtain current file name you can use the document-uri() function and then check the characters in the file name. For example you can create a rule like this:

Code: Select all


<rule context="/">
<let name="fileName" value="tokenize(document-uri(/), '/')[last()]"/>
<report test="contains($fileName, encode-for-uri('ß'))">
Do not use special chars in file name "<value-of select="$fileName"/>".
</report>
</rule>
Then you can create a validation scenario and add a new rule that validates you files with the created Schematron. You need to specify your Schematron schema in the "Schema" column from the validation scenario. Read more about how to create a validation scenario in our user manual:
http://www.oxygenxml.com/doc/versions/1 ... nario.html

Best Regards,
Octavian

Re: Validate filename

Posted: Fri Jul 31, 2015 11:04 am
by xephon
Thank you, Octavian. That's great news!

Greetings,
Stefan

Re: Validate filename

Posted: Wed Apr 13, 2016 7:04 pm
by rogerhadley
document-uri(/) returns the uri of the schematron file, not the file the schematron is validating. How do I get the uri of the file being validated?

Re: Validate filename

Posted: Wed Apr 13, 2016 7:13 pm
by rogerhadley
Ah. Never mind. I just figured out my problem. I need to use the fully qualified <sch:*> xpath. Using just <value-of select="$fileName"/> does not work. Using <sch:value-of select="$fileName"/> works.