Re: MSIE5b2 compliance with latest XSL-WD?

Subject: Re: MSIE5b2 compliance with latest XSL-WD?
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Wed, 23 Dec 1998 09:20:45 -0500
Here, Paul, is some feedback plus a working stylesheet for your example.

At 98/12/22 16:38 -0800, Biron,Paul V wrote:
>I've had no end to problems, among the biggest is simply getting ANYTHING to
>output,
>even for simple stylesheets.
>
>Included below is the first stylesheet (of any complexity whatsoever) that
>I've been able to get to produce results.

First, as a personal convention (not a software requirement) I changed the
stylesheet reference in "employees.xml" to be as follows:

<?xml version="1.0"?>
<!-- employees.xml -->
<?xml:stylesheet type="text/xsl" href="employees.msxsl" ?>

.... this refers to the stylesheet with the extension "msxsl" instead of
"xsl" as I personally distinguish W3C files (.xsl) from MS files (.msxsl)
in my directory structure.

>	1) without the <xsl:template match="employees"> rule
>	    (i.e. a match on the root level element) in there,
>	    IE5b2 displays only those things generated in the
>		<xsl:template match="/"> rule.
>		
>		WHY?  XT handles it in the way which I believe to be
>		"correct"...that is, there should be no need for this
>		extra rule.
I've learned an explicit catch-all rule is needed:

<xsl:template><xsl:apply-templates/></xsl:template>

.... *AND* (important) this rule goes at the *start* of the program, not
just anywhere, as Microsoft implies behaviour of templates based on
template location in the file (unlike W3C-WD2).
		
>	2) Is it really true that <xsl:apply-template/> doesn't
>	    work for output #PCDATA as I've commented below?  It
>	    certainly appears to be the case to me.  Again, XT
>	    handles the <xsl:apply-templates/> method just fine.

For MS-XSL, yes it really is true ... I've learned an explicit catch-all
rule is needed:

<xsl:template match="textnode()"><xsl:value-of/></xsl:template>

... and I've put both of these at the start of my stylesheets as "default"
behaviours I would expect to have already been there.
	   
>	3) IE5b2 seems to generate "more" HTML than is provided
>	    for in this stylesheet.  

This is something that I personally haven't witnessed.

>By that I mean the following.
>		When you "directly browse" the XML file file in IE5b2,
>		the column widths of the table seem to be set to no
>		wider than the column header text.

This, I believe, is in the standard semantics for HTML pages ... something
I figured I couldn't change without prodigious use of &nbsp; general entities.

>		However, if you load the output of XT's processing
>		of this stylesheet, the IE5b2 lets the longest <td> of
>		any row determine the width of the columns.

I'm witnessing the above behaviour in IE5b2 processing of my stylesheet below.

>     OK, I'll accept that IE5b2 doesn't do "or" in patterns.
>     I think this is documented on SBN.  I'll rewrite this as 4
>     separate templates
>	<xsl:template match="name | birthdate | ss_number | position">

Since all four elements are children of the <employee> element, I chose to
use a short-form that means it is unnecessary to have four separate
templates.  The short form is "employee/*" which reads "all child elements
of the <employee> element" ... though it might mean "all child nodes of the
<employee> element node" (would this include attributes, comments, pis, etc?).


>     in order to get any output of #PCDATA, you have to use
>     <xsl:value-of .../> instead of <xsl:apply-templates/>.

Or use the default behaviour I have described above.

>HELP!!!!

I hope the following does so:

==============================8<--------------------------------
<?xml version="1.0"?>
<!-- employees.msxsl -->

<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl";>

<!-- default behaviour - - - - - - - - - - - - - - - - - - - - - - - - - - -->

<xsl:template><xsl:apply-templates/></xsl:template>
<xsl:template match="textnode()"><xsl:value-of/></xsl:template>

<!-- specific behaviours - - - - - - - - - - - - - - - - - - - - - - - - - -->

<xsl:template match="/">            <!--before doing any element processing-->
	<html>
		<head>
			<title>XSL Test</title>
		</head>
		<body bgcolor="#FFFFFF">
			<table border="1">      <!--start the table and inject header-->
				<tr>
					<th>Name</th>
					<th>DOB</th>
					<th>SSN</th>
					<th>Position</th>
				</tr>
				<xsl:apply-templates/>  <!--inject the rows-->
			</table>
		</body>
	</html>
</xsl:template>

<xsl:template match="employee">     <!--each employee is in a new row-->
	<tr>
		<xsl:apply-templates/>
	</tr>
</xsl:template>

<xsl:template match="employee/*">   <!--all child elements of employee
                                        belong in their own column-->
	<td>
	    <xsl:apply-templates/>
	</td>
</xsl:template>

</xsl:stylesheet>
==============================8<--------------------------------

For my installation of IE5b2 "off the shelf", the above seems to work fine,
producing the following result (modulo the extra spaces I've injected to
keep mail readers from interpreting the HTML codes; to reproduce the
original, just replace all "< " with "<" and it should fall out):

==============================8<--------------------------------
< html>
< head>
< title>XSL Test< /title>
< /head>
< body bgcolor="#FFFFFF">
< table border="1">
< tr>
< th>Name< /th>
< th>DOB< /th>
< th>SSN< /th>
< th>Position< /th>
< /tr>
< tr>
< td>
James Smith< /td>
< td>
1970-09-30< /td>
< td>
555-09-8410< /td>
< td>
file clerk< /td>
< /tr>
< tr>
< td>
Jane Jones< /td>
< td>
1968-03-22< /td>
< td>
388-71-6662< /td>
< td>
marketing manager< /td>
< /tr>
< tr>
< td>
Mary Davis< /td>
< td>
1972-11-09< /td>
< td>
884-99-3192< /td>
< td>
lead engineer< /td>
< /tr>
< /table>
< /body>
< /html>

==============================8<--------------------------------

Good luck with the above, Paul ... I hope it gets you off the ground.

Perhaps if others on the list could suggest improvements to suggested
script above, we can all learn more.  The more examples that are shared,
the better.

........... Ken

p.s. Happy holidays and new year to all!


--
G. Ken Holman         mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Crane Softwrights Ltd.  http://www.CraneSoftwrights.com/s/
Box 266,                                V: +1(613)489-0999
Kars, Ontario CANADA K0A-2E0            F: +1(613)489-0995
Training:   http://www.CraneSoftwrights.com/s/schedule.htm
Resources: http://www.CraneSoftwrights.com/s/resources.htm
Shareware: http://www.CraneSoftwrights.com/s/shareware.htm
Next XSL Training (see training link):   WWW8 - 1999-05-11


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread