xsl-list
[Top] [All Lists]

Re: [xsl] null stylesheet?

2014-05-01 09:40:14
Hi Jack,

Yes, what you are describing is a "literal result element as
stylesheet". It is effectively shorthand for an XSLT stylesheet with a
single template rule, matching the root node.

Thus,

<html xmlns:xsl="http://www.w3.org/1999/XSL/Transform";   xsl:version="2.0">
... do your thing ...
</html>

to an XSLT processor, when provided as a stylesheet, is the same as

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; version="2.0">

  <xsl:template match="/">
    <html> ... do your thing ... </html>
  </xsl:template>

</xsl:stylesheet>

This was (one imagines) meant to be a convenience, but it's not used
much TMK. (I may have used it ... once?) This is probably because,
with only one template, such a stylesheet can never execute more than
a simple "pull"; as soon as you need another template you have to
build it out. It may also be at least as confusing to the newcomer as
it is useful. (Namespaces anyone?)

Cheers, Wendell


On Wed, Apr 30, 2014 at 11:10 PM, Kulas, Jack <Jkulas(_at_)lsijax(_dot_)com> 
wrote:
A most timely thread for me.  I just encountered the "simplified stylesheet." 
 I ran into it in the first design-pattern example of Chapter 17, "Stylesheet 
Design Patterns," in Michael's "XSLT2.0 and XP2ath 2.0, 4th ed."  (BTW, when 
can we expect the XSLT 3.0 book?]

The stylesheet there starts with

        <html xmlns:xsl="http://www.w3.org/1999/XSL/Transform";   
xsl:version="2.0">

and has no xsl:stylsheet element.  It was strange to see instances of XSLT 
elements xsl:for-each  and xsl: value-of in that stylesheet without the 
xs:stylesheet element as the outermost element.  I since learned that as long 
as the XSLT namespace is declared and there is an xsl:version attribute in 
its outermost element, which can't be in the XSLT namespace, it's an XSLT 
stylesheet!

Thus the following also counts as an XSLT stylesheet:

        <html xmlns:xsl="http://www.w3.org/1999/XSL/Transform";   
xsl:version="2.0"/>

--Jack Kulas
LSI, Inc
Jacksonvlle, FL

-----Original Message-----
From: Michael Kay [mailto:mike(_at_)saxonica(_dot_)com]

and that works perfectly well. But then I tried the slightly simpler

 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
version="1.0"/>

Yes, that's a legal stylesheet.

But Saxon-HE 9.5.1.3J run from the commandline complains that "The
supplied file does not appear to be a stylesheet"
(this is an error, not a warning; # XTSE0150).


I suspect you got the command line arguments wrong. This message from Saxon 
means that the file supplied as the stylesheet document did not have 
xsl:stylesheet or xsl:transform as its root. In fact more specifically I 
think it means the local name of the root element was not "stylesheet" or 
"transform" - you get a different message if only the namespace is wrong.

Michael Kay
Saxonica

----------------------------------------------------------------------
Disclaimer - This email and any files transmitted with it are proprietary and 
may contain privileged or copyright information. You must not present this 
message to another party without gaining permission from the sender. If you 
are not the intended recipient you must not copy, distribute or use this 
email or the information contained in it for any purpose other than to notify 
us. If you have received this message in error, please notify the sender 
immediately, and delete this email from your system. We do not guarantee that 
this material is free from viruses or any other defects although due care has 
been taken to minimize the risk. Any views expressed in this message are 
those of the individual sender, except where the sender specifically states 
them to be the views of LSI.




-- 
Wendell Piez | http://www.wendellpiez.com
XML | XSLT | electronic publishing
Eat Your Vegetables
_____oo_________o_o___ooooo____ooooooo_^
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--

<Prev in Thread] Current Thread [Next in Thread>
  • Re: [xsl] null stylesheet?, Wendell Piez <=