[whatwg] [WF2] Web Forms 2.0: Repetition and type ID
robin.berjon at expway.fr
Tue Jul 5 12:07:48 PDT 2005
Ian Hickson wrote:
> On Mon, 4 Jul 2005, Robin Berjon wrote:
>>Amongst the tools that have been mentionned was Schematron. Out of the
>>box Schematron can't check a media type, but with a very trivial to
>>write extension function it could. All the rest that you mention seems
>>very much doable. Schematron is built on XPath, which is a very useful
>>and powerful little language.
> Cool. In that case I look forward to a Schematron HTML5 conformance
As fantasai said, RNG+Schematron will be much easier, but yeah they make
for a great validation combo.
> Just out of interest, how would you do the second one above? Making sure
> that in any one document, there is only one <dfn> for each term defined?
Completely untested and looking scary as a regex, but off the top of my
head the following should do the trick. Inside a <rule> matching your
<dfn>, you use <let> to set $title to:
.[not(@title) and count(./*|text()) == 1]/abbr/@title |
string(.[not(@title) and (not(abbr/@title) or count(./*|text()) != 1)])
which should make it contain the value of the string used for the
current <dfn>. Then you put the following in an <assert> inside that rule:
preceding::dfn[@title] != $title and
not(@title) and abbr/@title and (count(./*|text()) == 1)
]/text() != $title and
(not(abbr/@title) or (count(./*|text()) != 1))
]) != $title
> The relevant part of the spec being:
> | Defining term: If the dfn element has a title attribute, then the exact
> | value of that attribute is the term being defined. Otherwise, if it
> | contains exactly one element child node and no child text nodes, and
> | that child element is an abbr element with a title attribute, then the
> | exact value of that attribute is the term being defined. Otherwise, it
> | is the exact textContent of the dfn element that gives the term being
> | defined. [...]
> | There must only be one dfn element per document for each term defined
> | (i.e. there must not be any duplicate terms).
> It's simple to implement that in, e.g., a dedicated perl-based conformance
> checker, but I have no idea how you'd do that in Schematron.
In Perl, one would use some XPath :) Though in Perl one may be combining
smaller XPath expressions with a hash to the same effect (I'm unsure
that would be the clearest way of writing it though).
> You seriously think that nested templates will be common enough for this
> to be a FAQ? Wow. A few months ago people were saying that this would be
> so rarely used that we should take it out!
See fantasai's answer, I fully agree with her.
Senior Research Scientist
More information about the whatwg