xsl-list
[Top] [All Lists]

Re: Implementing an Blogger-style template using XSLT

2006-02-21 00:18:04
doh!, the thing with a mailing list is you can't ammend you post. Here
is the "finished" version of the template I made for you. That last
one was an old copy from the clipboard.

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
  version="1.0"
  xmlns="http://www.w3.org/1999/xhtml";
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
  xmlns:MBTemplate="http://www.mydomain.com/Template";>

  <xsl:template match="/">
    <html>
      <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
        <title><xsl:value-of select="MBTemplate:sitetitle" /></title>
      </head>
      <body>
        <div id="menucontainer"></div>
        <div id="container">
          <div id="sidebar">
            <h2 id="welcomenote">Welcome to My Site</h2>
            <xsl:apply-templates select="MBTemplate:submenus" />
          </div>
          <div id="main">
            <xsl:value-of select="MBTemplate:sitetitle" />
            <xsl:apply-templates select="MBTemplate:entries" />
          </div>
        </div>
      </body>
    </html>
  </xsl:template>

  <xsl:template match="MBTemplate:submenus">
    <xsl:value-of select="MBTemplate:submenuheader" />
    <ul class="submenu">
      <xsl:apply-templates select="MBTemplate:submenu" />
    </ul>
  </xsl:template>

  <xsl:template match="MBTemplate:submenu">
    <li><xsl:value-of select="MBTemplate:submenulink" /></li>
  </xsl:template>

</xsl:stylesheet>



On 21/02/06, Terence Kearns 
<terence(_dot_)kearns(_at_)canberra(_dot_)edu(_dot_)au> wrote:
Sounds suspiciously like you want us to write your XSLT file for you :D

Okay welll here's a start then (untested). But I'm not gonna do your
homework for you.

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
 version="1.0"
 xmlns="http://www.w3.org/1999/xhtml";
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
 xmlns:MBTemplate="http://www.mydomain.com/Template";>

 <xsl:template match="/">
   <html>
     <head>
       <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
       <title>Document Title</title>
     </head>
     <body>
       <div id="menucontainer"></div>
       <div id="container">
         <div id="sidebar">
           <h2 id="welcomenote">Welcome to My Site</h2>
           <xsl:apply-templates select="BTemplate:submenus" />
         </div>
         <div id="main">
           <MBTemplate:sitetitle/>
           <xsl:apply-templates select="MBTemplate:entries" />
         </div>
       </div>
     </body>
   </html>
 </xsl:template>

 <xsl:template match="BTemplate:submenus">
   <MBTemplate:submenuheader/>
   <ul class="submenu">
     <xsl:apply-templates select="BTemplate:submenu" />
   </ul>
 </xsl:template>

 <xsl:template match="BTemplate:submenu">
   <li><MBTemplate:submenulink/></li>
 </xsl:template>

</xsl:stylesheet>

First, you don't currently have a BTemplate:submenus element to match
on in your source document just like other elements you included in
your template but I not contained in your source. Either you will have
to change your source XML to generate the elements you wish to match
in your templates, or you need to adjust your template references.

Second, I only included a suggested xsl:template for your submenus.
The rest is up to you! Go check out the XSL tutorials at zvon.org -
there would be a tonne more references that I'm sure ppl here would be
happy to provide you.

hint: you will need to define a <xsl:template
match="MBTemplate:entries"> container






On 21/02/06, publicreg(_at_)nascencetech(_dot_)com 
<publicreg(_at_)nascencetech(_dot_)com> wrote:
Hi,

I'm trying to implement a Blogger-style templating system and would like
to get some feedback on whether it's feasible or not. While it's true that
an XSLT file itself would be a template, some of my users are not keen on
learning it and I'm trying to strike some middle ground here.

The premise is this:

The template file would be an extension of XHTML and looks like this:

-------------------------

<?xml version="1.0" encoding="utf-8" ?>
<html xmlns:MBTemplate="http://www.mydomain.com/Template";>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Document Title</title>
</head>
<body>
<div id="menucontainer">
</div>
<div id="container">
       <div id="sidebar">
               <h2 id="welcomenote">Welcome to My Site</h2>
               <MBTemplate:submenus>
                       <MBTemplate:submenu>
                               <MBTemplate:submenuheader />
                               <ul class="submenu">
                                       <li><MBTemplate:submenulink /></li>
                               </ul>
                       </MBTemplate:submenu>
               </MBTemplate:submenus>
       </div>
       <div id="main">
               <MBTemplate:sitetitle />
               <MBTemplate:entries>
                       <MBTemplate:entry>
                               <div class="avatar">
                                       
<p><MBTemplate:userlink><MBTemplate:avatar /><br
/><MBTemplate:username /><br /><MBTemplate:msisdn
/></MBTemplate:userlink></p>
                               </div>
                               <div class="entry">
                                       <div class="entry2">
                                               <div 
class="entry-header"><MBTemplate:entry-title /></div>
                                               <div class="entry-contents">
                                                       
<MBTemplate:entry-contents />
                                               </div>
                                               <div
class="entry-footer"><p><MBTemplate:entry-meta><MBTemplate:entry-date
/></MBTemplate:entry-meta></p></div>
                                       </div>
                               </div>
                       </MBTemplate:entry>
               </MBTemplate:entries>
       </div>
</div>
</body>
</html>


-------------------------

Then, the data input would come in the form of an XML document that looks
like this:

--------------------------

<?xml version="1.0" encoding="utf-8" ?>
<MBData:Output xmlns:MBData="http://www.mydomain.com/MyData";>
       <MBData:Submenu>
               <MBData:Item href="http://www.google.com";>Link 
name</MBData:Item>
       </MBData:Submenu>
       <MBData:Entries>
               <MBData:Entry>
                       <MBData:Title>My Title</MBData:Title>
                       <MBData:Content>My article</MBData:Content>
                       <MBData:PostedData>11th Jan 2005</MBData:PostedData>
               </MBData:Entry>
       </MBData:Entries>
</MBData:Output>

--------------------------

Finally, I'd have an XSLT file that uses the 2 files and then translates
into XHTML code that I can output to the browser.

How, folks? Do you think it's feasible to do this? Would appreciate any
pointers in the right direction.

Thanks!
Wong


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--




--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>