Lists Home |
Date Index |
Kiia Kallio scripsit:
> - Some elements (such as "feConvolveMatrix") have a matrix as their
> parameter. This matrix is defined with two attributes: "order"
> (number-optional-number) and "kernelMatrix" (list of numbers). In
> order for the attributes to be valid, the "kernelMatrix" should have as
> many values as the order defines (for instance order = "3, 2" means
> that the matrix should have 6 values). There are also other cases of
> cross-dependencies like this.
I think that Schematron can handle this, though I am no expert on it.
> - Animation elements ("animate", "set", "animateColor",
> "animateTransform", "animateMotion") have some attributes ("by", "from",
> "to", "values") that define the new values for the animated attribute
> of some other element. The valid values for the attribute depend on the
> target attribute and the target element that has the attribute. For
> instance markup <set xlink:href = "#foobar" attributeName="type"
> to="turbulence" begin="3s" dur="6s"/> is completely valid if the element
> whose id is "foobar" is "feTurbulence". If it happens to be for instance
> "feColorMatrix", this is not valid. "feColorMatrix" does have "type"
> attribute, but "turbulence" is not a valid value for that. (And it
> is not even necessary to define "xlink:href" attribute to specify the
> animated element, but if the attribute is missing, the animation target
> is the parent element.)
I think that this is quite beyond the power of any validator not
written for the purpose, especially given that the xlink:href
attribute contains a general URI, not merely an IDREF.
> - Then there's all kind of little issues where the data to be validated
> is stored in the attribute (for conserving space) although an XML
> representation would be much more nicer and easier to parse. For example:
> <path d="M100,200 C100,100 250,100 250,200 S400,300 400,200" />
> would be much easier to process and validate if it was something like this:
> but unfortunately it isn't. (And I very well understand why, considering
> the space it takes...) So now the validator has to check if there
> is correct amount of numbers after each letter code, if the letter
> codes are valid etc. The valid format can be expressed with a BNF,
> but there are also even more complex ones to validate, such as datetime
> strings in ISO8601 format where BNF is not enough.
Such datetime strings can be handled by W3C XML Schema or RELAX NG.
The path strings are an excellent use case for RELAX NG pluggable
datatypes; you could write a recognizer for them.
> And of course there are all kinds of normal validation issues like
> restricted ranges for numeric values, checking if URI's are valid etc.
WXS and RNG can both handle these.
> So, I'd like to know if any validation schema can handle such things
> like cross- dependencies of attributes, dependencies between attributes
> and element types, and parsing of complex attributes for validating
> them, or (as the designers of various schemas are probably reading
> the list) if there are any plans for the features I'm looking for.
RELAX NG is good at this kind of dependency. It can easily handle
attribute vs. attribute (on the same element) and attributes that
control the possible child elements, using its general choice pattern.
Overall I recommend that you write a RELAX NG schema, starting with the
DTD and converting it to RNG using Trang. Then add restrictions and
refinements, including specifying XML Schema and custom datatypes as
needed; you can then write validators for the custom datatypes.
A few embedded Schematron rules, and you should have 95% of the job done.
It was impossible to inveigle John Cowan <email@example.com>
Georg Wilhelm Friedrich Hegel http://www.ccil.org/~cowan
Into offering the slightest apology http://www.reutershealth.com
For his Phenomenology. --W. H. Auden, from "People" (1953)