Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #107: Validate <meta> data #112

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions geekodoc/sch/2_5.2/geekodoc-v2.sch
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
GeekoDoc Schematron schema v2

Purpose:
Validate elements, attributes, or other structures that are difficult
to validate in the GeekoDoc RNG schema.

Author: Thomas Schraitle, 2023
-->
<s:schema xmlns:s="http://purl.oclc.org/dsdl/schematron"
xmlns:db="http://docbook.org/ns/docbook"
xmlns:pr="http://www.schematron-quickfix.com/validator/process"
queryBinding="xslt"
>
<s:ns prefix="db" uri="http://docbook.org/ns/docbook"/>
<s:ns prefix="xlink" uri="http://www.w3.org/1999/xlink"/>
<s:ns prefix="trans" uri="http://docbook.org/ns/transclusion"/>

<!-- Variables -->
<s:let name="meta-title-length" value="55"/>
<s:let name="meta-description-length" value="150"/>

<s:pattern>
<s:title>Validate meta elements</s:title>
<s:rule context="db:meta[@name='title']">
<s:assert test="string-length(.) &lt;= $meta-title-length">
The element meta[@name="title"] cannot have more than <s:value-of select="$meta-title-length"/> characters.
</s:assert>
</s:rule>

<s:rule context="db:meta[@name='description']">
<s:assert test="string-length(.) &lt;= $meta-description-length">
The element meta[@name="description"] cannot have more than <s:value-of select="$meta-description-length"/> characters.
</s:assert>
</s:rule>
</s:pattern>

</s:schema>