Validate filename
Questions about XML that are not covered by the other forums should go here.
-
- Posts: 159
- Joined: Mon Nov 24, 2014 1:49 pm
- Location: Greven/Germany
Validate filename
Hi,
is it possible to detect forbidden chars in filenames, like '(', ')', 'ä', 'ö', 'ü', etc. with an Oxygen validation scenario?
Best regards,
Stefan
is it possible to detect forbidden chars in filenames, like '(', ')', 'ä', 'ö', 'ü', etc. with an Oxygen validation scenario?
Best regards,
Stefan
stefan-jung.org – Your DITA/DITA-OT XML consultant
-
- Posts: 159
- Joined: Mon Nov 24, 2014 1:49 pm
- Location: Greven/Germany
Re: Validate filename
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.

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>
stefan-jung.org – Your DITA/DITA-OT XML consultant
-
- Posts: 388
- Joined: Thu Jul 01, 2004 12:29 pm
Re: Validate filename
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:
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
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>
http://www.oxygenxml.com/doc/versions/1 ... nario.html
Best Regards,
Octavian
Octavian Nadolu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 9
- Joined: Tue Aug 21, 2012 11:47 pm
Re: Validate filename
Post 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?
-
- Posts: 9
- Joined: Tue Aug 21, 2012 11:47 pm
Re: Validate filename
Post 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.
Return to “General XML Questions”
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