Validating the DITA schema from Schematron
Post here questions and problems related to editing and publishing DITA content.
-
- Posts: 922
- Joined: Thu May 02, 2019 2:32 pm
Validating the DITA schema from Schematron
Post by chrispitude »
Hi all,
We want our writers to use RelaxNG schemas, not DTD schemas. I recently asked Octavian how I could enforce this in Schematron.
My original thinking was to try to search from the <!DOCTYPE ...> declaration from Schematron. However, Octavian suggested a solution that instead reports when the <?xml-model ...> RelaxNG schema declaration is missing:
Note that he uses some kind of Saxon function call to get the xml-model PI. The rule applies to the document root element ("/element()").
I would have never figured this out myself, and I wanted to share it here in case it was useful to others!
We want our writers to use RelaxNG schemas, not DTD schemas. I recently asked Octavian how I could enforce this in Schematron.
My original thinking was to try to search from the <!DOCTYPE ...> declaration from Schematron. However, Octavian suggested a solution that instead reports when the <?xml-model ...> RelaxNG schema declaration is missing:
Code: Select all
<?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" xmlns:saxon="http://saxon.sf.net/">
<sch:let name="rngDeclaration" value="processing-instruction('xml-model')
[saxon:get-pseudo-attribute('schematypens')='http://relaxng.org/ns/structure/1.0']"/>
<sch:pattern>
<sch:rule context="/element()">
<sch:assert test="exists($rngDeclaration)">DTD schemas are unsupported in our flow; use a RelaxNG schema instead.</sch:assert>
</sch:rule>
</sch:pattern>
</sch:schema>
I would have never figured this out myself, and I wanted to share it here in case it was useful to others!
Return to “DITA (Editing and Publishing DITA Content)”
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