xsl-list
[Top] [All Lists]

Re: [xsl] accessing xsl document root from an included stylesheet

2009-12-04 09:18:48
2009/12/4 Michael Kay <mike(_at_)saxonica(_dot_)com>:
It's both verbose and inefficient compared with the much simpler

<xsl:variable name="xslmyn" select="document('')/*/namespace::myn" />

Thanks ! I'll fix this.

(..) But there's no way of disovering in an
included module where it was included from.

I read on w3c.org that "the resource located by the href attribute
value is parsed as an XML document, and the children of the
xsl:stylesheet element in this document replace the xsl:include
element in the including document."
Thus I thought the included code could access namespaces aliases of
the main xsl:stylesheet element. Anyway, I was clearly wrong.

However, it all seesm very long-winded to me. Why don't you just do

<xsl:template match="/">
 <xsl:if test="not(myn:rootElement)">
    <xsl:message terminate="yes">Root element must be named myn:rootElement
in the correct namespace</xsl:message>

I think I can not use this alternative, as my grammar is not the main
one : it defines additional attributes and elements that expand the
base grammars (to be clear : XSD and WADL are the base grammars).
Thus, I have no idea of what is the root element, which grammar it
fits, etc. In fact, I know it for *each* of my XSLs, of course, but
not in my case, as I was looking for a generic template to check the
namespace version.

Thanks a lot for your detailed answer and advice, Michael.

Regards,

Jan


Regards,

Michael Kay
http://www.saxonica.com/
http://twitter.com/michaelhkay


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--