[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

embedded stylesheets (long post contains code)

Subject: embedded stylesheets (long post contains code)
From: "Chris Pearson" <chrisp@xxxxxxxxxxx>
Date: Tue, 15 Jan 2002 11:32:18 -0500
embedded xslt stylesheet
hello list.

I'm trying to distribute a self-contained stylesheet to format and display data on MS IE 5.5 and higher browsers.  (I have to send a single file with an .xml extension)

I am able to generate my desired output with an external stylesheet call (e.g. <?xml-stylesheet type="text/xsl" href="style1.xsl"?> ) where I have one file of xml data and another file for my xslt stylesheet.  However, when I try to embed the stylesheet within the top-level element of my xml data, I no longer see the desired output (a formatted table with values).  I now see a sinlge line of all my node-text values, followed by my html structure (hr and a table hdr row.)

Can IE 5.5. and higher support embedded stylesheets?  What do I need to change in my stylesheet  to display correctly?

Thanks for any opinions / suggestions!

I'm changing these when I embed:
1) I'm adding a filter for the <xsl:stylesheet> nodes wth <xsl:template match="xsl:stylesheet" />
2) I'm changing the processing instruction from {href="style1.xsl"?>} to {href=}#style1"?>}
3) I'm inserting the stylesheet in between the last </body> closing tag and the </root> closing tag.

Sample XML:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="style1.xsl"?>
  <name>My Name</name>
  <part>Part A</part>
  <part>Part B</part>

My external stylesheet:
<xsl:stylesheet id="style1" version="1.0"

<xsl:template match="/">
  <xsl:apply-templates select="//header"/>

<xsl:template match="header">
    <xsl:variable name="count" select="1 + count(preceding::header1)" />
    <xsl:for-each select="//header">
      <xsl:call-template name="head">
        <xsl:with-param name="count" select="$count" />

<xsl:template name="head">
  <xsl:param name="count" />
  <!-- first test if the body belongs with this header -->
  <xsl:if test="(1 + count(preceding-sibling::header))=$count">
    <h1><xsl:value-of select="name" /></h1>
    <xsl:for-each select="following-sibling::body[count(preceding-sibling::header)=$count]">
        <xsl:call-template name="part" />

<xsl:template name="part">
  <h2><xsl:value-of select="part" /></h2>
  <h3>Schedule Detail</h3>  
  <table width='360' border='1'>
  <xsl:for-each select="schedule">
    <xsl:if test="position()=1">
      <td width='120' align='center' valign='bottom'><b>DAY</b></td>
      <td width='120' align='center' valign='bottom'><b>TIME</b></td>
      <td width='120' align='center' valign='bottom'><b>QUANTITY</b></td>
    <xsl:call-template name="sched" />

<xsl:template name="sched">
      <td width='120' align='center' valign='bottom'>
        <xsl:value-of select="date" />
      <td width='11%' align='center' valign='bottom'>
        <xsl:value-of select="time" />
      <td width='11%' align='center' valign='bottom'>
        <xsl:value-of select="qty" />

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

Current Thread


Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
First Name
Last Name
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.