1

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..

sideshowbarker
  • 81,827
  • 26
  • 193
  • 197
VSe
  • 919
  • 2
  • 13
  • 29
  • @sideshowbarker Is this doable? – VSe Aug 10 '17 at 14:56
  • Yes but I’ve not had time to look into it yet. I had been hoping someone else here with RelaxNG knowledge might be able to step in and provide and an answer. But if nobody else does soon I’ll make time to answer it – sideshowbarker Aug 10 '17 at 14:58
  • What error are you getting? You can’t make both `common.attrs.rdfa.property.title` and `common.attrs.rdfa.property.type ` mandatory on a `meta` element, because they both resolve to being an attribute with the name `property` but just with different values. And per the RDFa spec, the `property` attribute is allowed to be a “term”, a CURIE, or an absolute URL. So do you want to be more restrictive and only allow the `property` to be `dct:title` or `dct:type`? – sideshowbarker Aug 14 '17 at 02:58
  • @sideshowbarker, Two meta elements should be mandatory with the only options dct:title and dct:type. When declaring this I am getting something like data and string error... – VSe Aug 15 '17 at 02:24

1 Answers1

1

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:

head.inner =
        (       title.elem
        &       base.elem?
        &       common.inner.metadata
        ),
        meta.property.dct.title.elem,
        meta.property.dct.type.elem

meta.property.dct.title.elem =
        element meta { empty & meta.property.dct.title.attrs }
meta.property.dct.title.attrs =
        (       meta.attrs.property.dct.title
        &       meta.name.attrs.content
        )
meta.attrs.property.dct.title =
        attribute property { string "dct:title" }

meta.property.dct.type.elem =
        element meta { empty & meta.property.dct.type.attrs }
meta.property.dct.type.attrs =
        (       meta.attrs.property.dct.type
        &       meta.name.attrs.content
        )
meta.attrs.property.dct.type =
        attribute property { string "dct:type" }

Then the following document will cause no errors:

<!DOCTYPE html>
<html>
<head>
<title>Test</title>
<meta property=dct:title content=bar>
<meta property=dct:type content=bar>
</head>
<body></body>
</html>

…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 the meta 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 HTML head element is allowed to have:

  • an interleave of:
    • a required title element
    • an optional base element
    • common.inner.metadata, which is any amount of script, noscript, template, style, link, and meta elements
  • followed by a required meta element with a property=dct:title attribute
  • followed by a required meta element with a property=dct:type attribute

I 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:

head is missing a required instance of one or more of the following child elements: meta

That is, it won’t (well at least jing won’t) tell you the one you’re missing has property=dct:type.

When declaring this I am getting something like data and string error

I think you were having that problem because you were doing this:

common.attrs.rdfa.property.title = attribute property {"dct:title"}

…when what you need to be doing instead is this:

common.attrs.rdfa.property.title = attribute property {string "dct:title"}

…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 and dct:type values for the property attribute.

sideshowbarker
  • 81,827
  • 26
  • 193
  • 197
  • yes this is what expected. I too facing difficult to make the properties interleave and realized the RNC limitations. Thanks a lot.. – VSe Aug 16 '17 at 07:43