Commit ac89acd3 authored by jepso's avatar jepso

removed old documentation files

parent 10b6e115
This diff is collapsed.
<table width=100% cellspacing=0 cellpadding=0>
<tr>
<td class='bordered' valign='top'>
<?php
if ( ! isset($_GET['chapter'])) {
foreach ($i as $k => $v) {
$indexes = explode('.', $v['index']);
$level = count($indexes);
$e = explode(' - ', $v['name']);
$file = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'docs' . DIRECTORY_SEPARATOR . $v['name'] . '.php';
print '<div class=level' . $level . '><font class=level' . $level . '>&nbsp;'. $v['index'] . '. <a href=documentation2.php?chapter='
. urlencode($v['name']) . ">" . end($e) ."</a></font>";
if ( ! file_exists($file)) {
//print "<font color='red'>[code]</font>";
}
print "</div>";
}
} else {
$e = explode(' - ', $_GET['chapter']);
$subchapters = false;
$found = false;
foreach ($i as $k => $v) {
if ($found) {
if (strncmp($v['name'], $_GET['chapter'], strlen($_GET['chapter'])) === 0) {
$subchapters = true;
}
break;
}
$parts = explode(' - ', $v['name']);
$indexes = explode('.', $v['index']);
if ($v['name'] === $_GET['chapter']) {
if (isset($i[($k - 1)])) {
$prev = $i[($k - 1)];
}
if (isset($i[($k + 1)])) {
$next = $i[($k + 1)];
}
$foundKey = ($k + 1);
$found = $v;
}
}
?>
<table width=100% cellspacing=5 cellpadding=1>
<tr>
<td align='center' colspan=2>
<b class='title'>
<?php
$chapter = array_shift($parts);
print 'Chapter ' . $indexes[0] . '. ' . $chapter;
?>
</b>
</td>
</tr>
<tr>
<td align='left'>
<?php
if(isset($prev)) {
?>
<b><a href=documentation2.php?chapter=<?php print urlencode($prev['name']); ?>>Prev</a></b>
<?php
}
?>
</td>
<td align='right'>
<?php
if(isset($next)) {
?>
<b><a href=documentation2.php?chapter=<?php print urlencode($next['name']); ?>>Next</a></b></td>
<?php
}
?>
</tr>
<tr>
<td colspan=2>
<b class='title'>
<?php
//print implode('.', $indexes) . '. ' . implode(' - ', $parts);
?>
</b>
<hr>
<b class='title'>
<?php
print implode('.', $indexes) . '. ';
$stack = array();
$links = array();
$tmp = array_merge(array($chapter), $parts);
foreach($tmp as $k => $v) {
$stack[] = $v;
$links[] = "<a href=documentation2.php?chapter=" . urlencode(implode(' - ', $stack)) . '>' . $v . '</a>';
}
print implode(' - ', $links);
?>
<br \>
</b>
<hr class='small'>
<?php
if ($subchapters) {
?>
<b class='title'>
<div class='level1'> Table of contents</div>
</b>
<?php
for ($x = $foundKey; $x < count($i); $x++) {
$p = explode(' - ', $i[$x]['name']);
$count = (count($parts) + 1);
$l = count($p) - count($parts);
while($count--) {
array_shift($p);
}
if ( ! empty($p)) {
print "<div class=level" . $l . '><font class=level' . $l . '>' . $i[$x]['index'];
?>
<a href=documentation2.php?chapter=<?php print urlencode($i[$x]['name']) . '>' . end($p); ?></a>
</font></div>
<?php
}
if (strncmp($i[$x]['name'], $_GET['chapter'], strlen($_GET['chapter'])) !== 0) {
break;
}
}
}
$doc->renderBlock($found['name']);
}
?>
</td>
</tr>
</table>
</td>
<td width=10>
</td>
<td valign='top' width=300>
<div class='smallmenu'>
<font class=smallmenu>&nbsp; -- <a href=documentation2.php>index</a></font><br \>
<?php
foreach ($i as $k => $v) {
$indexes = explode('.', $v['index']);
$level = count($indexes);
$e = explode(' - ', $v['name']);
if($level === 1) {
$level++;
print '<font class=smallmenu>&nbsp;'. $v['index'] . '. <a href=documentation2.php?chapter='
. urlencode($v['name']) . ">" . end($e) ."</a></font><br \>";
}
}
?>
</div>
</td>
</tr>
</table>
XSLSTYLE=doctrine.xsl
XSLSTYLE_CHUNKED=doctrine-chunked.xsl
%.html: book/%.xml
/usr/local/bin/xsieve -xinclude --output $@ $(XSLSTYLE) $<
/usr/local/bin/xsieve -xinclude --stringparam base.dir html/ $(XSLSTYLE_CHUNKED) $<
html: doctrine.html
WORK IN PROGRESS!!!
Please feel free to contribute, but these docs are currently being developed
by Ian P. Christian <pookey@pookey.co.uk>.
Find me on IRC and talk to me if you want to help.
Pleaes use xmllint to validate your changes BEFORE committing.
Please follow the intenting format used in the file.
*2 SPACES* for indenting.
That's SPACES not TABS :)
For documentation about docbook XSL, visit:
http://www.sagehill.net/docbookxsl/index.html
For information about docbook itself, google - there's LOTS of sites.
This is a good reference:
http://xml.web.cern.ch/XML/goossens/dbatcern/index.html
the 'definitive guide' can be found here:
http://www.docbook.org/tdg/en/html/docbook.html
Xsieve is used for syntax highlighting:
http://xsieve.sourceforge.net/
Downloaded from CVS, it has 'experiments/programlisting' directory
containing stuff for the highlighting - check the makefile
to see how it works.
This diff is collapsed.
<?xml version="1.0" encoding='ISO-8859-1'?>
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"
[
<!ENTITY chap1 SYSTEM "intro.xml">
<!ENTITY chap2 SYSTEM "conn-mgt.xml">
]>
<book id="doctrinebook">
<bookinfo>
<title>Doctrine Documentation</title>
<author>
<firstname>Konsta</firstname>
<surname>Vesterinen</surname>
<authorblurb>The creator and lead developer.</authorblurb>
</author>
<author>
<firstname>Ian</firstname>
<othername>P.</othername>
<surname>Christian</surname>
<email>pookey@pookey.co.uk</email>
<authorblurb>Junior developer and documentation maintainer.</authorblurb>
</author>
<copyright>
<holder>Doctrine Project</holder>
<year>2007</year>
</copyright>
<legalnotice id="legalnotice">
<para>
The contents of this document are licensed under the Creative Commons
<ulink url="http://creativecommons.org/licenses/by-sa/2.0/">Attribution-ShareAlike License</ulink>.
</para>
</legalnotice>
<abstract>
<para>
Documentation for the PHP Doctrine project.
</para>
<para>
This document was generated <?dbtimestamp format="Y-m-d H:M:S"?>.
</para>
</abstract>
</bookinfo>
&chap1;
&chap2;
<chapter id="object-relational-mapping">
<title>Object Relational Mapping</title>
</chapter>
<chapter id="working-with-objects">
<title>Working With Objects</title>
</chapter>
<chapter id="configuration">
<title>Configuration</title>
</chapter>
<chapter id="advanced-components">
<title>Advanced Components</title>
</chapter>
<chapter id="dql">
<title>DQL (Doctrine Query Lanaguage)</title>
<sect1 id="dql-intro">
<title>Introduction</title>
<para>
Doctrine Query Language(DQL) is an Object Query Language created for helping users in complex object retrieval.
</para>
<para>
You should always consider using DQL(or raw SQL) when retrieving relational data efficiently (eg. when fetching users and their phonenumbers).
</para>
<para>
When compared to using raw SQL, DQL has several benefits:
</para>
<itemizedlist>
<listitem><para>From the start it has been designed to retrieve records(objects) not result set rows.</para></listitem>
<listitem><para>DQL understands relations so you don't have to type manually sql joins and join conditions.</para></listitem>
<listitem><para>DQL is portable on different databases</para></listitem>
<listitem><para>DQL has some very complex built-in algorithms like (the record limit algorithm) which can help developer to efficiently retrieve objects.</para></listitem>
<listitem><para>It supports some functions that can save time when dealing with one-to-many, many-to-many relational data with conditional fetching.</para></listitem>
</itemizedlist>
<para>
If the power of DQL isn't enough, you should consider using the rawSql API for object population.
</para>
<programlisting role="php"><![CDATA[
<?php
// DO NOT USE THE FOLLOWING CODE
// (using many sql queries for object population):
$users = $conn->getTable('User')->findAll();
foreach($users as $user) {
print $user->name."\n";
foreach($user->Phonenumber as $phonenumber) {
print $phonenumber."\n";
}
}
// same thing implemented much more efficiently:
// (using only one sql query for object population)
$users = $conn->query("FROM User.Phonenumber");
foreach($users as $user) {
print $user->name."\n";
foreach($user->Phonenumber as $phonenumber) {
print $phonenumber."\n";
}
}
?>]]></programlisting>
</sect1>
</chapter>
<chapter id="native-sql">
<title>Native SQL</title>
</chapter>
<chapter id="transactions">
<title>Transactions</title>
</chapter>
<chapter id="caching">
<title>Caching</title>
</chapter>
<chapter id="database-abstraction">
<title>Database Abstraction</title>
</chapter>
<chapter id="technology">
<title>Technology</title>
</chapter>
<chapter id="real-world-examples">
<title>Real World Examples</title>
</chapter>
<chapter id="coding-standards">
<title>Coding Standards</title>
</chapter>
</book>
This diff is collapsed.
<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:import href="/usr/share/sgml/docbook/xsl-stylesheets-1.70.1/xhtml/chunk.xsl"/>
<xsl:import href="/home/clients/jhassine/doctrine/trunk/manual/docbook/programlisting/colorer.xsl"/>
<xsl:import href="/home/clients/jhassine/doctrine/trunk/manual/docbook/programlisting/colorer-html.xsl"/>
<xsl:param name="html.stylesheet" select="'../doctrine.css'"/>
<xsl:param name="section.autolabel" select="1"/>
<xsl:param name="section.label.includes.component.label" select="1"/><!-- adds section numbering, ie '1.3.1. Mailing Lists' -->
</xsl:stylesheet>
body, p, td
{
font-family: arial, "lucida console", sans-serif
}
.programlisting
{
margin: 10px;
background-color: #eeeeee;
}
<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:import href="/usr/share/sgml/docbook/xsl-stylesheets-1.70.1/xhtml/docbook.xsl"/>
<xsl:import href="/home/clients/jhassine/doctrine/trunk/manual/docbook/programlisting/colorer.xsl"/>
<xsl:import href="/home/clients/jhassine/doctrine/trunk/manual/docbook/programlisting/colorer-html.xsl"/>
<xsl:param name="html.stylesheet" select="'doctrine.css'"/>
<xsl:param name="section.autolabel" select="1"/>
<xsl:param name="section.label.includes.component.label" select="1"/><!-- adds section numbering, ie '1.3.1. Mailing Lists' -->
</xsl:stylesheet>
Making syntax highlighting work
-------------------------------
~/p/xsieve/opt/bin/xsieve -xinclude -o testdoc.html testdoc.xsl testdoc.xml
Development in this directory will be cancelled.
Something like $XSIEVE/examples/syntax_highlighting will be used.
colorer.scm: the main part, uniting trees
run-colorer.scm: low-level driver to execute a colorizing program
colorer.xsl: processing of "programlisting"
testdoc.* + test.xml: testing
run.sh: run "testdoc" conversion
testdata.xml, test.scm: testing
test-one.scm: testing
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:syn="http://ns.laxan.com/text-vimcolor/1" version="1.0">
<!-- $Id: colorer-html.xsl,v 1.2 2006/04/29 05:48:16 olpa Exp $ -->
<xsl:template match="syn:Comment">
<span style="color:#0000FF;">
<xsl:apply-templates />
</span>
</xsl:template>
<xsl:template match="syn:Constant">
<span style="color:#FF00FF;">
<xsl:apply-templates />
</span>
</xsl:template>
<xsl:template match="syn:Identifier">
<span style="color:#008B8B;">
<xsl:apply-templates />
</span>
</xsl:template>
<xsl:template match="syn:Statement">
<span style="color:#A52A2A; font-weight:bold;">
<xsl:apply-templates />
</span>
</xsl:template>
<xsl:template match="syn:PreProc">
<span style="color:#A020F0;">
<xsl:apply-templates />
</span>
</xsl:template>
<xsl:template match="syn:Type">
<span style="color:#2E8B57; font-weight:bold;">
<xsl:apply-templates />
</span>
</xsl:template>
<xsl:template match="syn:Special">
<span style="color:#6A5ACD;">
<xsl:apply-templates />
</span>
</xsl:template>
<xsl:template match="syn:Underlined">
<span style="color:#000000; text-decoration:underline;">
<xsl:apply-templates />
</span>
</xsl:template>
<xsl:template match="syn:Error">
<span style="color:#FFFFFF; background:#FF0000 none;">
<xsl:apply-templates />
</span>
</xsl:template>
<xsl:template match="syn:Todo">
<span style="color:#0000FF; background: #FFFF00 none;">
<xsl:apply-templates />
</span>
</xsl:template>
</xsl:stylesheet>
<xsl:stylesheet
xmlns:xsl = "http://www.w3.org/1999/XSL/Transform"
version = "1.0"
xmlns:s = "http://xsieve.sourceforge.net"
xmlns:syn = "http://ns.laxan.com/text-vimcolor/1"
extension-element-prefixes="s">
<!-- $Id: colorer-one.xsl,v 1.1 2006/05/22 04:23:51 olpa Exp $ -->
<xsl:import href="colorer.xsl" />
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*" />
</xsl:copy>
</xsl:template>
<xsl:template match="programlisting | screen[starts-with(@role,'colorer:')]">
<xsl:apply-imports />
</xsl:template>
</xsl:stylesheet>
; $Id: colorer.scm,v 1.8 2006/04/29 04:49:48 olpa Exp $
; construct a tree from the text and path
; "ignore" is a list of path element which shouldn't be added to the tree
; each path item is either symbol, which is the node name,
; either (symbol (@ ...)), which is the node name and the attribute node.
; It is supposed that elements with attributes aren't in the ignore list.
(define (colorer:path-to-tree text path ignore)
(let loop ((tree text) (path path))
(if (null? path)
tree
(let (
(cur (car path))
(nodeset (cons tree '())))
(loop
(if (pair? cur)
(append cur nodeset)
(if (memq cur ignore) tree (cons cur nodeset)))
(cdr path))))))
; A fragment of the text node handler
(define-macro (%colorer:on-text)
(quote (let loop ((cur cur))
(let* (
(len-buf (string-length buf))
(len-cur (string-length cur))
(len-min (min len-buf len-cur)))
(if (> len-cur 0) ; the text node in the h-tree isn't finished yet?
(let (
(result ; result is either a tree, eiter #f
(if (zero? len-buf) ; the text node in the main tree finished?
#f
(colorer:path-to-tree
(substring buf 0 len-min)
path
ignore))))
; Update buffer, switch to the main tree traversing,
; continue h-tree traversing on switching back
(set! buf (substring buf len-min len-buf))
(call-with-current-continuation (lambda (here)
(set! walker here)
(yield result)))
(loop (substring cur len-min len-cur))))))))
; A fragment of the node and attribute handler
(define-macro (%colorer:on-pair)
(quote (let ((elem (car cur)))
(if (eq? elem '@)
; attribute: attach to the path
(set-car! path (list (car path) cur))
; element: update path, continue traversing
(let ((path (cons (car cur) path)))
(for-each
(lambda (kid) (loop kid path))
(cdr cur)))))))
; generator of highlighted chunks.
; Creation:
; (define highlighter (colorer:join-markup-stepper highlight-tree ignore))
; Usage step:
; (highlighter more-buf)
; where more-buf either text, either #f. Each step returns either a
; subtree, either #f if buffer is over.
(define (colorer:join-markup-stepper highlight-tree ignore)
(letrec (
(buf #f)
(yield #f)
; The main loop
(walker-loop (lambda (cur path)
(let loop ((cur cur) (path path))
(if (pair? cur)
(%colorer:on-pair)
(%colorer:on-text)))
; The highlighting tree is over. Stop looping.
; If the main tree isn't over (impossible),
; just return the data from main tree.
(set! walker (lambda (dummy)
(if (and buf (> (string-length buf) 0))
(let ((old-buf buf))
(set! buf #f)
(yield old-buf))
(yield #f))))
(walker 'dummy)))
; Set buffer, continue looping
(walker-entry
(lambda (new-buf)
(if new-buf
(set! buf new-buf))
(call-with-current-continuation (lambda (here)
(set! yield here)
(walker 'resume)))))
; Use once, than re-set
(walker
(lambda (dummy)
(set! walker walker-loop)
(walker-loop highlight-tree '()))))
; create generator
walker-entry))
; add the colorer namespace to the tree
(define (colorer:wrap-by-ns tree)
`(syn:syntax (@ (@
(*NAMESPACES* (syn "http://ns.laxan.com/text-vimcolor/1"))))
,tree))
; join main markup with highlighting markup
(define colorer:id (lambda x x))
(define (colorer:join-markup main-tree highlight-tree ignore)
(let ((stepper (colorer:join-markup-stepper highlight-tree ignore)))
(colorer:wrap-by-ns
; Walk over the main tree
(pre-post-order main-tree `(
; Comments, entities etc are not possible, so only few special cases
(*PI* *preorder* . ,colorer:id)
(@ *preorder* . ,colorer:id)
(*default* . ,colorer:id)
; Text node: split on highlighted subtrees
(*text* . ,(lambda (trigger str)
(let loop (
(chunks '())
(tree (stepper str)))
(if tree
; Loop while trees are being generated
(loop (cons tree chunks) (stepper #f))
; The node is processed. If there is only one chunk, return
; it, otherwise wrap the nodeset of chunks by a dummy
; element. Handle also impossible case of absense of chunks.
(cond
((null? chunks) "")
((null? (cdr chunks)) (car chunks))
(else (cons 'syn:syntax (reverse chunks)))))))))))))
<xsl:stylesheet
xmlns:xsl = "http://www.w3.org/1999/XSL/Transform"
version = "1.0"
xmlns:s = "http://xsieve.sourceforge.net"
xmlns:syn = "http://ns.laxan.com/text-vimcolor/1"
extension-element-prefixes="s">
<!-- $Id: colorer.xsl,v 1.6 2006/04/29 04:30:03 olpa Exp $ -->
<xsl:param name="colorer.bin">/home/clients/jhassine/doctrine/trunk/manual/docbook/programlisting/vimcolor/vimcolor-wrapper</xsl:param>
<xsl:param name="colorer.params">--format xml</xsl:param>
<xsl:param name="colorer.param.type">--filetype </xsl:param>
<xsl:param name="colorer.param.outfile">--output </xsl:param>
<s:init>
(load-from-path "sxml-utils.scm")
(load-from-path "colorer.scm")
(load-from-path "run-colorer.scm")
</s:init>
<!-- ProgramListing is colorized -->
<xsl:template match="programlisting[parent::syn:syntax] | screen[parent::syn:syntax]" priority="2">
<xsl:apply-imports/>
</xsl:template>
<!-- Colorize ProgramListing -->
<xsl:template match="programlisting | screen[starts-with(@role,'colorer:')]">
<xsl:variable name="type">
<xsl:choose>
<xsl:when test="self::screen"><xsl:value-of select="substring-after(@role,':')"/></xsl:when>
<xsl:otherwise><xsl:value-of select="@role"/></xsl:otherwise>
</xsl:choose>
</xsl:variable>
<s:scheme>
(let* (
(highlighted-tree (run-colorer (x:eval "string(.)") (x:eval "string($type)")))
(current (x:current))
(united-tree
(if (not highlighted-tree)
#f
(colorer:join-markup current highlighted-tree '()))))
(x:apply-templates
'with-param 'colorized #t
(if united-tree
united-tree
(colorer:wrap-by-ns current))))
</s:scheme>
</xsl:template>
<xsl:template match="syn:syntax">
<xsl:apply-templates select="node()"/>
</xsl:template>
</xsl:stylesheet>
/Makefile/1.1/Mon May 22 04:24:28 2006//
/vim2xslt.pl/1.1/Mon May 22 04:24:28 2006//
D
:pserver:anonymous@xsieve.cvs.sourceforge.net:/cvsroot/xsieve
vim_colors_dir = /usr/share/vim/colors
vim_files := $(wildcard $(vim_colors_dir)/*.vim)
xslt_files = $(patsubst %.vim,%.xsl,$(notdir $(vim_files)))
all: $(xslt_files)
%.xsl: $(vim_colors_dir)/%.vim
perl vim2xslt.pl $< >$@
#!/usr/bin/perl
# Take vim colors file and convert it to an XSLT stylesheet
# The only types vim-textcolor produces
my %syntax_data = (
'Comment' => undef,
'Constant' => undef,
'Identifier' => undef,
'Statement' => undef,
'PreProc' => undef,
'Type' => undef,
'Special' => undef,
'Underlined' => undef,
'Error' => undef,
'Todo' => undef
);
<xsl:stylesheet
xmlns:xsl = "http://www.w3.org/1999/XSL/Transform"
version = "1.0">
<xsl:template match="node()">
<xsl:copy>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
<html>
<head>
<title>Syntax highlighting for DocBook program listings</title>
</head>
<body style="background:#ffffff;">
<h1>Syntax highlighting for DocBook program listings</h1>
<p>Highlight content of <tt>ProgramListing</tt> using <a href="http://xsieve.sourceforge.net/">XSieve</a> and Vim. Example:</p>
<table border="0" cellspacing="5" cellpadding="5">
<tr>
<th valign="top">DocBook</th>
<td>
<pre style="background:#f0f0f0;">&lt;programlisting role=&quot;xml&quot;&gt;
&amp;lt;para&gt;Hello, &lt;emphasis&gt;&amp;amp;who;&lt;/emphasis
&gt;!&amp;lt;/para&gt; &lt;co id=&quot;who-entity&quot;/&gt;
&lt;/programlisting&gt;</pre>
</td>
</tr>
<tr>
<th>HTML&nbsp;result&nbsp;&nbsp;&nbsp;</th>
<td>
<pre style="background:#f0f0f0;">
<span style="color:#008B8B;">&lt;para&gt;</span>Hello, <span class="emphasis"><em><span style="color:#2E8B57; font-weight:bold;">&amp;</span><span style="color:#A52A2A; font-weight:bold;">who</span><span style="color:#2E8B57; font-weight:bold;">;</span></em></span>!<span style="color:#008B8B;">&lt;/para&gt;</span> (1)</pre>
</td>
</tr>
</table>
<a href="xsieve-programlisting.zip">Download</a> xsieve-programlisting.zip.
<h2>Usage</h2>
<p>Set the correct path to the script <tt>vimcolor-wrapper</tt> in <tt>colorer.xsl</tt>.</p>
<p>Create an XSLT wrapper which imports DocBook and colorer stylesheets:</p>
<pre style="background:#f0f0f0;">
<font color="#008b8b">&lt;</font><font color="#6a5acd">xsl</font><font color="#0000ff">:</font><font color="#a52a2a"><b>stylesheet</b></font><font color="#008b8b"> ...&gt;</font>
...
<font color="#008b8b">&lt;</font><font color="#6a5acd">xsl</font><font color="#0000ff">:</font><font color="#a52a2a"><b>import</b></font><font color="#008b8b"> </font><font color="#2e8b57"><b>href</b></font>=<font color="#ff00ff">&quot;..../docbook.xsl&quot;</font><font color="#008b8b">&gt;</font> (1)
<font color="#008b8b">&lt;</font><font color="#6a5acd">xsl</font><font color="#0000ff">:</font><font color="#a52a2a"><b>import</b></font><font color="#008b8b"> </font><font color="#2e8b57"><b>href</b></font>=<font color="#ff00ff">&quot;..../colorer.xsl&quot;</font><font color="#008b8b">&gt;</font> (2)
<font color="#008b8b">&lt;</font><font color="#6a5acd">xsl</font><font color="#0000ff">:</font><font color="#a52a2a"><b>import</b></font><font color="#008b8b"> </font><font color="#2e8b57"><b>href</b></font>=<font color="#ff00ff">&quot;..../colorer-html.xsl&quot;</font><font color="#008b8b">&gt;</font> (3)
... Your DocBook customization layer ...
<font color="#008b8b">&lt;/</font><font color="#6a5acd">xsl</font><font color="#0000ff">:</font><font color="#a52a2a"><b>stylesheet</b></font><font color="#008b8b">&gt;</font>
</pre>
<p><b>(1)</b> The path to the DocBook XSLT stylesheet. For example, <tt>/usr/share/xml/docbook/xsl-stylesheets/html/docbook.xsl</tt><br />
<b>(2)</b> The path to the colorer XSLT stylesheet.<br />
<b>(3)</b> Or <tt>colorer-fo.xsl</tt> for FO output.</p>
<h2>Test data</h2>
<p>The package contains test files <tt>test.xml</tt>, <tt>testdoc.xsl</tt> and <tt>testdoc.html</tt>. Use them as the starting point:</p>
<pre>xsieve -o testdoc.html --param callout.graphics 0 testdoc.xsl test.xml</pre>
</body>
</html>
rm -rf xsieve-programlisting.zip xsieve-programlisting
mkdir xsieve-programlisting
rsync -av --exclude CVS vimcolor xsieve-programlisting/
cp colorer.xsl colorer-html.xsl testdoc.xsl index.html sxml-utils.scm colorer.scm run-colorer.scm test.xml testdoc.html xsieve-programlisting/
zip xsieve-programlisting.zip -r xsieve-programlisting
; Run colorer and return the result as SXML
; $Id: run-colorer.scm,v 1.6 2006/04/29 05:47:24 olpa Exp $
(define colorer-bin #f)
(define colorer-params #f)
(define colorer-param-type #f)
(define colorer-param-outfile #f)
; Initialize colorer variables (only once)
(define (init-colorer-variables)
(if (not colorer-bin) (begin
(set! colorer-bin (x:eval "string($colorer.bin)"))
(set! colorer-params (x:eval "string($colorer.params)"))
(set! colorer-param-type (x:eval "string($colorer.param.type)"))
(set! colorer-param-outfile (x:eval "string($colorer.param.outfile)")))))
(define-macro (no-errors . body)
`(catch #t (lambda () ,@body) (lambda (dummy . args) #f)))
(define (run-colorer program-text program-type)
; Some sanity check
(init-colorer-variables)
(if (not (and program-text (> (string-length program-text) 0)))
#f
(let* (
; Construct command line to run the colorer
(infile (tmpnam)) ; for the program text
(outfile (tmpnam)) ; for the colored tokens
(cmdline (string-append
colorer-bin " " colorer-params " "
(if (and program-type (> (string-length program-type) 0))
(string-append colorer-param-type program-type " ")
"")
colorer-param-outfile outfile " " infile)))
;(display "Command line: ")(display cmdline)(newline)
; Ignore errors
(no-errors
; Write the program text to the file and execute the colorer
(with-output-to-file infile
(lambda () (display program-text)))
;(system (string-append "cp " infile " lastin")) ; DEBUG
(system cmdline)
;(system (string-append "cp " outfile " last")) ; DEBUG
; Load the XML result, cleanup and return the result
(let* (
(eval-str (string-append "document('file://" outfile "')"))
(tree (x:eval eval-str)))
(no-errors (delete-file outfile))
(no-errors (delete-file infile))
; drop "*TOP*" and drop namespace declaration from "syn:syntax"
(cons 'syn:syntax (cdr (cdadar tree))))))))
~/p/xsieve/opt/bin/xsieve --xinclude -o testdoc.html testdoc.xsl testdoc.xml
#~/p/xsieve/opt/bin/xsieve --xinclude -o testdoc.html testdoc.xsl /home/olpa/p/xsieve/doc/book/xsieve.xml
~/p/xsieve/opt/bin/xsieve -o testdoc.html testdoc.xsl xsieve.xml
~/p/xsieve/opt/bin/xsieve --xinclude -o testdoc.html colorer-one.xsl /home/olpa/p/xsieve/example/hello/doc/listing2.xml
#~/p/xsieve/opt/bin/xsieve --xinclude -o testdoc.html testdoc.xsl /home/olpa/p/xsieve/doc/book/xsieve.xml
~/p/xsieve/opt/bin/xsieve -o testdoc.html --param callout.graphics 0 testdoc.xsl /home/olpa/p/xsieve/doc/project/xtech2006/programlisting/test.xml
; $Id: sxml-utils.scm,v 1.1 2006/03/02 04:32:58 olpa Exp $
; A copy-paste of a part of the SXML library
; from CVS: SSAX/lib/SXML-tree-trans.scm
(define (pre-post-order tree bindings)
(let* ((default-binding (assq '*default* bindings))
(text-binding (or (assq '*text* bindings) default-binding))
(text-handler ; Cache default and text bindings
(and text-binding
(if (procedure? (cdr text-binding))
(cdr text-binding) (cddr text-binding)))))
(let loop ((tree tree))
(cond
((null? tree) '())
((not (pair? tree))
(let ((trigger '*text*))
(if text-handler (text-handler trigger tree)
(error "Unknown binding for " trigger " and no default"))))
((not (symbol? (car tree))) (map loop tree)) ; tree is a nodelist
(else ; tree is an SXML node
(let* ((trigger (car tree))
(binding (or (assq trigger bindings) default-binding)))
(cond
((not binding)
(error "Unknown binding for " trigger " and no default"))
((not (pair? (cdr binding))) ; must be a procedure: handler
(apply (cdr binding) trigger (map loop (cdr tree))))
((eq? '*preorder* (cadr binding))
(apply (cddr binding) tree))
((eq? '*macro* (cadr binding))
(loop (apply (cddr binding) tree)))
(else ; (cadr binding) is a local binding
(apply (cddr binding) trigger
(pre-post-order (cdr tree) (append (cadr binding) bindings)))
))))))))
(load "sxml-utils.scm")
(load "colorer.scm")
(define main-tree '(programlisting (*PI* a "b") (@ (format "linespecific")) "<article id=\"hw\">
<title>Hello</title>
<para>Hello <object>World</object>!</para>
</article>"))
(define h-tree "")
(define result (colorer:join-markup main-tree h-tree '(h)))
(write result)
; $Id: test.scm,v 1.2 2006/03/02 06:01:06 olpa Exp $
(define (test-case main-tree h-tree expected-result)
(display "------- Running a test case...")
(let ((result (caddr (colorer:join-markup main-tree h-tree '(h)))))
(if (equal? result expected-result)
(begin
(display "Ok")(newline))
(begin
(display "Error")(newline)
(display "Expected: ")(write expected-result)(newline)
(display "Result: ")(write result)(newline)))))
(load "sxml-utils.scm")
(load "colorer.scm")
(load "testdata.scm")
<?xml version="1.0"?>
<article>
<title>Testing Syntax Highlighting</title>
<para>Testing syntax highlighting</para>
<programlisting role="xml">
&lt;para>Hello, <emphasis>&amp;who;</emphasis
>!&lt;/para> <co id="who-entity"/>
</programlisting>
</article>
; test cases for joining parallel markup
; $Id: testdata.scm,v 1.2 2006/03/02 05:58:55 olpa Exp $
; (test-case in-xml also-xml joined-xml)
; the simplest test, no highlighting at all
(test-case
'(i "012")
'(h "012")
'(i "012"))
; the simplest test, some highlighting
(test-case
'(i "012")
'(h "0" (a "1") "2")
'(i (colorer:dummy "0" (a "1") "2")))
; the size of text is different
(test-case
'(i "0123456789")
'(h (a "01") "234" (b "56") "7")
'(i (colorer:dummy (a "01") "234" (b "56") "7" "89")))
(test-case
'(i "01234567")
'(h "0" (a "12") "345" (b "5789"))
'(i (colorer:dummy "0" (a "12") "345" (b "67"))))
; the text of the main tree is not corrupted
(test-case
'(i "012345")
'(h "ab" (c "cd") "ef")
'(i (colorer:dummy "01" (c "23") "45")))
; attributes are saved
(test-case
'(i "012345")
'(h "01"
(a (@ (a1 "a1") (a2 "a2"))
(b (@ (b1 "b1") (b2 "b2"))
"23"))
"45")
'(i (colorer:dummy "01"
(a (@ (a1 "a1") (a2 "a2"))
(b (@ (b1 "b1") (b2 "b2"))
"23"))
"45")))
; ordering and nesting of empty tags
(test-case
'(i "012" (x (y)) (z) "34")
'(h "01" (a "23") "4")
'(i (colorer:dummy "01" (a "2")) (x (y)) (z) (colorer:dummy (a "3") "4")))
; intersecting at left
(test-case
'(i "01" (a "2345" (b "67")))
'(h "012" (x (y "3456")) "7")
'(i "01" (a (colorer:dummy "2" (x (y "345"))) (b (colorer:dummy (x (y "6")) "7")))))
; intersecting at right
(test-case
'(i "01" (a "23" (b "45") "6") "78")
'(h "01234" (x (y "56")) "78")
'(i "01" (a "23" (b (colorer:dummy "4" (x (y "5")))) (x (y "6"))) "78"))
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>Article with code</title><meta name="generator" content="DocBook XSL Stylesheets V1.70.1" /></head><body><div class="article" lang="en" xml:lang="en"><div class="titlepage"><div><div><h2 class="title"><a id="id2434734"></a>Article with code</h2></div></div><hr /></div><p>A sample code:</p><div class="example"><a id="id2433082"></a><p class="title"><b>Example 1. </b></p><div class="example-contents"><div class="article" lang="en" xml:lang="en"><div class="titlepage"><div><div><h2 class="title"><a id="id2434675"></a>Testing Syntax Highlighting</h2></div></div><hr /></div><p>Testing syntax highlighting</p><pre class="programlisting">
<span xmlns="" xmlns:syn="http://ns.laxan.com/text-vimcolor/1" style="color:#008B8B;">&lt;para&gt;</span>Hello, <span class="emphasis"><em><span xmlns="" xmlns:syn="http://ns.laxan.com/text-vimcolor/1" style="color:#2E8B57; font-weight:bold;">&amp;</span><span xmlns="" xmlns:syn="http://ns.laxan.com/text-vimcolor/1" style="color:#A52A2A; font-weight:bold;">who</span><span xmlns="" xmlns:syn="http://ns.laxan.com/text-vimcolor/1" style="color:#2E8B57; font-weight:bold;">;</span></em></span>!<span xmlns="" xmlns:syn="http://ns.laxan.com/text-vimcolor/1" style="color:#008B8B;">&lt;/para&gt;</span> <a id="who-entity"></a><img src="images/callouts/1.png" alt="1" border="0" />
</pre></div></div></div><br class="example-break" /></div></body></html>
<article>
<title>Article with code</title>
<para>A sample code:</para>
<example>
<xi:include href="test.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
</example>
</article>
<xsl:stylesheet
xmlns:xsl = "http://www.w3.org/1999/XSL/Transform"
version = "1.0">
<xsl:import href="/usr/share/sgml/docbook/xsl-stylesheets-1.70.1/xhtml/docbook.xsl"/>
<xsl:import href="colorer.xsl"/>
<xsl:import href="colorer-html.xsl"/>
</xsl:stylesheet>
/README/1.1/Fri Apr 28 07:09:09 2006//
/README-Path-Class/1.1/Fri Apr 28 07:09:09 2006//
/README-Text-VimColor/1.1/Fri Apr 28 07:09:09 2006//
/text-vimcolor/1.1/Fri Apr 28 07:09:09 2006//
/vimcolor-wrapper/1.1/Fri Apr 28 07:09:09 2006//
D/lib////
xsieve/experiments/programlisting/vimcolor
:pserver:anonymous@xsieve.cvs.sourceforge.net:/cvsroot/xsieve
Command-line syntax highlighting based on vim
It uses Perl modules Text::VimColor and Path::Class.
Perl libraries of these modules are copied to "lib".
The program "vimcolor-wrapper" sets the path to the
local copy of the libraries and runs the original
script "text-vimcolor".
NAME
Path::Class - Cross-platform path specification manipulation
SYNOPSIS
use Path::Class;
my $dir = dir('foo', 'bar'); # Path::Class::Dir object
my $file = file('bob', 'file.txt'); # Path::Class::File object
# Stringifies to 'foo/bar' on Unix, 'foo\bar' on Windows, etc.
print "dir: $dir\n";
# Stringifies to 'bob/file.txt' on Unix, 'bob\file.txt' on Windows
print "file: $file\n";
my $subdir = $dir->subdir('baz'); # foo/bar/baz
my $parent = $subdir->parent; # foo/bar
my $parent2 = $parent->parent; # foo
my $dir2 = $file->dir; # bob
# Work with foreign paths
use Path::Class qw(foreign_file foreign_dir);
my $file = foreign_file('Mac', ':foo:file.txt');
print $file->dir; # :foo:
print $file->as_foreign('Win32'); # foo\file.txt
# Interact with the underlying filesystem:
# $dir_handle is an IO::Dir object
my $dir_handle = $dir->open or die "Can't read $dir: $!";
# $file_handle is an IO::File object
my $file_handle = $file->open($mode) or die "Can't read $file: $!";
DESCRIPTION
`Path::Class' is a module for manipulation of file and directory
specifications (strings describing their locations, like
`'/home/ken/foo.txt'' or `'C:\Windows\Foo.txt'') in a cross-platform
manner. It supports pretty much every platform Perl runs on, including
Unix, Windows, Mac, VMS, Epoc, Cygwin, OS/2, and NetWare.
The well-known module `File::Spec' also provides this service, but it's
sort of awkward to use well, so people sometimes avoid it, or use it in
a way that won't actually work properly on platforms significantly
different than the ones they've tested their code on.
In fact, `Path::Class' uses `File::Spec' internally, wrapping all the
unsightly details so you can concentrate on your application code.
Whereas `File::Spec' provides functions for some common path
manipulations, `Path::Class' provides an object-oriented model of the
world of path specifications and their underlying semantics.
`File::Spec' doesn't create any objects, and its classes represent the
different ways in which paths must be manipulated on various platforms
(not a very intuitive concept). `Path::Class' creates objects
representing files and directories, and provides methods that relate
them to each other. For instance, the following `File::Spec' code:
my $absolute = File::Spec->file_name_is_absolute(
File::Spec->catfile( @dirs, $file )
);
can be written using `Path::Class' as
my $absolute = Path::Class::File->new( @dirs, $file )->is_absolute;
or even as
my $absolute = file( @dirs, $file )->is_absolute;
Similar readability improvements should happen all over the place when
using `Path::Class'.
Using `Path::Class' can help solve real problems in your code too - for
instance, how many people actually take the "volume" (like `C:' on
Windows) into account when writing `File::Spec'-using code? I thought
not. But if you use `Path::Class', your file and directory objects will
know what volumes they refer to and do the right thing.
The guts of the `Path::Class' code live in the `Path::Class::File' and
`Path::Class::Dir' modules, so please see those modules' documentation
for more details about how to use them.
EXPORT
The following functions are exported by default.
file
A synonym for `Path::Class::File->new'.
dir A synonym for `Path::Class::Dir->new'.
If you would like to prevent their export, you may explicitly pass an
empty list to perl's `use', i.e. `use Path::Class ()'.
The following are exported only on demand.
foreign_file
A synonym for `Path::Class::File->new_foreign'.
foreign_dir
A synonym for `Path::Class::Dir->new_foreign'.
Notes on Cross-Platform Compatibility
Although it is much easier to write cross-platform-friendly code with
this module than with `File::Spec', there are still some issues to be
aware of.
* Some platforms, notably VMS and some older versions of DOS (I
think), all filenames must have an extension. Thus if you create a
file called foo/bar and then ask for a list of files in the
directory foo, you may find a file called bar. instead of the bar
you were expecting. Thus it might be a good idea to use an extension
in the first place.
AUTHOR
Ken Williams, KWILLIAMS@cpan.org
COPYRIGHT
Copyright (c) Ken Williams. All rights reserved.
This library is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
SEE ALSO
Path::Class::Dir, Path::Class::File, File::Spec
Text::VimColor
--------------
This module tries to markup text files according to their syntax. It can
be used to produce web pages with pretty-printed colourful source code
samples. It can produce output in the following formats:
The module comes with a command line program, text-vimcolor, which makes
it easy to do 'ad-hoc' syntax coloring jobs.
Geoff Richards <qef@laxan.com>
Release procedure
-----------------
* Update the version number in lib/Text/VimColor.pm and META.yml
* Update the changelog with a new section for a matching version number
and the correct date and time
* Copy the ChangeLog into place (from 'debian' directory in my CVS)
* Realclean, make and test
* Make the dist, take it to another machine and build and test there
* Commit everything, and set tag like 'Release_0_07-1'
* Upload to CPAN
xsieve/experiments/programlisting/vimcolor/lib
:pserver:anonymous@xsieve.cvs.sourceforge.net:/cvsroot/xsieve
/Class.pm/1.1/Fri Apr 28 07:17:33 2006//
D/Class////
xsieve/experiments/programlisting/vimcolor/lib/Path
:pserver:anonymous@xsieve.cvs.sourceforge.net:/cvsroot/xsieve
package Path::Class;
$VERSION = '0.15';
@ISA = qw(Exporter);
@EXPORT = qw(file dir);
@EXPORT_OK = qw(file dir foreign_file foreign_dir);
use strict;
use Exporter;
use Path::Class::File;
use Path::Class::Dir;
sub file { Path::Class::File->new(@_) }
sub dir { Path::Class::Dir ->new(@_) }
sub foreign_file { Path::Class::File->new_foreign(@_) }
sub foreign_dir { Path::Class::Dir ->new_foreign(@_) }
1;
__END__
=head1 NAME
Path::Class - Cross-platform path specification manipulation
=head1 SYNOPSIS
use Path::Class;
my $dir = dir('foo', 'bar'); # Path::Class::Dir object
my $file = file('bob', 'file.txt'); # Path::Class::File object
# Stringifies to 'foo/bar' on Unix, 'foo\bar' on Windows, etc.
print "dir: $dir\n";
# Stringifies to 'bob/file.txt' on Unix, 'bob\file.txt' on Windows
print "file: $file\n";
my $subdir = $dir->subdir('baz'); # foo/bar/baz
my $parent = $subdir->parent; # foo/bar
my $parent2 = $parent->parent; # foo
my $dir2 = $file->dir; # bob
# Work with foreign paths
use Path::Class qw(foreign_file foreign_dir);
my $file = foreign_file('Mac', ':foo:file.txt');
print $file->dir; # :foo:
print $file->as_foreign('Win32'); # foo\file.txt
# Interact with the underlying filesystem:
# $dir_handle is an IO::Dir object
my $dir_handle = $dir->open or die "Can't read $dir: $!";
# $file_handle is an IO::File object
my $file_handle = $file->open($mode) or die "Can't read $file: $!";
=head1 DESCRIPTION
C<Path::Class> is a module for manipulation of file and directory
specifications (strings describing their locations, like
C<'/home/ken/foo.txt'> or C<'C:\Windows\Foo.txt'>) in a cross-platform
manner. It supports pretty much every platform Perl runs on,
including Unix, Windows, Mac, VMS, Epoc, Cygwin, OS/2, and NetWare.
The well-known module C<File::Spec> also provides this service, but
it's sort of awkward to use well, so people sometimes avoid it, or use
it in a way that won't actually work properly on platforms
significantly different than the ones they've tested their code on.
In fact, C<Path::Class> uses C<File::Spec> internally, wrapping all
the unsightly details so you can concentrate on your application code.
Whereas C<File::Spec> provides functions for some common path
manipulations, C<Path::Class> provides an object-oriented model of the
world of path specifications and their underlying semantics.
C<File::Spec> doesn't create any objects, and its classes represent
the different ways in which paths must be manipulated on various
platforms (not a very intuitive concept). C<Path::Class> creates
objects representing files and directories, and provides methods that
relate them to each other. For instance, the following C<File::Spec>
code:
my $absolute = File::Spec->file_name_is_absolute(
File::Spec->catfile( @dirs, $file )
);
can be written using C<Path::Class> as
my $absolute = Path::Class::File->new( @dirs, $file )->is_absolute;
or even as
my $absolute = file( @dirs, $file )->is_absolute;
Similar readability improvements should happen all over the place when
using C<Path::Class>.
Using C<Path::Class> can help solve real problems in your code too -
for instance, how many people actually take the "volume" (like C<C:>
on Windows) into account when writing C<File::Spec>-using code? I
thought not. But if you use C<Path::Class>, your file and directory objects
will know what volumes they refer to and do the right thing.
The guts of the C<Path::Class> code live in the C<Path::Class::File>
and C<Path::Class::Dir> modules, so please see those
modules' documentation for more details about how to use them.
=head2 EXPORT
The following functions are exported by default.
=over 4
=item file
A synonym for C<< Path::Class::File->new >>.
=item dir
A synonym for C<< Path::Class::Dir->new >>.
=back
If you would like to prevent their export, you may explicitly pass an
empty list to perl's C<use>, i.e. C<use Path::Class ()>.
The following are exported only on demand.
=over 4
=item foreign_file
A synonym for C<< Path::Class::File->new_foreign >>.
=item foreign_dir
A synonym for C<< Path::Class::Dir->new_foreign >>.
=back
=head1 Notes on Cross-Platform Compatibility
Although it is much easier to write cross-platform-friendly code with
this module than with C<File::Spec>, there are still some issues to be
aware of.
=over 4
=item *
Some platforms, notably VMS and some older versions of DOS (I think),
all filenames must have an extension. Thus if you create a file
called F<foo/bar> and then ask for a list of files in the directory
F<foo>, you may find a file called F<bar.> instead of the F<bar> you
were expecting. Thus it might be a good idea to use an extension in
the first place.
=back
=head1 AUTHOR
Ken Williams, KWILLIAMS@cpan.org
=head1 COPYRIGHT
Copyright (c) Ken Williams. All rights reserved.
This library is free software; you can redistribute it and/or
modify it under the same terms as Perl itself.
=head1 SEE ALSO
Path::Class::Dir, Path::Class::File, File::Spec
=cut
/Dir.pm/1.1/Fri Apr 28 07:17:33 2006//
/Entity.pm/1.1/Fri Apr 28 07:17:33 2006//
/File.pm/1.1/Fri Apr 28 07:17:33 2006//
D
xsieve/experiments/programlisting/vimcolor/lib/Path/Class
:pserver:anonymous@xsieve.cvs.sourceforge.net:/cvsroot/xsieve
package Path::Class::Entity;
use strict;
use File::Spec;
use File::stat ();
use overload
(
q[""] => 'stringify',
fallback => 1,
);
sub new {
my $from = shift;
my ($class, $fs_class) = (ref($from)
? (ref $from, $from->{file_spec_class})
: ($from, $Path::Class::Foreign));
return bless {file_spec_class => $fs_class}, $class;
}
sub is_dir { 0 }
sub _spec_class {
my ($class, $type) = @_;
die "Invalid system type '$type'" unless ($type) = $type =~ /^(\w+)$/; # Untaint
my $spec = "File::Spec::$type";
eval "require $spec; 1" or die $@;
return $spec;
}
sub new_foreign {
my ($class, $type) = (shift, shift);
local $Path::Class::Foreign = $class->_spec_class($type);
return $class->new(@_);
}
sub _spec { $_[0]->{file_spec_class} || 'File::Spec' }
sub is_absolute {
# 5.6.0 has a bug with regexes and stringification that's ticked by
# file_name_is_absolute(). Help it along.
$_[0]->_spec->file_name_is_absolute($_[0]->stringify)
}
sub cleanup {
my $self = shift;
my $cleaned = $self->new( $self->_spec->canonpath($self) );
%$self = %$cleaned;
return $self;
}
sub absolute {
my $self = shift;
return $self if $self->is_absolute;
return $self->new($self->_spec->rel2abs($self->stringify, @_));
}
sub relative {
my $self = shift;
return $self->new($self->_spec->abs2rel($self->stringify, @_));
}
sub stat { File::stat::stat("$_[0]") }
sub lstat { File::stat::lstat("$_[0]") }
1;
package Path::Class::File;
use strict;
use Path::Class::Dir;
use Path::Class::Entity;
use base qw(Path::Class::Entity);
use IO::File ();
sub new {
my $self = shift->SUPER::new;
my $file = pop();
my @dirs = @_;
my ($volume, $dirs, $base) = $self->_spec->splitpath($file);
if (length $dirs) {
push @dirs, $self->_spec->catpath($volume, $dirs, '');
}
$self->{dir} = @dirs ? Path::Class::Dir->new(@dirs) : undef;
$self->{file} = $base;
return $self;
}
sub as_foreign {
my ($self, $type) = @_;
local $Path::Class::Foreign = $self->_spec_class($type);
my $foreign = ref($self)->SUPER::new;
$foreign->{dir} = $self->{dir}->as_foreign($type) if defined $self->{dir};
$foreign->{file} = $self->{file};
return $foreign;
}
sub stringify {
my $self = shift;
return $self->{file} unless defined $self->{dir};
return $self->_spec->catfile($self->{dir}->stringify, $self->{file});
}
sub dir {
my $self = shift;
return $self->{dir} if defined $self->{dir};
return Path::Class::Dir->new($self->_spec->curdir);
}
BEGIN { *parent = \&dir; }
sub volume {
my $self = shift;
return '' unless defined $self->{dir};
return $self->{dir}->volume;
}
sub basename { shift->{file} }
sub open { IO::File->new(@_) }
sub openr { $_[0]->open('r') or die "Can't read $_[0]: $!" }
sub openw { $_[0]->open('w') or die "Can't write $_[0]: $!" }
sub touch {
my $self = shift;
if (-e $self) {
my $now = time();
utime $now, $now, $self;
} else {
$self->openw;
}
}
sub slurp {
my ($self, %args) = @_;
my $fh = $self->openr;
if ($args{chomped} or $args{chomp}) {
chomp( my @data = <$fh> );
return wantarray ? @data : join '', @data;
}
local $/ unless wantarray;
return <$fh>;
}
sub remove {
my $file = shift->stringify;
return unlink $file unless -e $file; # Sets $! correctly
1 while unlink $file;
return not -e $file;
}
1;
__END__
=head1 NAME
Path::Class::File - Objects representing files
=head1 SYNOPSIS
use Path::Class qw(file); # Export a short constructor
my $file = file('foo', 'bar.txt'); # Path::Class::File object
my $file = Path::Class::File->new('foo', 'bar.txt'); # Same thing
# Stringifies to 'foo/bar.txt' on Unix, 'foo\bar.txt' on Windows, etc.
print "file: $file\n";
if ($file->is_absolute) { ... }
my $v = $file->volume; # Could be 'C:' on Windows, empty string
# on Unix, 'Macintosh HD:' on Mac OS
$file->cleanup; # Perform logical cleanup of pathname
my $dir = $file->dir; # A Path::Class::Dir object
my $abs = $file->absolute; # Transform to absolute path
my $rel = $file->relative; # Transform to relative path
=head1 DESCRIPTION
The C<Path::Class::File> class contains functionality for manipulating
file names in a cross-platform way.
=head1 METHODS
=over 4
=item $file = Path::Class::File->new( <dir1>, <dir2>, ..., <file> )
=item $file = file( <dir1>, <dir2>, ..., <file> )
Creates a new C<Path::Class::File> object and returns it. The
arguments specify the path to the file. Any volume may also be
specified as the first argument, or as part of the first argument.
You can use platform-neutral syntax:
my $dir = file( 'foo', 'bar', 'baz.txt' );
or platform-native syntax:
my $dir = dir( 'foo/bar/baz.txt' );
or a mixture of the two:
my $dir = dir( 'foo/bar', 'baz.txt' );
All three of the above examples create relative paths. To create an
absolute path, either use the platform native syntax for doing so:
my $dir = dir( '/var/tmp/foo.txt' );
or use an empty string as the first argument:
my $dir = dir( '', 'var', 'tmp', 'foo.txt' );
If the second form seems awkward, that's somewhat intentional - paths
like C</var/tmp> or C<\Windows> aren't cross-platform concepts in the
first place, so they probably shouldn't appear in your code if you're
trying to be cross-platform. The first form is perfectly fine,
because paths like this may come from config files, user input, or
whatever.
=item $file->stringify
This method is called internally when a C<Path::Class::File> object is
used in a string context, so the following are equivalent:
$string = $file->stringify;
$string = "$file";
=item $file->volume
Returns the volume (e.g. C<C:> on Windows, C<Macintosh HD:> on Mac OS,
etc.) of the object, if any. Otherwise, returns the empty string.
=item $file->basename
Returns the name of the file as a string, without the directory
portion (if any).
=item $file->is_dir
Returns a boolean value indicating whether this object represents a
directory. Not surprisingly, C<Path::Class::File> objects always
return false, and C<Path::Class::Dir> objects always return true.
=item $file->is_absolute
Returns true or false depending on whether the file refers to an
absolute path specifier (like C</usr/local/foo.txt> or C<\Windows\Foo.txt>).
=item $file->cleanup
Performs a logical cleanup of the file path. For instance:
my $file = file('/foo//baz/./foo.txt')->cleanup;
# $file now represents '/foo/baz/foo.txt';
=item $dir = $file->dir
Returns a C<Path::Class::Dir> object representing the directory
containing this file.
=item $dir = $file->parent
A synonym for the C<dir()> method.
=item $abs = $file->absolute
Returns a C<Path::Class::File> object representing C<$file> as an
absolute path. An optional argument, given as either a string or a
C<Path::Class::Dir> object, specifies the directory to use as the base
of relativity - otherwise the current working directory will be used.
=item $rel = $file->relative
Returns a C<Path::Class::File> object representing C<$file> as a
relative path. An optional argument, given as either a string or a
C<Path::Class::Dir> object, specifies the directory to use as the base
of relativity - otherwise the current working directory will be used.
=item $foreign = $file->as_foreign($type)
Returns a C<Path::Class::File> object representing C<$file> as it would
be specified on a system of type C<$type>. Known types include
C<Unix>, C<Win32>, C<Mac>, C<VMS>, and C<OS2>, i.e. anything for which
there is a subclass of C<File::Spec>.
Any generated objects (subdirectories, files, parents, etc.) will also
retain this type.
=item $foreign = Path::Class::File->new_foreign($type, @args)
Returns a C<Path::Class::File> object representing a file as it would
be specified on a system of type C<$type>. Known types include
C<Unix>, C<Win32>, C<Mac>, C<VMS>, and C<OS2>, i.e. anything for which
there is a subclass of C<File::Spec>.
The arguments in C<@args> are the same as they would be specified in
C<new()>.
=item $fh = $file->open($mode, $permissions)
Passes the given arguments, including C<$file>, to C<< IO::File->new >>
(which in turn calls C<< IO::File->open >> and returns the result
as an C<IO::File> object. If the opening
fails, C<undef> is returned and C<$!> is set.
=item $fh = $file->openr()
A shortcut for
$fh = $file->open('r') or die "Can't read $file: $!";
=item $fh = $file->openw()
A shortcut for
$fh = $file->open('w') or die "Can't write $file: $!";
=item $file->touch
Sets the modification and access time of the given file to right now,
if the file exists. If it doesn't exist, C<touch()> will I<make> it
exist, and - YES! - set its modification and access time to now.
=item $file->slurp()
In a scalar context, returns the contents of C<$file> in a string. In
a list context, returns the lines of C<$file> (according to how C<$/>
is set) as a list. If the file can't be read, this method will throw
an exception.
If you want C<chomp()> run on each line of the file, pass a true value
for the C<chomp> or C<chomped> parameters:
my @lines = $file->slurp(chomp => 1);
=item $file->remove()
This method will remove the file in a way that works well on all
platforms, and returns a boolean value indicating whether or not the
file was successfully removed.
C<remove()> is better than simply calling Perl's C<unlink()> function,
because on some platforms (notably VMS) you actually may need to call
C<unlink()> several times before all versions of the file are gone -
the C<remove()> method handles this process for you.
=item $st = $file->stat()
Invokes C<< File::stat::stat() >> on this file and returns a
C<File::stat> object representing the result.
=item $st = $file->lstat()
Same as C<stat()>, but if C<$file> is a symbolic link, C<lstat()>
stats the link instead of the file the link points to.
=back
=head1 AUTHOR
Ken Williams, ken@mathforum.org
=head1 SEE ALSO
Path::Class, Path::Class::Dir, File::Spec
=cut
/VimColor.pm/1.1/Fri Apr 28 07:16:26 2006//
D/VimColor////
xsieve/experiments/programlisting/vimcolor/lib/Text
:pserver:anonymous@xsieve.cvs.sourceforge.net:/cvsroot/xsieve
/light.css/1.1/Fri Apr 28 07:16:26 2006//
/light.xsl/1.1/Fri Apr 28 07:16:26 2006//
/mark.vim/1.1/Fri Apr 28 07:16:26 2006//
D
xsieve/experiments/programlisting/vimcolor/lib/Text/VimColor
:pserver:anonymous@xsieve.cvs.sourceforge.net:/cvsroot/xsieve
/*
* A stylesheet designed to be used with the HTML output of the
* Perl module Text::Highlight::Vim.
*
* This is designed to make the highlighting look like the default gvim
* colour scheme, with 'background=light'.
*
* Geoff Richards (qef@laxan.com)
*
* This CSS file (light.css) is public domain. Do what you want with it.
* That doesn't mean that HTML with this CSS in is public domain.
*/
body { color: black; background: white none }
A:link { color: #00F; background: white none }
A:visited { color: #909; background: white none }
A:hover { color: #F00; background: white none }
A:active { color: #F00; background: white none }
.synComment { color: #0000FF }
.synConstant { color: #FF00FF }
.synIdentifier { color: #008B8B }
.synStatement { color: #A52A2A ; font-weight: bold }
.synPreProc { color: #A020F0 }
.synType { color: #2E8B57 ; font-weight: bold }
.synSpecial { color: #6A5ACD }
.synUnderlined { color: #000000 ; text-decoration: underline }
.synError { color: #FFFFFF ; background: #FF0000 none }
.synTodo { color: #0000FF ; background: #FFFF00 none }
<?xml version="1.0"?>
<!--
This is an XSLT/XSL-FO stylesheet designed to be used with the XML
output of the Perl module Text::VimColor.
This is designed to make the highlighting look like the default gvim
colour scheme, with 'background=light'.
Geoff Richards <qef@laxan.com>
This XSL file (light.xsl) is public domain. Do what you want with it.
Bugs: background colouring doesn't work in FOP.
-->
<xsl:stylesheet version="1.0"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:syn="http://ns.laxan.com/text-vimcolor/1">
<xsl:template match="syn:syntax">
<fo:root>
<fo:layout-master-set>
<!-- Master for odd (right hand) pages -->
<fo:simple-page-master master-name="recto"
page-height="297mm" page-width="210mm"
margin-top="10mm" margin-left="25mm"
margin-bottom="10mm" margin-right="15mm">
<fo:region-body margin-top="10mm" margin-bottom="10mm"/>
<fo:region-before extent="10mm"/>
<fo:region-after extent="10mm"/>
</fo:simple-page-master>
<!-- Master for even (left hand) pages -->
<fo:simple-page-master master-name="verso"
page-height="297mm" page-width="210mm"
margin-top="10mm" margin-left="15mm"
margin-bottom="10mm" margin-right="25mm">
<fo:region-body margin-top="10mm" margin-bottom="10mm"/>
<fo:region-before extent="10mm"/>
<fo:region-after extent="10mm"/>
</fo:simple-page-master>
<fo:page-sequence-master master-name="recto-verso">
<fo:repeatable-page-master-alternatives>
<fo:conditional-page-master-reference
master-name="recto" odd-or-even="odd"/>
<fo:conditional-page-master-reference
master-name="verso" odd-or-even="even"/>
</fo:repeatable-page-master-alternatives>
</fo:page-sequence-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="recto">
<!-- Header -->
<fo:static-content flow-name="xsl-region-before">
<fo:block text-align="end" font-size="10pt"
font-family="sans-serif" font-style="italic">
<xsl:value-of select="@filename"/>
</fo:block>
</fo:static-content>
<!-- Footer -->
<fo:static-content flow-name="xsl-region-after">
<fo:block text-align="end" font-size="10pt" font-family="sans-serif">
<fo:page-number/>
</fo:block>
</fo:static-content>
<!-- Body text -->
<fo:flow flow-name="xsl-region-body">
<fo:block font-family="monospace" font-size="10pt" line-height="12pt"
white-space-collapse="false">
<xsl:apply-templates/>
</fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>
</xsl:template>
<xsl:template match="syn:Comment">
<fo:inline color="#0000FF"><xsl:apply-templates/></fo:inline>
</xsl:template>
<xsl:template match="syn:Constant">
<fo:inline color="#FF00FF"><xsl:apply-templates/></fo:inline>
</xsl:template>
<xsl:template match="syn:Identifier">
<fo:inline color="#008B8B"><xsl:apply-templates/></fo:inline>
</xsl:template>
<xsl:template match="syn:Statement">
<fo:inline color="#A52A2A" font-weight="bold"><xsl:apply-templates/></fo:inline>
</xsl:template>
<xsl:template match="syn:PreProc">
<fo:inline color="#A020F0"><xsl:apply-templates/></fo:inline>
</xsl:template>
<xsl:template match="syn:Type">
<fo:inline color="#2E8B57" font-weight="bold"><xsl:apply-templates/></fo:inline>
</xsl:template>
<xsl:template match="syn:Special">
<fo:inline color="#6A5ACD"><xsl:apply-templates/></fo:inline>
</xsl:template>
<xsl:template match="syn:Underlined">
<fo:inline text-decoration="underline"><xsl:apply-templates/></fo:inline>
</xsl:template>
<xsl:template match="syn:Error">
<fo:inline color="#FFFFFF" background-color="#FF0000"><xsl:apply-templates/></fo:inline>
</xsl:template>
<xsl:template match="syn:Todo">
<fo:inline color="#0000FF" background-color="#FFFF00"><xsl:apply-templates/></fo:inline>
</xsl:template>
</xsl:stylesheet>
" mark.vim - turn Vim syntax highlighting into an ad-hoc markup language that
" can be parsed by the Text::VimColor Perl module.
"
" Maintainer: Geoff Richards <qef@laxan.com>
" Based loosely on 2html.vim, by Bram Moolenaar <Bram@vim.org>,
" modified by David Ne\v{c}as (Yeti) <yeti@physics.muni.cz>.
set report=1000000
" For some reason (I'm sure it used to work) we now need to get Vim
" to make another attempt to detect the filetype if it wasn't set
" explicitly.
if !strlen(&filetype)
filetype detect
endif
syn on
" Set up the output buffer.
new
set modifiable
set paste
" Expand tabs. Without this they come out as '^I'.
set isprint+=9
wincmd p
" Loop over all lines in the original text
let s:end = line("$")
let s:lnum = 1
while s:lnum <= s:end
" Get the current line
let s:line = getline(s:lnum)
let s:len = strlen(s:line)
let s:new = ""
" Loop over each character in the line
let s:col = 1
while s:col <= s:len
let s:startcol = s:col " The start column for processing text
let s:id = synID(s:lnum, s:col, 1)
let s:col = s:col + 1
" Speed loop (it's small - that's the trick)
" Go along till we find a change in synID
while s:col <= s:len && s:id == synID(s:lnum, s:col, 1) | let s:col = s:col + 1 | endwhile
" Output the text with the same synID, with class set to c{s:id}
let s:id = synIDtrans(s:id)
let s:name = synIDattr(s:id, 'name')
let s:new = s:new . '>' . s:name . '>' . substitute(substitute(substitute(strpart(s:line, s:startcol - 1, s:col - s:startcol), '&', '\&a', 'g'), '<', '\&l', 'g'), '>', '\&g', 'g') . '<' . s:name . '<'
if s:col > s:len
break
endif
endwhile
exe "normal \<C-W>pa" . strtrans(s:new) . "\n\e\<C-W>p"
let s:lnum = s:lnum + 1
+
endwhile
" Strip whitespace from the ends of lines
%s:\s\+$::e
wincmd p
normal dd
This diff is collapsed.
#!/bin/sh
DIR=`dirname $0`
PERL5LIB=$DIR/lib:$PERL5LIB
export PERL5LIB
$DIR/text-vimcolor "$@"
L'installation de Doctrine est très simple. Il suffit de récupérer la dernière version de Doctrine sur http://doctrine.pengus.net/svn/trunk.
Pour ce faire, vous avez besoin d'un client Subversion (SVN).
Pour "emprunter" (checkout) Doctrine dans répertoire courant en utiliser l'outil de lignes de commande **svn**, utilisez le code suivant:
<code type="bash">
svn co http://doctrine.pengus.net/svn/trunk .
</code>
Si vous n'avez pas de client SVN, choisissez-en un dans la liste ci-dessous.
Trouver l'option **Checkout** et entrez http://doctrine.pengus.net/svn/trunk dans le champ **path** ou **repository url**.
Aucune authentification n'est requise pour récupérer Doctrine.
* [http://tortoisesvn.tigris.org/ TortoiseSVN] une application Windows qui s'intègre directement dans l'exporateur de fichier.
* [http://www.apple.com/downloads/macosx/development_tools/svnx.html svnx] une interface graphique SVN pour Mac
* Eclipse possède une intégration SVN grâce au plugin [http://subclipse.tigris.org/ subeclipse]
Caching is one of the most influental things when it comes to performance tuning. Doctrine_Cache provides means for
caching queries and for managing the cached queries.
Doctrine_Db_Profiler is an eventlistener for Doctrine_Db. It provides flexible query profiling. Besides the sql strings
the query profiles include elapsed time to run the queries. This allows inspection of the queries that have been performed without the
need for adding extra debugging code to model classes.
Doctrine_Db_Profiler can be enabled by adding it as an eventlistener for Doctrine_Db.
<code type="php">
?></code>
<code type="php">
$table = $conn->getTable("User");
$table->setEventListener(new MyListener2());
// retrieve user whose primary key is 2
$user = $table->find(2);
$user->name = "John Locke";
// update event will be listened and current time will be assigned to the field 'updated'
$user->save();
</code>
Many web applications have different kinds of lists. The lists may contain data from multiple components (= database tables) and
they may have actions such as paging, sorting and setting conditions. Doctrine_Hook helps building these lists. It has a simple API for
building search criteria forms as well as building a DQL query from the 'hooked' parameters.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment