OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

docbook message

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]


Subject: Re: [docbook] docbook website features


Am Freitag, 20. August 2004 04:33 schrieb Stefan Seefeld:
> hi there,
>
> I'm looking into using db website for a project and I'm wondering
> whether it provides support for the following use case:
>
> I'd like to be able to update at a single place some information
> concerning the project ('news', 'status', 'releases', etc.), and I'd like
> the website to include some links / paragraph etc. at particular
> places related to this information.
>
> Let's assume I have a 'news' page which I add a new paragraph into
> each time I'v got something new to report. I'd like the website
> generator to pick up the latest news and generate some html paragraph /
> headline into the index.html file (say). Is that possible ?

Its not possible out of the box. But you can use XInclude to include the 
<para> of your news page into the index page like this

<para>Welcome to my page! Latest news:</para>
<xi:include href="news.xml" xpointer="xpointer(//para[@role='latestnews'])"/>

I assume that you use xsltproc and Makefiles to generate your webpage:
then you have to take care that your Makefile recognizes that index.html has 
to be generated whenever news.xml was changed. you will find a modified 
version of makefile-dep.xsl which looks for xml:base attributes and adds 
dependencies to depends.tabular. And of course you have to add --xinclude to 
your xsltproc options in your Makefile. I dont know if it works 
out-of-the-box cause i hacked it a long time ago. but it works for me. it 
just adds all files which are found in xml:base attributes to the list of 
dependencies. if it works it might be a useful patch yor website 
distribution.  

kind regards,
janning


> Thanks,
> 		Stefan
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
                version="1.0">

<xsl:param name="filename-prefix" select="''"/>
<xsl:param name="output-root" select="''"/>

<xsl:output method="text"/>

<xsl:template match="autolayout">
  <xsl:text>website: </xsl:text>
  <xsl:apply-templates select="toc" mode="all"/>
  <xsl:apply-templates select="notoc" mode="all"/>
  <xsl:text>&#10;&#10;</xsl:text>
  <xsl:apply-templates select="toc"/>
  <xsl:apply-templates select="notoc"/>
  <xsl:text>&#10;</xsl:text>
  <xsl:text>distclean: clean
&#9;rm -f </xsl:text>
  <xsl:text>autolayout.xml depends.tabular
&#9;touch depends.tabular </xsl:text>
  <xsl:text>&#10;&#10;</xsl:text>
  <xsl:text>clean:
&#9;rm -f -R htdocs</xsl:text>
  <xsl:text>&#10;&#10;</xsl:text>
</xsl:template>

<xsl:template match="toc">
<!--
  <xsl:apply-templates select="." mode="calculate-dir"/>
-->
  <xsl:call-template name="output-root"/>
  <xsl:value-of select="@dir"/>
  <xsl:value-of select="$filename-prefix"/>
  <xsl:value-of select="@filename"/>
  <xsl:text>: </xsl:text>
  <xsl:value-of select="@page"/>
  <xsl:text>&#10;</xsl:text>
  <xsl:call-template name="check-includes"/>
  <xsl:apply-templates select=".//tocentry"/>
</xsl:template>

<xsl:template match="tocentry|notoc">
<!--
  <xsl:apply-templates select="." mode="calculate-dir"/>
-->
  <xsl:if test="@filename">
    <xsl:call-template name="output-root"/>
    <xsl:value-of select="@dir"/>
    <xsl:value-of select="$filename-prefix"/>
    <xsl:value-of select="@filename"/>
    <xsl:text>: </xsl:text>
    <xsl:value-of select="@page"/>
    <xsl:text>&#10;</xsl:text>
    <xsl:call-template name="check-includes"/>
  </xsl:if>
</xsl:template>

<xsl:template match="toc" mode="all">
  <xsl:apply-templates select=".//tocentry" mode="all"/>
<!--
  <xsl:apply-templates select="." mode="calculate-dir"/>
-->
  <xsl:call-template name="output-root"/>
  <xsl:value-of select="@dir"/>
  <xsl:value-of select="$filename-prefix"/>
  <xsl:value-of select="@filename"/>
  <xsl:text> </xsl:text>
</xsl:template>

<xsl:template match="tocentry|notoc" mode="all">
<!--
  <xsl:apply-templates select="." mode="calculate-dir"/>
-->
  <xsl:if test="@filename">
    <xsl:call-template name="output-root"/>
    <xsl:value-of select="@dir"/>
    <xsl:value-of select="$filename-prefix"/>
    <xsl:value-of select="@filename"/>
    <xsl:text> </xsl:text>
  </xsl:if>
</xsl:template>

<xsl:template match="*" mode="calculate-dir">
  <xsl:choose>
    <xsl:when test="starts-with(@dir, '/')">
      <!-- if the directory on this begins with a "/", we're done... -->
      <xsl:value-of select="substring-after(@dir, '/')"/>
<!--
      <xsl:if test="@dir != '/'">
        <xsl:text>/</xsl:text>
      </xsl:if>
-->
    </xsl:when>

    <xsl:when test="parent::*">
      <!-- if there's a parent, try it -->
      <xsl:apply-templates select="parent::*" mode="calculate-dir"/>
      <xsl:if test="@dir">
        <xsl:value-of select="@dir"/>
<!--
        <xsl:text>/</xsl:text>
-->
      </xsl:if>
    </xsl:when>

    <xsl:otherwise>
      <xsl:if test="@dir">
        <xsl:value-of select="@dir"/>
<!--
        <xsl:text>/</xsl:text>
-->
      </xsl:if>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>

<xsl:template name="output-root">
  <xsl:if test="$output-root != ''">
    <xsl:value-of select="$output-root"/>
    <xsl:text>/</xsl:text>
  </xsl:if>
</xsl:template>

<xsl:template name="check-includes">
  <xsl:if test="document(@page)//@xml:base">
    <xsl:value-of select="@page"/>
    <xsl:text>: </xsl:text>
    <xsl:for-each select="document(@page)//@xml:base">
      <xsl:value-of select="."/>
      <xsl:text> </xsl:text>
    </xsl:for-each>
    <xsl:text>&#10;</xsl:text>
    <xsl:text>&#9;</xsl:text>
    <xsl:text>touch </xsl:text>    
    <xsl:value-of select="@page"/>
    <xsl:text>&#10;</xsl:text>
  </xsl:if>
</xsl:template>

</xsl:stylesheet>


[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]