In the RelaxNG compact-syntax schema here:
https://github.com/validator/validator/blob/master/schema/html5/rdfa.rnc#L51
…I would like to edit with some fixed rdfa attribute 'property' value in meta
element.
I defined two values like:
common.attrs.rdfa.property.title = attribute property {"dct:title"}
common.attrs.rdfa.property.type = attribute property {"dct:type"}
…these two should be mandatory in meta
element, how this can be done in existing rdfa common.attrs.rdfa.property
list?
I am getting an error while trying to add these..
OK, this is doable as long are you’re willing to accept some limitations. Here’s how:
In the https://github.com/validator/validator/blob/master/schema/html5/meta.rnc#L33 file, change
head.inner
to this:Then the following document will cause no errors:
…but any document that doesn’t have both the
<meta property=dct:title content=…>
element and the<meta property=dct:type content=…>
element—and in that order—will cause an error.So the biggest limitation there is that you can’t use interleave (
&
) but instead you need to require a specific ordering for themeta
elements.The reason for that is what’s already been explained in the questions Interleave In RNC and Can relaxng specify an unordered set of elements with the same name, but different attributes? and at https://www.oasis-open.org/committees/relax-ng/spec-20011203.html#interleave-restrictions:
The gist of it is: there’s a prohibition on interleaving definitions for elements of the same name, and it’s an intentional design restriction added to RelaxNG to make implementation more feasible.
So the above (re)definition of
head.inner
says that an HTMLhead
element is allowed to have:title
elementbase
elementcommon.inner.metadata
, which is any amount ofscript
,noscript
,template
,style
,link
, andmeta
elementsmeta
element with aproperty=dct:title
attributemeta
element with aproperty=dct:type
attributeI think that’s the closest you’re going to get to what you want, as long as you’re using RelaxNG.
Another limitation of it is, it won’t give you very helpful error messages if one of those is missing.
Instead you’ll just get this:
That is, it won’t (well at least jing won’t) tell you the one you’re missing has
property=dct:type
.I think you were having that problem because you were doing this:
…when what you need to be doing instead is this:
…that is, you need to specify the
string
keyword there.But anyway, making changes to
common.attrs.rdfa.property
would never get you what you want as far as requiring documents to have both<meta property=dct:title content=…>
and<meta property=dct:type content=…>
elements.All that making changes there would have gotten you (if it you could get past the syntax problems) is, it’d allow specific
dct:title
anddct:type
values for theproperty
attribute.