Re: [xsl] stylesheet expansion

Subject: Re: [xsl] stylesheet expansion
From: Colin Paul Adams <colin@xxxxxxxxxxxxxxxxxx>
Date: Wed, 26 Dec 2007 23:35:18 +0000
>>>>> "Colin" == Colin Paul Adams <colin@xxxxxxxxxxxxxxxxxx> writes:

    >>> I then tried it on Saxon 9. It reports error XTSE0210, so I
    >>> guess Dr. Kay is ignoring the fragment identifier for the
    >>> purposes of XTSE0210. I guess it can be argued either way with
    >>> that wording, and perhaps it is deliberately ambiguous. The
    >>> main point is that you don't get an infinite recursion whilst
    >>> compiling.

    Colin> I just realized that ignoring the fragment identifier is
    Colin> actually safer (or at least easier).

    Colin> Consider:

    Colin> <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet
    Colin> version="2.0"
    Colin> xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
    Colin> xml:id="me"
    >> 
    Colin>    <xsl:import href="#me" />

    Colin> </xsl:stylesheet>

    Colin> Saxon reports error XTSE0210 whereas Gestalt goes into an
    Colin> infinite loop.

    Colin> So in order to be conformant, Gestalt has somehow to check
    Colin> that the fragment identifier does not refer to a module
    Colin> already in action.

I was worried about lots of different fragment identifiers aliasing to
the same element (with the XPath XPointer scheme, one could probably
come up with a near-infinity of different fragment ids pointing to the
same element).

But in fact this was a bug.

A simple fix was to observe that simply recording the href attribute
is sufficient. Now the first import or include will always pass, but
it is then guaranteed that the same xsl:import or xsl:include will be
processed again, and so the recursion is detected. (For the same
reason, using Abel's trick of junctions or links cannot fool the
processor into missing a genuine recursive import).

So it is perfectly safe to allow this.
-- 
Colin Adams
Preston Lancashire

Current Thread