Subject: Re: [xsl] stylesheet expansion From: Colin Paul Adams <colin@xxxxxxxxxxxxxxxxxx> Date: Wed, 26 Dec 2007 16:31:39 +0000 |
Abel> I am under the impression that step nr (5) should not be Abel> necessary, as you technically do not include the (whole) Abel> same stylesheet (giving you error XTSE0210: "A stylesheet Abel> cannot import itself"), but well, it's what the specs say I Abel> guess. To fool the processor we need a trick: the junction Abel> point/hard link. Alternatives are: using a http location Abel> (different FQDN name) or a local machine name named Abel> differently (i.e., through the hosts file). Having read the spec. I'm under the impression that you do not need to resort to such a trick. Nor indeed hard-code the imports (which make the transformation immobile). So I reduced the length of the hrefs, and saved imports.xsl as: <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:include="http://include" extension-element-prefixes="include"> <xsl:import href="#include-me1" /> <xsl:import href="#include-me2"/> <xsl:template match="/"> <xsl:text>text-main
</xsl:text> <xsl:apply-imports /> </xsl:template> <include:stylesheet use-when="0"> <xsl:stylesheet xml:id="include-me1" version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output omit-xml-declaration="yes" /> <xsl:template match="/"> <xsl:text>text-included-1
</xsl:text> </xsl:template> </xsl:stylesheet> </include:stylesheet> <include:stylesheet use-when="0"> <xsl:stylesheet xml:id="include-me2" version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <xsl:text>text-included-2
</xsl:text> <xsl:next-match /> </xsl:template> </xsl:stylesheet> </include:stylesheet> </xsl:stylesheet> Then: gestalt imports.xsl hello-world.xml yielded: text-main text-included-2 text-included-1 So no junction/link trick is necessary with Gestalt. Of course, using fragment identifiers is not reliable, as this is implementation-defined behaviour. It works on Gestalt, as it supports XPointer syntax (shorthand pointers and element() scheme), on the assumption that the media type is application/xml and that XPointer is applicable to this media type (suppressable with an option). I see that this option may no longer be necessary, as the wording now specifically says XPointer may be supported. 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. P.S. match="/" rather than a name="something"? Not my style (it's also slightly inefficient, depending upon the size of the dummy document). -- Colin Adams Preston Lancashire
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] stylesheet expansion, Abel Braaksma | Thread | Re: [xsl] stylesheet expansion, Abel Braaksma |
Re: [xsl] stylesheet expansion, Abel Braaksma | Date | Re: [xsl] stylesheet expansion, Abel Braaksma |
Month |