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

Re: [Fwd: xsl:import (was Re: Multiple views on an xml docum

Subject: Re: [Fwd: xsl:import (was Re: Multiple views on an xml document)]
From: Lewis <lewis@xxxxxxxxxxx>
Date: Tue, 07 Nov 2000 08:51:54 -0500
xsl import css
Thank you.  I think I like the first approach (Entity) better as it's just
a stright insert of html code; I don't need to manipulate it.

Thanks again,
Lewis

Jeni Tennison wrote:

> Lewis,
>
> > Along these same lines, I have some html code I want to include in
> > all of my html documents. A small example:
> [amended example]
> > <?xml version="1.0"?>
> > <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> version="1.0">>
> >
> > <style type="text/css" id="NOF_STYLE_SHEET">
> >   DIV#Picture25LYR { position:absolute; visibility:inherit; }
> >   DIV#Picture26LYR { position:absolute; visibility:inherit; }
> >   DIV#Picture27LYR { position:absolute; visibility:inherit; }
> > </style>
> >
> > </xsl:stylesheet>
> >
> > In the xsl file that creates my html, I include the line:
> >
> >   <xsl:import href="test.xsl"/>
>
> xsl:import and xsl:include are designed to allow you to use the
> variables, keys, templates and other XSLT constructs from a stylesheet
> in another stylesheet, *not* to include a particular snippet of XML in
> your stylesheet.
>
> There are two ways of keeping XML snippets in separate files and
> including them in your stylesheet. In both, the snippet is stored in a
> separate file. So, you create an XML file that contains the text that
> you want to include. For example, style.xml might be:
>
> --- style.xml ---
> <style type="text/css" id="NOF_STYLE_SHEET">
>   DIV#Picture25LYR { position:absolute; visibility:inherit; }
>   DIV#Picture26LYR { position:absolute; visibility:inherit; }
>   DIV#Picture27LYR { position:absolute; visibility:inherit; }
> </style>
> ---
>
> The first is to use entities.  Within your stylesheet, declare the
> entity within a DOCTYPE at the top of the page:
>
> <!DOCTYPE xsl:stylesheet [
>   <!ENTITY style SYSTEM 'style.xml'>
> ]>
>
> Then, at the point where you want to include the contents of that
> file, refer to the entity you've defined with an entity reference:
>
> <xsl:template match="/">
>   <html>
>     <head>
>       <title>My Page</title>
>       <!-- CSS styles included here -->
>       &style;
>     </head>
>     <body>
>       ...
>     </body>
>   </html>
> </xsl:template>
>
> The contents of your style.xml file will then be included wherever you
> reference the entity.
>
> The second option is to use the document() function in XSLT to pull in
> the contents of the style.xml file.  The call:
>
>   document('style.xml')
>
> accesses the XML document node, and you can then copy it to insert it
> into your output:
>
> <xsl:template match="/">
>   <html>
>     <head>
>       <title>My Page</title>
>       <!-- CSS styles included here -->
>       <xsl:copy-of select="document('style.xml')/style" />
>     </head>
>     <body>
>       ...
>     </body>
>   </html>
> </xsl:template>
>
> The two approaches each have advantages and disadvantages. The
> entities approach is very useful for inserting any well-formed XML
> into your stylesheet: it could be used to insert five elements, or a
> piece of text, for example. With document(), on the other hand, the
> XML being imported has to be XML, and has to be a *document* - that
> means it has to have one, and only one, element. On the other hand,
> the document() approach allows you more easily to *process* the
> nodes that you pull in, which means that the included document can
> itself be transformed before being outputted.
>
> I hope that this helps,
>
> Jeni
>
> ---
> Jeni Tennison
> http://www.jenitennison.com/

--
Lewis Cunningham
NDS Systems
Tel : 727-538-2250
Mail: lewis@xxxxxxxxxxx
Web : www.ndsapps.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.