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

Re: XSL import

Subject: Re: XSL import
From: Abel Online <abel.online@xxxxxxxxx>
Date: Mon, 28 Aug 2006 17:51:23 +0200
import text html
Hi Bernie,

It is not possible to include on any other place than as a top-level element (this counts for both xsl:inclue and xsl:import). Perhaps you can split your XSL and do something like the following and put them in main.xsl:

<xsl:import href="header.xsl" />
<xsl:import href="body.xsl" />
<xsl:import href="footer.xsl" />

Another approach you could use, is using the xsl:apply-templates and call a matching rule from the included xsl file. Something like this (should go in the header.xsl):

<xsl:template match="field/text" mode="header">
  .. do you header thing ...
</xsl:template>

Place the following on the place where you wanted the included XSL:
<xsl:apply-templates select="text/[@name='activeTab']" mode="header" />

Now you can place the xsl:import command anywhere you like (as a top-level element, that is) and you can call the xsl:apply-templates whenever you wanted to "include" the header. The reason I add "mode" attribute is because I think you would otherwise have a conflicting match.

HtH,

Cheers,

Abel Braaksma
http://abelleba.metacarpus.com


Bernie wrote:


Excuse my english, I'll try to explain that as better as I can:

I have a group of XSL that use common HTML and XSL elements. I'd like
to make a new and unique XSL as an include which gathers these common
items.

Concise example:

xml:
===

<?xml version="1.0" encoding="UTF-8"?>
<theForm>
 <fields>
    <text name="activeTab">tab one</text>
    <text name="title">The title of the page</text>
  </fields>
</theForm>

Main XSL:
=======
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" encoding="utf-8" indent="yes"
doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" />


 <xsl:template match="/">
   <html xmlns="http://www.w3.org/1999/xhtml">
   <head>
   <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
   <title>Bla bla bla</title>
   <link href="/css/main.css" rel="stylesheet" type="text/css" />
   </head>
   <body>
     <xsl:apply-templates />
   </body>
   </html>
 </xsl:template>

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

 <xsl:template match="fields">
    <div id="divGenContainer">

<!-- HERE IS WHERE I WANT TO INCLUDE THE HEADER XSL/HTML -->

       <div id="divContents">
            <xsl:value-of select="text[@name='title']" />
       </div>

     </div>
  </xsl:template>

</xsl:stylesheet>


The include file (XSL/HTML) should have some like the following content:
--------------------------------------------------------------------------------------------------------



<xsl:value-of select="text[@name='activeTab']" />



-------


Thanx in advance.
Bernie.




On 8/28/06, Florent Georges <darkman_spam@xxxxxxxx> wrote:


Bernie WROTE:

> How can I insert an XSL into an specific location in another
> (xsl:import) and use sibling tags in both xsl?

  It is maybe my low level of knowledge in English, but I didn't
understand your question.  Could you reformulate?  An simple example
could be more precise than prose.

Regards,

--drkm


























p5.vert.ukl.yahoo.com uncompressed/chunked Mon Aug 28 14:13:42 GMT 2006



___________________________________________________________________________


Dicouvrez un nouveau moyen de poser toutes vos questions quelque soit le sujet !
Yahoo! Questions/Riponses pour partager vos connaissances, vos opinions et vos expiriences.
http://fr.answers.yahoo.com

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-2011 All Rights Reserved.