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

Re: embedded stylesheets (long post contains code)

Subject: Re: embedded stylesheets (long post contains code)
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Tue, 15 Jan 2002 18:28:49 +0000
Re:  embedded stylesheets (long post contains code)
Hi Chris,

> 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 don't think that you can use embedded stylesheets with IE (or I've
never yet managed to). However, what you can do is embed the *data*
within the *stylesheet* and then get at it using the document()
function.

A very quick example to demonstrate the idea. Here's "test.xml" - a
file that references itself as its own stylesheet. The source data is
embedded within the stylesheet, within the my:data element.

<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="test.xml"?>
<xsl:stylesheet version="1.0" 
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:my="http://www.jenitennison.com/"
                exclude-result-prefixes="my">

<my:data>
  Foo bar
</my:data>

<xsl:template match="/">
  <html>
    <head><title>Test</title></head>
    <body>
      <h1>Here's my heading</h1>
      <xsl:value-of select="document('')/*/my:data" />
    </body>
  </html>
</xsl:template>

</xsl:stylesheet>

[Note that the my:data element has to be an element in a namespace;
you can stop this namespace from being added to the output using the
exclude-result-prefixes attribute as shown above.]

The result (tested in IE 6.0) is the HTML page:

<html>
  <head>
    <title>Test</title>
    <META http-equiv="Content-Type" content="text/html; charset=UTF-16">
  </head>
  <body>
    <h1>Here's my heading</h1>
    Foo bar
  </body>
</html>

Out of interest, why do you need to deliver a single document rather
than two?

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

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.
Email
First Name
Last Name
Company
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.