OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   Validation question

[ Lists Home | Date Index | Thread Index ]

I want to validate SVG content, up to the level that I can be certain that the document
doesn't produce errors in rendering. Basically the only way to do this currently is to
load the document to a viewer and see if it works. I don't want this, but much lighter
solution.

There is only a DTD available for SVG, but I'm looking for some better validation schema.
However, I don't think the validation that SVG requires can be expressed with the ones
(XML Schema, RELAX NG) I have investigated. (Using something else than DTD would of course
require creating that schema, but I still consider that smaller task than writing a custom
validator...)

There are a few problematic things in SVG:

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

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

- 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:
<path>
    <moveto>
        <coordinate x = "100" y = "100" />
    </moveto>
    <curveto>
        <coordinate x = "100" y = "100" />
        <coordinate x = "250" y = "100" />
        <coordinate x = "250" y = "200" />
    </curveto>
    <smoothcurveto>
        <coordinate x = "400" y = "300" />
        <coordinate x = "400" y = "200" />
    </smoothcurveto>
</path>
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.

And of course there are all kinds of normal validation issues like restricted ranges
for numeric values, checking if URI's are valid etc.

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.

I probably have to write some custom code anyway, so I'd also like to know if there is
some validator software that uses a schema that can catch as many errors as possible,
and then use some custom code written by the user for validating the "hard cases".

One option I think would be to construct some sort of XSLT transformation that re-formats
complex attributes to XML that is easier to validate (like the path example above) but I
know very little about XSLT, so I don't really know if it can handle things like this. If
somebody has pointers for cases where this has been succesfully done, I'd be grateful.

Kiia Kallio
Software Engineer
Fathammer Ltd.
http://www.fathammer.com




 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS