Re: infinite loop

Hi Allan,

> While we're on the subject of infinite loops, does anyone have any
> idea how to detect an infinite loop in a schema programatically?
> Particularly, i'd like to use xslt to detect and infinite loop in an
> xsd schema. I've been wondering about this for a while, but haven't
> been able to find anything out by hunting on the web or reading up
> on the subject. So far, the only idea i've had was to recurse
> element by element as if creating an instance document from the
> schema (similar to your chapter in the professional xml schemas
> book, Jeni) and waiting to see if it crashes the processor or not.
> Obviously, I'd prefer not to have to resort to that!

Perhaps you could keep track of which element declarations you've gone
through as you recurse (using generate-id() I guess) and then whenever
you come to an element declaration check to see if it's in that list.
If it is, and the element is required (something that is again a
little fiddly to work out -- you'll have to pass that as a parameter
as well) then the schema involves an infinite loop.

Make sense?

Jeni

---
Jeni Tennison
http://www.jenitennison.com/

Received on Friday, 10 January 2003 07:28:01 UTC