[Typo3-dev] Validating TypoScript - Schema vs. DTD
Christian Welzel
gawain at camlann.de
Wed Nov 30 22:35:22 CET 2005
Elmar Hinz wrote:
> Does anybody know if schema do offer something like this?
I dont think that any of this technologies can be used
to validate TS very well.
The problem is that TS is very flexible and extensible. Think
only of the many config-options introduced by extentions...
how do you want to update the schema or dtd to reflect this
new options ?
I think the best approach to validate TS is to write a tree
traversal validator using simple php objects. The syntax is
already checked by the parser while transforming the TS into
the php-Array. So all the validator has to do is to make sure,
all options are existing in the current TS-object.
If the TS looks like
page = PAGE
page.10 = TEXT
page.10.value = Foobar
there have to be two validation objects in php (one for PAGE
and one for TEXT). The flow then looks like that
parse TS and create array
create validator with TS-Array
for each first level child
get type and call the type-validator with child
type-validator: check properties
type-validator: call type-validators for every child (if any)
type-validator: return ok/error
delete validator
end
(you surely got the idea).
this way all typo3-internal TS properties and hierarchies can
be validated without too much programming overhead.
only for extentions there has to be a way for them to register
their validator objects.
--
MfG, Christian Welzel
(Ex-Admin AG DSN Gerokstrasse)
GPG-Key: http://www.camlann.de/key.asc <-> ID: 70A1AD15
Fingerprint: 4F50 19BF 3346 36A6 CFA9 DBDC C268 6D24 70A1 AD15
More information about the TYPO3-dev
mailing list