Update of /cvsroot/fink/experimental/alexkhansen/xml
In directory 
sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22744/experimental/alexkhansen/xml

Added Files:
        Makefile.common finkdoc-html.xsl finkdoc-text.xsl 
        finkdoc-website.i18n.xsl finkdoc-website.xsl finkdoc.dtd 
        finkfaq.dtd postprocess.pl textify.pl url-encode.xsl 
Log Message:
committing multilingual howto doc to experimental tree for general 
edification


--- NEW FILE: Makefile.common ---
# Hey Emacs, this is a -*- makefile -*-
# $Id: Makefile.common,v 1.1 2004/03/04 02:17:05 alexkhansen Exp $

# common rules for processing XML documents
# post-processing needed to add PHP processing instructions

ifndef STYLESHEET_WEBSITE
STYLESHEET_WEBSITE = $(basedir)/finkdoc-website.xsl
endif
STYLESHEET_HTML = $(basedir)/finkdoc-html.xsl
STYLESHEET_TEXT = $(basedir)/finkdoc-text.xsl

PROCESS_WEBSITE = /usr/bin/perl $(basedir)/postprocess.pl
PROCESS_HTML = sed -e 's,$$Id,$$Fink,g'
PROCESS_TEXT = /usr/bin/perl $(basedir)/textify.pl

# selectors

all_targets = $(TARGET)
install_files = $(TARGET)
#install_files = $(filter %.php,$(TARGET))


ifdef WANT_HTML
all_targets += $(patsubst %.xml,%.html,$(SOURCE))
install_files += $(patsubst %.xml,%.html,$(SOURCE))
install_html = $(patsubst %.xml,%.html,$(SOURCE))
endif

ifdef WANT_TEXT
all_targets += $(patsubst %.xml,%.txt,$(SOURCE))
install_txt = $(patsubst %.xml,%.txt,$(SOURCE))
install_txt += $(patsubst %.xml,%.html,$(SOURCE))
endif

# basics

all: $(all_targets)

clean:
        rm -rf *.rdf *.php *.html *.txt *.tmp *.inc

force: clean all

.SUFFIXES: .xml .php.tmp .php .html.tmp .html .txt.tmp .txt .rdf

.PHONY: all clean force install

# rendering to php-framed HTML for the website (multi-page)

%.php.tmp: $(SOURCE) $(STYLESHEET_WEBSITE) $(basedir)/finkdoc.dtd
        xmllint --noout --valid $(SOURCE) && \
        xsltproc --stringparam PRINTFILE $(patsubst %.xml,%.html,$(SOURCE)) 
--stringparam DESTDIR $(DESTDIR)/ $(STYLESHEET_WEBSITE) $(SOURCE)

%.php: %.php.tmp $(PROCESS_WEBSITE)
        $(PROCESS_WEBSITE) <$< >$@

# rendering to pure HTML (monolithic)

%.html.tmp: %.xml $(STYLESHEET_HTML) $(basedir)/finkdoc.dtd
        xmllint --noout --valid $(SOURCE) && \
        xsltproc -o $(patsubst %.xml,%.html.tmp,$(SOURCE)) $(STYLESHEET_HTML) $(SOURCE)

%.html: %.html.tmp
        $(PROCESS_HTML) <$< >$@

# rendering to pure text (monolithic)

%.txt.tmp: %.xml $(STYLESHEET_TEXT) $(basedir)/finkdoc.dtd
        xmllint --noout --valid $(SOURCE) && \
        xsltproc -o $(patsubst %.xml,%.txt.tmp,$(SOURCE)) $(STYLESHEET_TEXT) $(SOURCE)

%.txt: %.txt.tmp $(PROCESS_TEXT)
        $(PROCESS_TEXT) <$< >$@

# install files inside website

install: $(install_files) install-hook
ifdef DESTDIR
        cp $(install_files) $(basedir)/web/$(DESTDIR)/
else
        @echo "DESTDIR not defined, can't install"
endif
ifdef WANT_HTML
        cp $(install_html) $(basedir)/scripts/installer/dmg/$(DESTDIR)/
endif
#ifdef WANT_TEXT
#       cp $(install_txt) $(basedir)/fink/
#endif

install-hook:

# validate the XML files

check:
        xmllint --noout --valid $(SOURCE)

# eof

--- NEW FILE: finkdoc-html.xsl ---
<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
                version="1.1">

<xsl:output method="html"
        indent="no" encoding="iso-8859-1"
        doctype-public="-//W3C//DTD HTML 4.01 Transitional//EN"
        doctype-system="http://www.w3.org/TR/html4/loose.dtd"/>

<!-- ***** whole document ***** -->

<xsl:template match="document">
<html><head>
<title>Fink Documentation - <xsl:value-of select="title"/></title>
</head><body>

<h1 style="text-align: center;"><xsl:value-of select="title"/></h1>

<xsl:apply-templates select="preface" />

<!-- start TOC -->

<h2><xsl:text>Contents</xsl:text></h2>

<ul>
<xsl:for-each select="chapter">
<li>
  <a><xsl:attribute name="href"><xsl:text>#</xsl:text><xsl:value-of 
select="@filename"/></xsl:attribute>
    <b><xsl:number format="1 " /><xsl:value-of select="title" /></b>
  </a>

  <ul>
        <xsl:for-each select="faqentry|section">
        <li><a><xsl:attribute name="href">
        <xsl:text>#</xsl:text><xsl:value-of select="../@filename" 
/><xsl:text>.</xsl:text><xsl:value-of select="@name" />
        </xsl:attribute>
        <xsl:number count="chapter" format="1." /><xsl:number format="1 " />
        <xsl:for-each select="question/p">
        <xsl:if test='position() = 1'><xsl:call-template name="plain"/></xsl:if>
        </xsl:for-each>
        <xsl:value-of select="title" />
        </a></li>
        </xsl:for-each>
  </ul>
</li>

</xsl:for-each>
</ul>

<!-- end TOC -->

<xsl:apply-templates select="chapter" />

<xsl:call-template name="copyright" />

<xsl:apply-templates select="cvsid" />

</body></html>
</xsl:template>

<!-- ***** chapter ***** -->

<xsl:template match="chapter">

<h2><a name="[EMAIL PROTECTED]"><xsl:number format="1 " /><xsl:value-of 
select="title"/></a></h2>

<xsl:apply-templates/>

</xsl:template>

<!-- ***** article ***** -->

<xsl:template match="article">
<html><head>
<title>Fink Documentation - <xsl:value-of select="title" /></title>
</head><body>
<h1 align="center"><xsl:value-of select="title"/></h1>
<xsl:apply-templates select="preface" />
<xsl:apply-templates select="section" />
<xsl:call-template name="copyright" />
<xsl:apply-templates select="cvsid" />
</body></html>
</xsl:template>


<!-- ***** other structure elements ***** -->

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

<xsl:template match="section">
<h3><a name="{../@[EMAIL PROTECTED]">
<xsl:if test="boolean(//document)">
<xsl:number count="chapter" format="1." /><xsl:number format="1 " />
</xsl:if>
<xsl:value-of select="title"/></a></h3>
<xsl:apply-templates/>
</xsl:template>

<xsl:template match="faqentry">
<a name="{../@[EMAIL PROTECTED]"><xsl:apply-templates/></a>
</xsl:template>

<xsl:template match="question">
<div class="question">
<p><b>Q<xsl:number count="chapter" format="1." /><xsl:number count="faqentry" 
format="1" /><xsl:text>: </xsl:text>
<xsl:for-each select="p">
<xsl:if test='position() = 1'><xsl:call-template name="plain" /></xsl:if>
</xsl:for-each>
</b></p>
<xsl:for-each select="p">
<xsl:if test='position() > 1'><xsl:apply-templates select="." /></xsl:if>
</xsl:for-each>
</div>
</xsl:template>

<xsl:template match="answer">
<div class="answer">
<p><b><xsl:text>A:</xsl:text></b><xsl:text> </xsl:text>
<xsl:for-each select="p">
<xsl:if test='position() = 1'><xsl:call-template name="plain" /></xsl:if>
</xsl:for-each>
</p>
<xsl:for-each select="p | codeblock | ul">
<xsl:if test='position() > 1'><xsl:apply-templates select="." /></xsl:if>
</xsl:for-each>
</div>
</xsl:template>

<!-- ***** block-level elements ***** -->

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

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

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

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

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

<xsl:template match="itemtable">
<table border="0" cellpadding="0" cellspacing="10">
<tr valign="bottom"><th align="left"><xsl:value-of select="@labelt" /></th><th 
align="left"><xsl:value-of select="@labeld" /></th></tr>
<xsl:apply-templates select="item" />
</table>
</xsl:template>

<xsl:template match="item">
<tr valign="top"><td><xsl:apply-templates select="itemt" /></td>
<td><xsl:apply-templates select="itemd" /></td></tr>
</xsl:template>

<xsl:template match="itemt|itemd">
<xsl:apply-templates/>
</xsl:template>

<xsl:template match="cvsid">
<hr/><p><xsl:text>Generated from </xsl:text><i><xsl:apply-templates/></i></p>
</xsl:template>


<!-- ***** character-level elements ***** -->

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

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

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

<xsl:template match="code|filename">
<tt style="white-space: nowrap;"><xsl:apply-templates/></tt>
</xsl:template>

<xsl:template match="link">
<a href="[EMAIL PROTECTED]"><xsl:apply-templates/></a>
</xsl:template>

<xsl:template match="varlink">
<a href="[EMAIL PROTECTED]"><xsl:apply-templates/></a>
</xsl:template>

<xsl:template match="xref">
<a><xsl:attribute name="href">#<xsl:choose><xsl:when 
test="boolean(@chapter)"><xsl:value-of select="@chapter" 
/></xsl:when><xsl:otherwise><xsl:for-each select="ancestor::chapter | 
ancestor::article"><xsl:value-of 
select="@filename"/></xsl:for-each></xsl:otherwise></xsl:choose><xsl:if 
test="boolean(@section)">.<xsl:value-of select="@section" /></xsl:if></xsl:attribute>
<xsl:apply-templates/></a>
</xsl:template>


<!-- *** special stuff *** -->

<xsl:template match="title|shorttitle">
</xsl:template>

<xsl:template name="plain">
<xsl:apply-templates/>
</xsl:template>


<xsl:template name="copyright">
<hr/>
<h2>Copyright Notice</h2>
<p><xsl:text>Copyright (c) 2001 Christoph Pfisterer,
Copyright (c) 2001-2004 The Fink Project.
You may distribute this document in print for private purposes,
provided the document and this copyright notice remain complete and
unmodified. Any commercial reproduction and any online publication
requires the explicit consent of the author.</xsl:text></p>
</xsl:template>



</xsl:stylesheet>

--- NEW FILE: finkdoc-text.xsl ---
<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
                version="1.1">

<xsl:output method="xml" encoding="iso-8859-1" />

<!-- ***** whole document ***** -->

<xsl:template match="document">
<document>

<xsl:apply-templates select="cvsid" />

<h1><xsl:value-of select="title"/></h1>

<xsl:apply-templates select="preface" />

<xsl:apply-templates select="chapter" />

</document>
</xsl:template>

<!-- ***** chapter ***** -->

<xsl:template match="chapter">

<h1><xsl:value-of select="title"/></h1>

<xsl:apply-templates/>

</xsl:template>

<!-- ***** article ***** -->

<xsl:template match="article">
<document>

<xsl:apply-templates select="cvsid" />

<h1><xsl:value-of select="title"/></h1>

<xsl:apply-templates select="preface" />

<xsl:apply-templates select="section" />

</document>
</xsl:template>


<!-- ***** other structure elements ***** -->

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

<xsl:template match="section">
<h2><xsl:value-of select="title"/></h2>
<xsl:apply-templates/>
</xsl:template>

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

<xsl:template match="question">
<p><xsl:text>Q: </xsl:text>
<xsl:for-each select="p">
<xsl:if test='position() = 1'><xsl:call-template name="plain"/></xsl:if>
</xsl:for-each>
</p>
<xsl:for-each select="p">
<xsl:if test='position() > 1'><xsl:apply-templates select="."/></xsl:if>
</xsl:for-each>
</xsl:template>

<xsl:template match="answer">
<p><xsl:text>A: </xsl:text>
<xsl:for-each select="p">
<xsl:if test='position() = 1'><xsl:call-template name="plain"/></xsl:if>
</xsl:for-each>
</p>
<xsl:for-each select="p | codeblock | ul">
<xsl:if test='position() > 1'><xsl:apply-templates select="."/></xsl:if>
</xsl:for-each>
</xsl:template>

<!-- ***** block-level elements ***** -->

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

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

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

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

<!-- itemtable, item, itemt, itemd -->

<xsl:template match="cvsid">
<p><xsl:text>Generated from </xsl:text><xsl:apply-templates/></p>
</xsl:template>


<!-- ***** character-level elements ***** -->

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

<!-- i -->

<xsl:template match="quote">
&quot;<xsl:apply-templates/>&quot;
</xsl:template>

<xsl:template match="code|filename">
"<xsl:apply-templates/>"
</xsl:template>

<xsl:template match="link">
<xsl:apply-templates/>
<xsl:text> [</xsl:text><xsl:value-of select="@url"/><xsl:text>]</xsl:text>
</xsl:template>

<xsl:template match="varlink">
<xsl:apply-templates/>
<xsl:text> [</xsl:text><xsl:value-of select="@varurl"/><xsl:text>]</xsl:text>
</xsl:template>

<!-- xref -->


<!-- *** special stuff *** -->

<xsl:template match="title|shorttitle">
</xsl:template>

<xsl:template name="plain">
<xsl:apply-templates/>
</xsl:template>



</xsl:stylesheet>

--- NEW FILE: finkdoc-website.i18n.xsl ---
<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
                version="1.1">

<!-- set the variables used throughout the document -->
<xsl:variable name="lang-ext" ><xsl:value-of select="document/@lang" /></xsl:variable>

<!-- just a dummy, everything is written with xsl:document -->
<xsl:output method="text"/>

<!-- ***** whole document (renders contents page) ***** -->

<xsl:template match="document">

<xsl:document href="[EMAIL PROTECTED]" method="html" indent="no" encoding="utf-8">
<xsl:text disable-output-escaping="yes">&lt;? include_once "</xsl:text><xsl:value-of 
select="@fsroot"/><xsl:text disable-output-escaping="yes">phpLang.inc.php"; 
?&gt;</xsl:text>
</xsl:document>

<xsl:document href="[EMAIL PROTECTED]" method="html" indent="no" encoding="utf-8">
<xsl:text disable-output-escaping="yes">&lt;?</xsl:text>

$title = "<xsl:value-of select="shorttitle"/>";
$cvs_author = 'Author: <xsl:value-of select="cvsid"/>';
$cvs_date = 'Date: <xsl:value-of select="cvsid"/>';
<xsl:text disable-output-escaping="yes">$metatags = &quot;&lt;link 
rel=\&quot;contents\&quot; href=\&quot;</xsl:text><xsl:value-of select="@filename"/>
<xsl:text disable-output-escaping="yes">.php?phpLang=</xsl:text><xsl:value-of 
select="$lang-ext"/>
<xsl:text disable-output-escaping="yes">\&quot; title=\&quot;</xsl:text><xsl:value-of 
select="shorttitle"/>
<xsl:text disable-output-escaping="yes"> Contents\&quot;&gt;&lt;link 
rel=\&quot;next\&quot; href=\&quot;</xsl:text><xsl:value-of 
select="chapter/@filename"/>
<xsl:text disable-output-escaping="yes">.php?phpLang=</xsl:text><xsl:value-of 
select="$lang-ext"/>
<xsl:text disable-output-escaping="yes">\&quot; title=\&quot;</xsl:text><xsl:value-of 
select="chapter/title"/>
<xsl:text disable-output-escaping="yes">\&quot;&gt;&quot;</xsl:text>;

include_once "header.<xsl:value-of select="$lang-ext" />.inc"; 
<xsl:text disable-output-escaping="yes">?&gt;</xsl:text> 

<h1><xsl:value-of select="title"/></h1>

<xsl:apply-templates select="preface" />

<!-- start TOC -->

<h2><xsl:text>Contents</xsl:text></h2>

<ul><xsl:text>
        </xsl:text>
        <xsl:for-each select="chapter">
        <li>
                <a><xsl:attribute name="href"><xsl:value-of 
select="@filename"/><xsl:text>.php?phpLang=</xsl:text><xsl:value-of select="$lang-ext" 
/></xsl:attribute>
                        <b><xsl:number format="1 " /><xsl:value-of select="title" 
/></b>
                </a>
                <ul>
                <xsl:for-each select="faqentry|section">
                        <li>
                        <a><xsl:attribute name="href">
                        <xsl:value-of select="../@filename" 
/><xsl:text>.php?phpLang=</xsl:text><xsl:value-of select="$lang-ext" 
/><xsl:text>#</xsl:text><xsl:value-of select="@name" />
                        </xsl:attribute>
                        <xsl:number count="chapter" format="1." /><xsl:number 
format="1 " />
                                <xsl:for-each select="question/p">
                                <xsl:if test='position() = 1'><xsl:call-template 
name="plain"/></xsl:if>
                                </xsl:for-each>
                                <xsl:value-of select="title" />
                        </a>
                        </li>
                </xsl:for-each>
                </ul>
        </li>
        </xsl:for-each>
</ul>

<!-- end TOC -->

<xsl:apply-templates select="cvsid" />

<xsl:apply-templates select="chapter" />

<xsl:text disable-output-escaping="yes">&lt;?</xsl:text> include_once "<xsl:value-of 
select="@fsroot"/>footer.inc"; <xsl:text 
disable-output-escaping="yes">?&gt;</xsl:text> 
</xsl:document>

<!-- Generate language specific header include file -->
<xsl:document href="[EMAIL PROTECTED]:base}header.{$lang-ext}.inc" method="text" 
indent="no" encoding="utf-8">
<xsl:text disable-output-escaping="yes">&lt;?</xsl:text><xsl:text> 
/* This file is generated, do not edit manually! */

$section = "</xsl:text><xsl:value-of select="@section"/><xsl:text>";
$parents = array("doc/index.php", "Document List");
$navbox = array(
  "</xsl:text>
<xsl:value-of select="$DESTDIR"/>
<xsl:text>index.php?phpLang=</xsl:text><xsl:value-of select="$lang-ext"/><xsl:text>", 
"Contents",
</xsl:text>
<xsl:for-each select="chapter">
<xsl:text>  "</xsl:text><xsl:value-of select="$DESTDIR"/><xsl:value-of 
select="@filename"/><xsl:text>.php?phpLang=</xsl:text><xsl:value-of 
select="$lang-ext"/><xsl:text>", "</xsl:text>
<xsl:value-of select="shorttitle"/>
<xsl:text>",
</xsl:text>
</xsl:for-each>
<xsl:text>);
$printlink = "</xsl:text>
<xsl:value-of select="$DESTDIR"/><xsl:value-of 
select="$PRINTFILE"/><xsl:text>.</xsl:text><xsl:value-of select="$lang-ext"/>
<xsl:text>.html";

$fsroot = $root = "</xsl:text><xsl:value-of select="@fsroot"/><xsl:text>";
include $fsroot."header.inc";
</xsl:text><xsl:text disable-output-escaping="yes"> ?&gt;</xsl:text>
</xsl:document>

</xsl:template>

<!-- ***** chapter (renders to a separate file) ***** -->

<xsl:template match="chapter">
<xsl:document href="[EMAIL PROTECTED]" method="html" indent="no" encoding="utf-8">
<xsl:text disable-output-escaping="yes">&lt;? include_once "</xsl:text><xsl:value-of 
select="../@fsroot"/><xsl:text disable-output-escaping="yes">phpLang.inc.php"; 
?&gt;</xsl:text>
</xsl:document>

<xsl:document href="[EMAIL PROTECTED]" method="html" indent="no" encoding="utf-8">
<xsl:text disable-output-escaping="yes">&lt;?</xsl:text>

$title = "<xsl:value-of select="../shorttitle"/> - <xsl:value-of 
select="shorttitle"/>";
$cvs_author = 'Author: <xsl:value-of select="../cvsid" />';
$cvs_date = 'Date: <xsl:value-of select="../cvsid" />';
<xsl:text disable-output-escaping="yes">$metatags = &quot;&lt;link 
rel=\&quot;contents\&quot; href=\&quot;</xsl:text><xsl:value-of select="../@filename"/>
<xsl:text disable-output-escaping="yes">.php?phpLang=</xsl:text><xsl:value-of 
select="$lang-ext"/>
<xsl:text disable-output-escaping="yes">\&quot; title=\&quot;</xsl:text><xsl:value-of 
select="../shorttitle"/>
<xsl:text disable-output-escaping="yes"> Contents\&quot;&gt;\n\t</xsl:text>
<xsl:for-each select="following-sibling::chapter">
<xsl:if test="position()=1">
<xsl:text disable-output-escaping="yes">&lt;link rel=\&quot;next\&quot; 
href=\&quot;</xsl:text><xsl:value-of select="@filename"/>
<xsl:text disable-output-escaping="yes">.php?phpLang=</xsl:text><xsl:value-of 
select="$lang-ext"/>
<xsl:text disable-output-escaping="yes">\&quot; title=\&quot;</xsl:text><xsl:value-of 
select="title"/>
<xsl:text disable-output-escaping="yes">\&quot;&gt;\n\t</xsl:text>
</xsl:if>
</xsl:for-each>
<xsl:for-each select="preceding-sibling::chapter">
<xsl:if test="position()=last()">
<xsl:text disable-output-escaping="yes">&lt;link rel=\&quot;prev\&quot; 
href=\&quot;</xsl:text><xsl:value-of select="@filename"/>
<xsl:text disable-output-escaping="yes">.php?phpLang=</xsl:text><xsl:value-of 
select="$lang-ext"/>
<xsl:text disable-output-escaping="yes">\&quot; title=\&quot;</xsl:text><xsl:value-of 
select="title"/>
<xsl:text disable-output-escaping="yes">\&quot; /&gt;</xsl:text>
</xsl:if>
</xsl:for-each>
<xsl:if test="position()=1">
<xsl:text disable-output-escaping="yes">&lt;link rel=\&quot;prev\&quot; 
href=\&quot;</xsl:text><xsl:value-of select="../@filename"/>
<xsl:text disable-output-escaping="yes">.php?phpLang=</xsl:text><xsl:value-of 
select="$lang-ext"/>
<xsl:text disable-output-escaping="yes">\&quot; title=\&quot;</xsl:text><xsl:value-of 
select="../shorttitle"/>
<xsl:text disable-output-escaping="yes"> Contents\&quot; /&gt;</xsl:text>
</xsl:if>
<xsl:text disable-output-escaping="yes">&quot;</xsl:text>;

include_once "header.<xsl:value-of select="$lang-ext" />.inc"; 
<xsl:text disable-output-escaping="yes">?&gt;</xsl:text> 

<h1><xsl:value-of select="../shorttitle"/><xsl:text> - </xsl:text><xsl:number 
format="1 " /><xsl:value-of select="title"/></h1>

<xsl:apply-templates/>

<xsl:for-each select="following-sibling::chapter">
<xsl:if test="position()=1">
<p align="right">
Next: <a href="[EMAIL PROTECTED]"><xsl:number format="1 " /><xsl:value-of 
select="title" /></a>
</p>
</xsl:if>
</xsl:for-each>

<xsl:text disable-output-escaping="yes">&lt;?</xsl:text> include_once "<xsl:value-of 
select="../@fsroot"/>footer.inc"; <xsl:text 
disable-output-escaping="yes">?&gt;</xsl:text> 
</xsl:document>
</xsl:template>

<!-- ***** article (renders all on one page) ***** -->

<xsl:template match="article">
<xsl:document href="[EMAIL PROTECTED]" method="html" indent="no" encoding="utf-8">
<xsl:text disable-output-escaping="yes">&lt;? include_once "</xsl:text><xsl:value-of 
select="@fsroot"/><xsl:text disable-output-escaping="yes">phpLang.inc.php"; 
?&gt;</xsl:text>
</xsl:document>

<xsl:document href="[EMAIL PROTECTED]@lang}.php" method="html" indent="no" 
encoding="utf-8">
<xsl:text disable-output-escaping="yes">&lt;?</xsl:text>
$title = "<xsl:value-of select="shorttitle" />";
$cvs_author = 'Author: <xsl:value-of select="cvsid"/>';
$cvs_date = 'Date: <xsl:value-of select="cvsid"/>';
include_once 'nav.inc';
$fsroot = $root = '<xsl:value-of select="@fsroot" />';
include_once '<xsl:value-of select="@fsroot" />header.inc'; 
<xsl:text disable-output-escaping="yes">?&gt;</xsl:text> 

<h1><xsl:value-of select="title"/></h1>

<xsl:apply-templates select="cvsid" />

<xsl:apply-templates select="preface" />

<xsl:apply-templates select="section" />

<xsl:text disable-output-escaping="yes">&lt;?</xsl:text> include_once "<xsl:value-of 
select="@fsroot"/>footer.inc"; <xsl:text 
disable-output-escaping="yes">?&gt;</xsl:text> 

</xsl:document>
</xsl:template>


<!-- ***** other structure elements ***** -->

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

<xsl:template match="section">
<h2><a name="[EMAIL PROTECTED]">
<xsl:if test="boolean(//document)">
<xsl:number count="chapter" format="1." /><xsl:number format="1 " />
</xsl:if>
<xsl:value-of select="title"/></a></h2>
<xsl:apply-templates/>
</xsl:template>

<xsl:template match="faqentry">
<a name="[EMAIL PROTECTED]"><xsl:apply-templates/></a>
</xsl:template>

<xsl:template match="question">
<div class="question">
<p><b>Q<xsl:number count="chapter" format="1." /><xsl:number count="faqentry" 
format="1" /><xsl:text>: </xsl:text>
<xsl:for-each select="p">
<xsl:if test='position() = 1'><xsl:call-template name="plain" /></xsl:if>
</xsl:for-each>
</b></p>
<xsl:for-each select="p">
<xsl:if test='position() > 1'><xsl:apply-templates select="." /></xsl:if>
</xsl:for-each>
</div>
</xsl:template>

<xsl:template match="answer">
<div class="answer">
<p><b>A:</b><xsl:text> </xsl:text>
<xsl:for-each select="p">
<xsl:if test='position() = 1'><xsl:call-template name="plain" /></xsl:if>
</xsl:for-each>
</p>
<xsl:for-each select="p | codeblock | ul">
<xsl:if test='position() > 1'><xsl:apply-templates select="." /></xsl:if>
</xsl:for-each>
</div>
</xsl:template>

<!-- ***** block-level elements ***** -->

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

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

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

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

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

<xsl:template match="itemtable">
<table border="0" cellpadding="0" cellspacing="10">
<tr valign="bottom"><th align="left"><xsl:value-of select="@labelt" /></th><th 
align="left"><xsl:value-of select="@labeld" /></th></tr>
<xsl:apply-templates select="item" />
</table>
</xsl:template>

<xsl:template match="item">
<tr valign="top"><td><xsl:apply-templates select="itemt" /></td>
<td><xsl:apply-templates select="itemd" /></td></tr>
</xsl:template>

<xsl:template match="itemt|itemd">
<xsl:apply-templates/>
</xsl:template>

<xsl:template match="cvsid">
<p><xsl:text>Generated from </xsl:text><i><xsl:apply-templates/></i></p>
</xsl:template>


<!-- ***** character-level elements ***** -->

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

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

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

<xsl:template match="code|filename">
<code><xsl:apply-templates/></code>
</xsl:template>

<xsl:template match="link">
<a href="[EMAIL PROTECTED]"><xsl:apply-templates/></a>
</xsl:template>

<xsl:template match="varlink">
<a href="[EMAIL PROTECTED]"><xsl:apply-templates/></a>
</xsl:template>

<xsl:template match="xref">
<a><xsl:attribute name="href">
<xsl:if test="boolean(@chapter)"><xsl:value-of select="@chapter" 
/>.php?phpLang=<xsl:value-of select="$lang-ext" /></xsl:if>
<xsl:if test="boolean(@section)">#<xsl:value-of select="@section" /></xsl:if>
</xsl:attribute>
<xsl:apply-templates/></a>
</xsl:template>


<!-- *** special stuff *** -->

<xsl:template match="title|shorttitle">
</xsl:template>

<xsl:template name="plain">
<xsl:apply-templates/>
</xsl:template>



</xsl:stylesheet>

--- NEW FILE: finkdoc-website.xsl ---
<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
                version="1.1">

<!-- just a dummy, everything is written with xsl:document -->
<xsl:output method="text"/>

<!-- ***** whole document (renders contents page) ***** -->

<xsl:template match="document">
<xsl:document href="[EMAIL PROTECTED]" method="html" indent="no" encoding="iso-8859-1">
<html><head>
<title><xsl:value-of select="shorttitle"/></title>
<link rel="contents" href="[EMAIL PROTECTED]" title="{shorttitle} Contents" />
<link rel="next" href="{chapter/@filename}.php" title="{chapter/title}" />
</head><body>

<h1><xsl:value-of select="title"/></h1>

<xsl:apply-templates select="preface" />

<!-- start TOC -->

<h2><xsl:text>Contents</xsl:text></h2>

<ul><xsl:text>
</xsl:text>
<xsl:for-each select="chapter">
<li><a><xsl:attribute name="href">
<xsl:value-of select="@filename"/><xsl:text>.php</xsl:text>
</xsl:attribute>
<b><xsl:number format="1 " /><xsl:value-of select="title" /></b></a></li><xsl:text>
</xsl:text>

<ul><xsl:text>
</xsl:text>
<xsl:for-each select="faqentry|section">
<li><a><xsl:attribute name="href">
<xsl:value-of select="../@filename" /><xsl:text>.php#</xsl:text><xsl:value-of 
select="@name" />
</xsl:attribute>
<xsl:number count="chapter" format="1." /><xsl:number format="1 " />
<xsl:for-each select="question/p">
<xsl:if test='position() = 1'><xsl:call-template name="plain"/></xsl:if>
</xsl:for-each>
<xsl:value-of select="title" />
</a></li><xsl:text>
</xsl:text>
</xsl:for-each>
</ul><xsl:text>
</xsl:text>

</xsl:for-each>
</ul>

<!-- end TOC -->

<xsl:apply-templates select="cvsid" />

<xsl:apply-templates select="chapter" />

</body></html>
</xsl:document>

<!-- Generate header.inc -->
<xsl:document href="[EMAIL PROTECTED]:base}header.inc" method="text" indent="no" 
encoding="iso-8859-1">
<xsl:text>&lt;?
/* This file is generated, do not edit manually! */

$section = "documentation";
$parents = array("doc/index.php", "Document List");
$navbox = array(
  "</xsl:text>
<xsl:value-of select="$DESTDIR"/>
<xsl:text>index.php", "Contents",
</xsl:text>
<xsl:for-each select="chapter">
<xsl:text>  "</xsl:text><xsl:value-of select="$DESTDIR"/><xsl:value-of 
select="@filename"/><xsl:text>.php", "</xsl:text>
<xsl:value-of select="shorttitle"/>
<xsl:text>",
</xsl:text>
</xsl:for-each>
<xsl:text>);
$printlink = "</xsl:text>
<xsl:value-of select="$DESTDIR"/><xsl:value-of select="$PRINTFILE"/>
<xsl:text>";

$fsroot = $root = "../../";
include $fsroot."header.inc";
?&gt;
</xsl:text>
</xsl:document>

</xsl:template>

<!-- ***** chapter (renders to a separate file) ***** -->

<xsl:template match="chapter">
<xsl:document href="[EMAIL PROTECTED]" method="html" indent="no" encoding="iso-8859-1">
<html><head>
<!-- this will be seen and then removed by postprocess.pl -->
<xsl:value-of select="../cvsid" />
<title><xsl:value-of select="../shorttitle"/><xsl:text> - </xsl:text><xsl:value-of 
select="shorttitle"/></title>
<link rel="contents" href="{../@filename}.php" title="{../shorttitle} Contents" />

<xsl:for-each select="following-sibling::chapter">
<xsl:if test="position()=1">
<link rel="next" href="[EMAIL PROTECTED]" title="{title}" />
</xsl:if>
</xsl:for-each>

<xsl:for-each select="preceding-sibling::chapter">
<xsl:if test="position()=last()">
<link rel="prev" href="[EMAIL PROTECTED]" title="{title}" />
</xsl:if>
</xsl:for-each>
<xsl:if test="position()=1">
<link rel="prev" href="{../@filename}.php" title="{../shorttitle} Contents" />
</xsl:if>

</head><body>

<h1><xsl:value-of select="../shorttitle"/><xsl:text> - </xsl:text><xsl:number 
format="1 " /><xsl:value-of select="title"/></h1>

<xsl:apply-templates/>

<xsl:for-each select="following-sibling::chapter">
<xsl:if test="position()=1">
<p align="right">
Next: <a href="[EMAIL PROTECTED]"><xsl:number format="1 " /><xsl:value-of 
select="title" /></a>
</p>
</xsl:if>
</xsl:for-each>

</body></html>
</xsl:document>
</xsl:template>

<!-- ***** article (renders all on one page) ***** -->

<xsl:template match="article">
<xsl:document href="[EMAIL PROTECTED]" method="html" indent="no" encoding="iso-8859-1">
<html><head>
<title><xsl:value-of select="shorttitle" /></title>
</head><body>

<h1><xsl:value-of select="title"/></h1>

<xsl:apply-templates select="cvsid" />

<xsl:apply-templates select="preface" />

<xsl:apply-templates select="section" />

</body></html>
</xsl:document>
</xsl:template>


<!-- ***** other structure elements ***** -->

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

<xsl:template match="section">
<h2><a name="[EMAIL PROTECTED]">
<xsl:if test="boolean(//document)">
<xsl:number count="chapter" format="1." /><xsl:number format="1 " />
</xsl:if>
<xsl:value-of select="title"/></a></h2>
<xsl:apply-templates/>
</xsl:template>

<xsl:template match="faqentry">
<a name="[EMAIL PROTECTED]"><xsl:apply-templates/></a>
</xsl:template>

<xsl:template match="question">
<div class="question">
<p><b>Q<xsl:number count="chapter" format="1." /><xsl:number count="faqentry" 
format="1" /><xsl:text>: </xsl:text>
<xsl:for-each select="p">
<xsl:if test='position() = 1'><xsl:call-template name="plain" /></xsl:if>
</xsl:for-each>
</b></p>
<xsl:for-each select="p">
<xsl:if test='position() > 1'><xsl:apply-templates select="." /></xsl:if>
</xsl:for-each>
</div>
</xsl:template>

<xsl:template match="answer">
<div class="answer">
<p><b>A:</b><xsl:text> </xsl:text>
<xsl:for-each select="p">
<xsl:if test='position() = 1'><xsl:call-template name="plain" /></xsl:if>
</xsl:for-each>
</p>
<xsl:for-each select="p | codeblock | ul">
<xsl:if test='position() > 1'><xsl:apply-templates select="." /></xsl:if>
</xsl:for-each>
</div>
</xsl:template>

<!-- ***** block-level elements ***** -->

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

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

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

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

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

<xsl:template match="itemtable">
<table border="0" cellpadding="0" cellspacing="10">
<tr valign="bottom"><th align="left"><xsl:value-of select="@labelt" /></th><th 
align="left"><xsl:value-of select="@labeld" /></th></tr>
<xsl:apply-templates select="item" />
</table>
</xsl:template>

<xsl:template match="item">
<tr valign="top"><td><xsl:apply-templates select="itemt" /></td>
<td><xsl:apply-templates select="itemd" /></td></tr>
</xsl:template>

<xsl:template match="itemt|itemd">
<xsl:apply-templates/>
</xsl:template>

<xsl:template match="cvsid">
<p><xsl:text>Generated from </xsl:text><i><xsl:apply-templates/></i></p>
</xsl:template>


<!-- ***** character-level elements ***** -->

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

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

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

<xsl:template match="code|filename">
<code><xsl:apply-templates/></code>
</xsl:template>

<xsl:template match="link">
<a href="[EMAIL PROTECTED]"><xsl:apply-templates/></a>
</xsl:template>

<xsl:template match="varlink">
<a href="[EMAIL PROTECTED]"><xsl:apply-templates/></a>
</xsl:template>

<xsl:template match="xref">
<a><xsl:attribute name="href">
<xsl:if test="boolean(@chapter)"><xsl:value-of select="@chapter" />.php</xsl:if>
<xsl:if test="boolean(@section)">#<xsl:value-of select="@section" /></xsl:if>
</xsl:attribute>
<xsl:apply-templates/></a>
</xsl:template>


<!-- *** special stuff *** -->

<xsl:template match="title|shorttitle">
</xsl:template>

<xsl:template name="plain">
<xsl:apply-templates/>
</xsl:template>



</xsl:stylesheet>

--- NEW FILE: finkdoc.dtd ---
<!ENTITY % block "codeblock | ol | p | ul" >
<!ENTITY % inline "#PCDATA | code | strong | em | filename | link | varlink | tt | 
quote | xref" >

<!ENTITY fink_version "0.6.2" >


<!-- Root elements -->
<!ELEMENT article ( title, shorttitle, cvsid, preface?, section+ ) >
<!ATTLIST article filename ID #REQUIRED >
<!ATTLIST article lang CDATA "en" >
<!ATTLIST article fsroot CDATA "../" >

<!ELEMENT document ( title, shorttitle, cvsid, preface?, chapter+ ) >
<!ATTLIST document filename ID #REQUIRED >
<!ATTLIST document lang CDATA "en" >
<!ATTLIST document section CDATA "documentation" >
<!ATTLIST document fsroot CDATA "../../" >


<!-- Structure -->
<!ELEMENT chapter ( title, shorttitle, preface?, section+ ) >
<!ATTLIST chapter filename ID #REQUIRED >

<!ELEMENT title ( #PCDATA ) >
<!ELEMENT shorttitle ( #PCDATA ) >
<!ELEMENT cvsid ( #PCDATA ) >
<!ELEMENT preface ( p+ ) >

<!ELEMENT section (title?, ( %block; | itemtable )*) >
<!ATTLIST section name NMTOKEN #IMPLIED >


<!-- Block elements -->
<!ELEMENT codeblock ( #PCDATA | em | strong )* >
<!ELEMENT p ( %inline; )* >


<!-- Inline -->
<!ELEMENT code ( #PCDATA | em | strong )* >
<!ELEMENT em ( #PCDATA ) >
<!ELEMENT strong ( #PCDATA ) >
<!ELEMENT filename ( #PCDATA ) >
<!ELEMENT tt ( #PCDATA ) >
<!ELEMENT quote ( #PCDATA ) >


<!-- Links -->
<!ELEMENT link ( #PCDATA ) >
<!ATTLIST link url CDATA #REQUIRED >

<!-- VarLinks -->
<!ELEMENT varlink ( #PCDATA ) >
<!ATTLIST varlink url CDATA #REQUIRED >
<!ATTLIST varlink varurl CDATA #REQUIRED >


<!ELEMENT xref ( #PCDATA ) >
<!ATTLIST xref chapter IDREF #IMPLIED >
<!ATTLIST xref section NMTOKEN #IMPLIED >


<!-- Lists -->
<!ELEMENT ol ( li+ ) >
<!ELEMENT ul ( li+ ) >

<!ELEMENT li ( %inline; | codeblock | p | ol )* >

<!ELEMENT itemtable ( item+ ) >
<!ATTLIST itemtable labeld CDATA "Value" >
<!ATTLIST itemtable labelt CDATA "Field" >

<!ELEMENT item ( itemt, itemd ) >
<!ELEMENT itemt ( %inline; )* >
<!ELEMENT itemd ( %block; )* >

--- NEW FILE: finkfaq.dtd ---
<!ENTITY % block "codeblock | p | ul" >
<!ENTITY % inline "#PCDATA | code | em | filename | link | tt | quote | xref" >

<!ENTITY fink_version "0.6.2" >


<!-- Root elements -->

<!ELEMENT document ( title, shorttitle, cvsid, preface?, chapter+ ) >
<!ATTLIST document filename ID #REQUIRED >
<!ATTLIST document lang CDATA "en" >
<!ATTLIST document section CDATA "faq" >
<!ATTLIST document fsroot CDATA "../" >


<!-- Structure -->
<!ELEMENT chapter ( title, shorttitle, faqentry+ ) >
<!ATTLIST chapter filename ID #REQUIRED >

<!ELEMENT title ( #PCDATA ) >
<!ELEMENT shorttitle ( #PCDATA ) >
<!ELEMENT cvsid ( #PCDATA ) >
<!ELEMENT preface ( p+ ) >

<!ELEMENT faqentry ( question, answer ) >
<!ATTLIST faqentry name ID #REQUIRED >

<!ELEMENT question ( p ) >
<!ELEMENT answer ( %block; )* >


<!-- Block elements -->
<!ELEMENT codeblock ( #PCDATA | em )* >
<!ELEMENT p ( %inline; )* >


<!-- Inline -->
<!ELEMENT code ( #PCDATA | em )* >
<!ELEMENT em ( #PCDATA ) >
<!ELEMENT filename ( #PCDATA ) >
<!ELEMENT tt ( #PCDATA ) >
<!ELEMENT quote ( #PCDATA ) >


<!-- Links -->
<!ELEMENT link ( #PCDATA ) >
<!ATTLIST link url CDATA #REQUIRED >

<!ELEMENT xref ( #PCDATA ) >
<!ATTLIST xref chapter IDREF #IMPLIED >
<!ATTLIST xref section NMTOKEN #IMPLIED >


<!-- Lists -->
<!ELEMENT ul ( li+ ) >
<!ELEMENT li ( %inline; | codeblock | p )* >

--- NEW FILE: postprocess.pl ---
#!/usr/bin/perl -w
use strict;

my ($text, $tag_author, $tag_date);

while (<>) {
  $text .= $_;
}

$tag_author = '$Author'.'$';
$tag_date = '$Date'.'$';

if ($text =~ m|Id: \S+ \S+ (\d{2,4}/\d{1,2}/\d{1,2} \d{1,2}:\d{1,2}:\d{1,2}) (\S+)|) {
  $tag_author = "Author: $2";
  $tag_date = "Date: $1";
}

$text =~ s|<\!DOCTYPE[^>]+>\n||g;
$text =~ s|<html>.*<head>.*<title>|<?\n\$title = "|s;
while ($text =~ s|(</title>.*[^\\])'(.*</head>)|$1\\'$2|s) {
}
$text =~ s|</title>|";\n\$cvs_author = '$tag_author';\n\$cvs_date = 
'$tag_date';\n\n\$metatags = '|s;
$text =~ s|</head>.*<body>|';\n\ninclude "header.inc";\n?>\n\n|s;
$text =~ s|</body>.*</html>|\n\n\n<?\ninclude "footer.inc";\n?>\n|s;
$text =~ s|\$Id|\$Fink|g;

$text =~ s|[EMAIL PROTECTED]@|<?php print \$root; ?>|g;


print $text;

exit 0;

--- NEW FILE: textify.pl ---
#!/usr/bin/perl -w
use strict;

# configuration
my $linelength = 76;

# input
my ($text);

while (<>) {
  $text .= $_;
}

# output state
my ($s, $prefix, $newprefix, $ptype, $leading, $uscore);
$s = "";
$prefix = "";
$newprefix = "";
$ptype = 99;
$leading = 0;
$uscore = 0;

# output routine
sub render {
  my ($line, $pos, $t);

  print "\n"x$leading;
  $leading = 1;

  $s =~ s/&quot;/\"/g;   # xsltproc quirk - converts all " to &quot;

  if ($ptype == 3) {
    # preformatted
    foreach $line (split(/\n/, $s)) {
      print $prefix.$line."\n";
      $prefix = $newprefix;
    }
  } else {
    # normal text flow

    $s =~ s/^\n+//s;       # no newlines at the beginning (but a blank is okay)
    $s =~ s/\s+/ /gs;      # collapse whitespace (removes newlines, too)
    $s =~ s/\s+$//s;       # no whitespace at the end
    $s =~ s/((\S+)\s\[(\S+)\])/
      ($2 eq $3) ? ("<".$3.">") : $1/ge;   # collapse links with URL = text
    $s =~ s/\$Id/\$Fink/g; # hide CVS tag from CVS
    $s =~ s/&lt;/</g;      # HTML entities
    $s =~ s/&gt;/>/g;      #  "
    $s =~ s/&amp;/&/g;     #  "

    my $space = $linelength - length($prefix);
    while (length($s) > $space) {
      $pos = rindex($s," ",$space);
      if ($pos < 0) {
        $t = substr($s,0,$space);
        $s = substr($s,$space);
      } else {
        $t = substr($s,0,$pos);
        $s = substr($s,$pos+1);
      }
      print $prefix.$t."\n";
      $prefix = $newprefix;
      $space = $linelength - length($prefix);
    }
    print $prefix.$s."\n";
    $prefix = $newprefix;
  }

  $s = "";
}

# tag callbacks
sub starttag {
  my $tag = shift;

  if ($tag eq "h1") {
    $leading = 2;
    $leading = 1 if $ptype == 98;
    $leading = 0 if $ptype == 99;
    $ptype = 1;
    $s = " ";
  } elsif ($tag eq "h2") {
    $leading = 2;
    $leading = 1 if $ptype == 98;
    $leading = 0 if $ptype == 99;
    $leading = 1 if $ptype == 1;
    $ptype = 2;
    $s = " ";
  } elsif ($tag eq "p") {
    if ($ptype == 2 or $ptype == 99 or $ptype == 98) {
      $leading = 0;
    } else {
      $leading = 1;
    }
    if ($ptype == 99 or $ptype == 98) {
      $ptype = 98;
    } else {
      $ptype = 0;
    }
    $s = "";
  } elsif ($tag eq "pre") {
    $ptype = 3;
    $prefix .= "   ";
    $newprefix .= "   ";
    $leading = 1;
    $s = "";
  } elsif ($tag eq "li") {
    $prefix .= " * ";
    $newprefix .= "   ";
  } elsif ($tag eq "u") {
    $s .= "_";
    $uscore++;
  }
}

sub endtag {
  my $tag = shift;
  my ($cnt);

  if ($tag eq "h1") {
    $cnt = length($s)+1;
    &render();
    print "="x$cnt."\n";
  } elsif ($tag eq "h2") {
    $cnt = length($s)+1;
    &render();
    print "-"x$cnt."\n";
  } elsif ($tag eq "p") {
    &render();
  } elsif ($tag eq "pre") {
    &render();
    $prefix = substr($prefix,0,-3);
    $newprefix = substr($newprefix,0,-3);
    $ptype = 0;
  } elsif ($tag eq "li") {
    $prefix = substr($prefix,0,-3);
    $newprefix = substr($newprefix,0,-3);
  } elsif ($tag eq "u") {
    $s .= "_";
    $uscore--;
    $uscore = 0 if $uscore < 0;
  }
}

sub addtext {
  my $part = shift;

  if ($uscore > 0) {
    $part =~ tr/ /_/;
  }
  $s .= $part;
}


# input parser
my ($pos, $endpos, $t, $tag);
while (length($text) > 0) {
  $pos = index($text,"<");
  if ($pos < 0) {
    last;
  }
  if ($pos > 0) {
    &addtext(substr($text,0,$pos));
  }

  $endpos = index($text,">",$pos);
  if ($endpos <= $pos) {
    last;
  }
  $tag = substr($text,$pos+1,$endpos-$pos-1);
  if (substr($tag,0,1) eq "/") {
    &endtag(substr($tag,1));
  } else {
    &starttag($tag);
  }

  $text = substr($text,$endpos+1);
}

print "\n\nEOF.\n";

exit 0;

--- NEW FILE: url-encode.xsl ---
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; version="1.0">

  <xsl:output method="xml" indent="yes" encoding="iso-8859-1"/>

  <!-- ISO-8859-1 based URL-encoding demo
       Written by Mike J. Brown, [EMAIL PROTECTED]
       Updated 2002-05-20.

       No license; use freely, but credit me if reproducing in print.

       Also see http://skew.org/xml/misc/URI-i18n/ for a discussion of
       non-ASCII characters in URIs.
  -->

  <!-- Characters we'll support.
       We could add control chars 0-31 and 127-159, but we won't. -->
  <xsl:variable name="ascii"> !"#$%&amp;'()*+,-./0123456789:;&lt;=&gt;[EMAIL 
PROTECTED]|}~</xsl:variable>
  <xsl:variable 
name="latin1">&#160;&#161;&#162;&#163;&#164;&#165;&#166;&#167;&#168;&#169;&#170;&#171;&#172;&#173;&#174;&#175;&#176;&#177;&#178;&#179;&#180;&#181;&#182;&#183;&#184;&#185;&#186;&#187;&#188;&#189;&#190;&#191;&#192;&#193;&#194;&#195;&#196;&#197;&#198;&#199;&#200;&#201;&#202;&#203;&#204;&#205;&#206;&#207;&#208;&#209;&#210;&#211;&#212;&#213;&#214;&#215;&#216;&#217;&#218;&#219;&#220;&#221;&#222;&#223;&#224;&#225;&#226;&#227;&#228;&#229;&#230;&#231;&#232;&#233;&#234;&#235;&#236;&#237;&#238;&#239;&#240;&#241;&#242;&#243;&#244;&#245;&#246;&#247;&#248;&#249;&#250;&#251;&#252;&#253;&#254;&#255;</xsl:variable>

  <!-- Characters that usually don't need to be escaped -->
  <xsl:variable 
name="safe">!'()*-.0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz~</xsl:variable>

  <xsl:variable name="hex" >0123456789ABCDEF</xsl:variable>

  <!-- 
  <xsl:template match="/">

    <result>
      <string>
        <xsl:value-of select="$iso-string"/>
      </string>
      <hex>
        <xsl:call-template name="url-encode">
          <xsl:with-param name="str" select="$iso-string"/>
        </xsl:call-template>
      </hex>
    </result>

  </xsl:template>

  -->

  <xsl:template name="url-encode">
    <xsl:param name="str"/>   
    <xsl:if test="$str">
      <xsl:variable name="first-char" select="substring($str,1,1)"/>
      <xsl:choose>
        <xsl:when test="contains($safe,$first-char)">
          <xsl:value-of select="$first-char"/>
        </xsl:when>
        <xsl:otherwise>
          <xsl:variable name="codepoint">
            <xsl:choose>
              <xsl:when test="contains($ascii,$first-char)">
                <xsl:value-of 
select="string-length(substring-before($ascii,$first-char)) + 32"/>
              </xsl:when>
              <xsl:when test="contains($latin1,$first-char)">
                <xsl:value-of 
select="string-length(substring-before($latin1,$first-char)) + 160"/>
              </xsl:when>
              <xsl:otherwise>
                <xsl:message terminate="no">Warning: string contains a character that 
is out of range! Substituting "?".</xsl:message>
                <xsl:text>63</xsl:text>
              </xsl:otherwise>
            </xsl:choose>
          </xsl:variable>
        <xsl:variable name="hex-digit1" select="substring($hex,floor($codepoint div 
16) + 1,1)"/>
        <xsl:variable name="hex-digit2" select="substring($hex,$codepoint mod 16 + 
1,1)"/>
        <xsl:value-of select="concat('%',$hex-digit1,$hex-digit2)"/>
        </xsl:otherwise>
      </xsl:choose>
      <xsl:if test="string-length($str) &gt; 1">
        <xsl:call-template name="url-encode">
          <xsl:with-param name="str" select="substring($str,2)"/>
        </xsl:call-template>
      </xsl:if>
    </xsl:if>
  </xsl:template>

</xsl:stylesheet>




-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click
_______________________________________________
Fink-commits mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/fink-commits

Reply via email to