1
0
mirror of synced 2025-01-18 22:41:43 +03:00

added xsl stylesheet to generate changelogs from svn log. merged a few patches from 0.10

This commit is contained in:
romanb 2008-03-19 18:33:14 +00:00
parent 82efe45c00
commit 223daae2ec
16 changed files with 532 additions and 51 deletions

View File

@ -193,7 +193,7 @@ final class Doctrine
const ATTR_EMULATE_DATABASE = 116; // manager/session attribute
const ATTR_USE_NATIVE_ENUM = 117; // manager/session attribute
const ATTR_DEFAULT_SEQUENCE = 133; // ??
const ATTR_FETCHMODE = 118; // deprecated
const ATTR_FETCHMODE = 118; // deprecated? might use them again for associations
const ATTR_NAME_PREFIX = 121; // ??
const ATTR_CREATE_TABLES = 122; // manager/session attribute
const ATTR_COLL_LIMIT = 123; // manager/session attribute
@ -208,7 +208,6 @@ final class Doctrine
const ATTR_QUERY_CACHE = 157; // manager/session attribute
const ATTR_QUERY_CACHE_LIFESPAN = 158; // manager/session attribute
const ATTR_MODEL_LOADING = 161; // manager/session attribute
const ATTR_LOCK = 162; // ??
const ATTR_HYDRATE = 163; // ??
const ATTR_IDENTIFIER = 164; // ??
const ATTR_METADATA_CACHE = 165; // manager/session attribute

View File

@ -33,7 +33,7 @@
* @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/
abstract class Doctrine_Access extends Doctrine_Locator_Injectable implements ArrayAccess
abstract class Doctrine_Access implements ArrayAccess
{
/**
* setArray

View File

@ -31,7 +31,7 @@
* @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/
abstract class Doctrine_Configurable extends Doctrine_Locator_Injectable
abstract class Doctrine_Configurable
{
/**
* @var array $attributes an array of containing all attributes

View File

@ -84,6 +84,17 @@ class Doctrine_Connection_Mssql extends Doctrine_Connection
if ($checkOption && ! $this->getAttribute(Doctrine::ATTR_QUOTE_IDENTIFIER)) {
return $identifier;
}
if (strpos($identifier, '.') !== false) {
$parts = explode('.', $identifier);
$quotedParts = array();
foreach ($parts as $p) {
$quotedParts[] = $this->quoteIdentifier($p);
}
return implode('.', $quotedParts);
}
return '[' . str_replace(']', ']]', $identifier) . ']';
}

View File

@ -254,7 +254,7 @@ class Doctrine_Hydrator extends Doctrine_Hydrator_Abstract
*/
protected function _setLastElement(&$prev, &$coll, $index, $dqlAlias, $oneToOne)
{
if ($coll === self::$_null) {
if ($coll === $this->_nullObject) {
return false;
}

View File

@ -30,7 +30,7 @@
* @version $Revision: 3192 $
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/
abstract class Doctrine_Hydrator_Abstract extends Doctrine_Locator_Injectable
abstract class Doctrine_Hydrator_Abstract
{
/**
* @var array $_aliasMap two dimensional array containing the map for query aliases
@ -53,13 +53,18 @@ abstract class Doctrine_Hydrator_Abstract extends Doctrine_Locator_Injectable
* The current hydration mode.
*/
protected $_hydrationMode = Doctrine::HYDRATE_RECORD;
protected $_nullObject;
/**
* constructor
*
* @param Doctrine_Connection|null $connection
*/
public function __construct() {}
public function __construct()
{
$this->_nullObject = Doctrine_Null::$INSTANCE;
}
/**
* Sets the fetchmode.

View File

@ -32,10 +32,16 @@
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @author Roman Borschel <roman@code-factory.org>
*/
class Doctrine_Hydrator_RecordDriver extends Doctrine_Locator_Injectable
class Doctrine_Hydrator_RecordDriver
{
protected $_collections = array();
protected $_mappers = array();
private $_nullObject;
public function __construct()
{
$this->_nullObject = Doctrine_Null::$INSTANCE;
}
public function getElementCollection($component)
{
@ -98,7 +104,7 @@ class Doctrine_Hydrator_RecordDriver extends Doctrine_Locator_Injectable
public function getNullPointer()
{
return self::$_null;
return $this->_nullObject;
}
public function getElement(array $data, $className)

View File

@ -77,7 +77,6 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera
private function __construct()
{
$this->_root = dirname(__FILE__);
Doctrine_Locator_Injectable::initNullObject(new Doctrine_Null);
}
/**
@ -543,7 +542,7 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera
}
/**
* Creates a new native query (instance of Doctrine_RawSql).
* Creates a new native (SQL) query.
*
* @return Doctrine_RawSql
*/

View File

@ -86,7 +86,7 @@ class Doctrine_Mapper
$this->_domainClassName = $name;
$this->_conn = $classMetadata->getConnection();
$this->_classMetadata = $classMetadata;
$this->_nullObject = Doctrine_Null::getInstance();
$this->_nullObject = Doctrine_Null::$INSTANCE;
if ($classMetadata->getInheritanceType() == Doctrine::INHERITANCETYPE_JOINED) {
$this->_mappingStrategy = new Doctrine_Mapper_JoinedStrategy($this);
} else {

View File

@ -33,17 +33,16 @@
* @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/
// static initializer
Doctrine_Null::$INSTANCE = new Doctrine_Null();
final class Doctrine_Null
{
private static $_instance;
public static $INSTANCE;
public function __construct() {}
public static function getInstance()
{
if (is_null(self::$_instance)) {
self::$_instance = new Doctrine_Null();
}
return self::$_instance;
return self::$INSTANCE;
}
public function exists()

View File

@ -208,7 +208,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
{
if (isset($mapper) && $mapper instanceof Doctrine_Mapper) {
$class = get_class($this);
$this->_mapper = Doctrine_Manager::getInstance()->getMapper($class);
$this->_mapper = $mapper;
$this->_class = $this->_mapper->getClassMetadata();
$exists = ! $isNewEntry;
} else {
@ -262,16 +262,6 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
{
return self::$_index;
}
/**
* setUp
* this method is used for setting up relations and attributes
* it should be implemented by child classes
*
* @return void
*/
/*public function setUp()
{ }*/
/**
* construct
@ -485,7 +475,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
continue;
}
if ($value === self::$_null || $overwrite) {
if ($value === Doctrine_Null::$INSTANCE || $overwrite) {
$this->_data[$column] = $default;
$this->_modified[] = $column;
$this->_state = Doctrine_Record::STATE_TDIRTY;
@ -513,9 +503,9 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
if (isset($tmp[$fieldName])) {
$data[$fieldName] = $tmp[$fieldName];
} else if (array_key_exists($fieldName, $tmp)) {
$data[$fieldName] = self::$_null;
$data[$fieldName] = Doctrine_Null::$INSTANCE;
} else if (!isset($this->_data[$fieldName])) {
$data[$fieldName] = self::$_null;
$data[$fieldName] = Doctrine_Null::$INSTANCE;
}
unset($tmp[$fieldName]);
}
@ -554,7 +544,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
$name = (array)$this->_class->getIdentifier();
$name = $name[0];
if ($exists) {
if (isset($this->_data[$name]) && $this->_data[$name] !== self::$_null) {
if (isset($this->_data[$name]) && $this->_data[$name] !== Doctrine_Null::$INSTANCE) {
$this->_id[$name] = $this->_data[$name];
}
}
@ -563,7 +553,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
$names = (array)$this->_class->getIdentifier();
foreach ($names as $name) {
if ($this->_data[$name] === self::$_null) {
if ($this->_data[$name] === Doctrine_Null::$INSTANCE) {
$this->_id[$name] = null;
} else {
$this->_id[$name] = $this->_data[$name];
@ -600,7 +590,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
foreach ($this->_data as $k => $v) {
if ($v instanceof Doctrine_Record && $this->_class->getTypeOf($k) != 'object') {
unset($vars['_data'][$k]);
} else if ($v === self::$_null) {
} else if ($v === Doctrine_Null::$INSTANCE) {
unset($vars['_data'][$k]);
} else {
switch ($this->_class->getTypeOf($k)) {
@ -838,7 +828,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
if ( ! isset($this->_data[$fieldName])) {
throw new Doctrine_Record_Exception('Unknown property '. $fieldName);
}
if ($this->_data[$fieldName] === self::$_null) {
if ($this->_data[$fieldName] === Doctrine_Null::$INSTANCE) {
return null;
}
@ -895,15 +885,16 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
}*/
// Use built-in accessor functionality
$value = self::$_null;
$nullObj = Doctrine_Null::$INSTANCE;
$value = $nullObj;
if (isset($this->_data[$fieldName])) {
if ($this->_data[$fieldName] !== self::$_null) {
if ($this->_data[$fieldName] !== $nullObj) {
return $this->_data[$fieldName];
}
if ($this->_data[$fieldName] === self::$_null && $load) {
if ($this->_data[$fieldName] === $nullObj && $load) {
$this->load();
}
if ($this->_data[$fieldName] === self::$_null) {
if ($this->_data[$fieldName] === $nullObj) {
$value = null;
}
return $value;
@ -982,7 +973,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
if ($old !== $value) {
if ($value === null) {
$value = self::$_null;
$value = Doctrine_Null::$INSTANCE;
}
$this->_data[$fieldName] = $value;
@ -1032,7 +1023,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
return $this;
}
} else {
if ($value !== self::$_null) {
if ($value !== Doctrine_Null::$INSTANCE) {
$relatedTable = $value->getTable();
$foreignFieldName = $rel->getForeignFieldName();
$localFieldName = $rel->getLocalFieldName();
@ -1083,7 +1074,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
return true;
}
if (isset($this->_references[$fieldName]) &&
$this->_references[$fieldName] !== self::$_null) {
$this->_references[$fieldName] !== Doctrine_Null::$INSTANCE) {
return true;
}
return false;
@ -1100,7 +1091,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
} else if (isset($this->_references[$fieldName])) {
if ($this->_references[$fieldName] instanceof Doctrine_Record) {
// todo: delete related record when saving $this
$this->_references[$fieldName] = self::$_null;
$this->_references[$fieldName] = Doctrine_Null::$INSTANCE;
} else if ($this->_references[$fieldName] instanceof Doctrine_Collection) {
$this->_references[$fieldName]->setData(array());
}
@ -1211,7 +1202,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
foreach ($modifiedFields as $field) {
$type = $this->_class->getTypeOf($field);
if ($this->_data[$field] === self::$_null) {
if ($this->_data[$field] === Doctrine_Null::$INSTANCE) {
$dataSet[$field] = null;
continue;
}
@ -1286,7 +1277,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
$a = array();
foreach ($this as $column => $value) {
if ($value === self::$_null || is_object($value)) {
if ($value === Doctrine_Null::$INSTANCE || is_object($value)) {
$value = null;
}
$a[$column] = $value;

View File

@ -138,7 +138,7 @@ class Doctrine_Sequence_Mssql extends Doctrine_Sequence
$query = 'SELECT @@IDENTITY';
}
return $this->conn->fetchOne($query);
return (string) floor((float) $this->conn->fetchOne($query));
}
/**

View File

@ -29,14 +29,15 @@
* @link www.phpdoctrine.org
* @since 1.0
* @version $Revision$
* @author Roman Borschel <roman@code-factory.org>
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/
class Doctrine_Validator extends Doctrine_Locator_Injectable
class Doctrine_Validator
{
/**
* @var array $validators an array of validator objects
*/
private static $validators = array();
private static $validators = array();
/**
* returns a validator object
@ -50,6 +51,8 @@ class Doctrine_Validator extends Doctrine_Locator_Injectable
$class = 'Doctrine_Validator_' . ucwords(strtolower($name));
if (class_exists($class)) {
self::$validators[$name] = new $class;
} else if (class_exists($name)) {
self::$validators[$name] = new $name;
} else {
throw new Doctrine_Exception("Validator named '$name' not available.");
}
@ -78,7 +81,7 @@ class Doctrine_Validator extends Doctrine_Locator_Injectable
$fields = ($record->exists()) ? $record->getModified() : $record->getData();
$err = array();
foreach ($fields as $fieldName => $value) {
if ($value === self::$_null) {
if ($value === Doctrine_Null::$INSTANCE) {
$value = null;
} else if ($value instanceof Doctrine_Record) {
$value = $value->getIncremented();

463
svn2cl.xsl Normal file
View File

@ -0,0 +1,463 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
svn2cl.xsl - xslt stylesheet for converting svn log to a normal
changelog
version 0.9
Usage (replace ++ with two minus signs which aren't allowed
inside xml comments):
svn ++verbose ++xml log | \
xsltproc ++stringparam strip-prefix `basename $(pwd)` \
++stringparam linelen 75 \
++stringparam groupbyday yes \
++stringparam separate-daylogs yes \
++stringparam include-rev yes \
++stringparam breakbeforemsg yes/2 \
++stringparam reparagraph yes \
++stringparam authorsfile FILE \
++stringparam ignore-message-starting \
svn2cl.xsl - > ChangeLog
This file is based on several implementations of this conversion
that I was not completely happy with and some other common
xslt constructs found on the web.
Copyright (C) 2004, 2005, 2006, 2007 Arthur de Jong.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
3. The name of the author may not be used to endorse or promote
products derived from this software without specific prior
written permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-->
<!DOCTYPE xsl:stylesheet [
<!ENTITY tab "&#9;">
<!ENTITY newl "&#10;">
<!ENTITY space "&#32;">
]>
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output
method="text"
encoding="utf-8"
media-type="text/plain"
omit-xml-declaration="yes"
standalone="yes"
indent="no" />
<xsl:strip-space elements="*" />
<!-- the prefix of pathnames to strip -->
<xsl:param name="strip-prefix" select="'/'" />
<!-- the length of a line to wrap messages at -->
<xsl:param name="linelen" select="75" />
<!-- whether entries should be grouped by day -->
<xsl:param name="groupbyday" select="'no'" />
<!-- whether to seperate log messages by empty lines -->
<xsl:param name="separate-daylogs" select="'no'" />
<!-- whether a revision number should be included -->
<xsl:param name="include-rev" select="'no'" />
<!-- whether the log message should start on a new line -->
<xsl:param name="breakbeforemsg" select="'no'" />
<!-- whether the message should be rewrapped within one paragraph -->
<xsl:param name="reparagraph" select="'no'" />
<!-- whether certain messages should be ignored -->
<xsl:param name="ignore-message-starting" select="''" />
<!-- location of authors file if any -->
<xsl:param name="authorsfile" select="''" />
<xsl:key name="author-lookup" match="author" use="@uid" />
<xsl:variable name="authors-top" select="document($authorsfile)/authors" />
<!-- match the topmost log entry -->
<xsl:template match="log">
<xsl:choose>
<xsl:when test="$ignore-message-starting != ''">
<!-- only handle logentries with don't contain the string -->
<xsl:apply-templates select="logentry[not(starts-with(msg,$ignore-message-starting))]" />
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="logentry" />
</xsl:otherwise>
</xsl:choose>
<!-- add newlines at the end of the changelog -->
<xsl:text>&newl;</xsl:text>
</xsl:template>
<!-- format one entry from the log -->
<xsl:template match="logentry">
<xsl:choose>
<!-- if we're grouping we should omit some headers -->
<xsl:when test="$groupbyday='yes'">
<!-- save log entry number -->
<xsl:variable name="pos" select="position()" />
<!-- fetch previous entry's date -->
<xsl:variable name="prevdate">
<xsl:apply-templates select="../logentry[position()=(($pos)-1)]/date" />
</xsl:variable>
<!-- fetch previous entry's author -->
<xsl:variable name="prevauthor">
<xsl:value-of select="normalize-space(../logentry[position()=(($pos)-1)]/author)" />
</xsl:variable>
<!-- fetch this entry's date -->
<xsl:variable name="date">
<xsl:apply-templates select="date" />
</xsl:variable>
<!-- fetch this entry's author -->
<xsl:variable name="author">
<xsl:value-of select="normalize-space(author)" />
</xsl:variable>
<!-- check if header is changed -->
<xsl:if test="($prevdate!=$date) or ($prevauthor!=$author)">
<!-- add newline -->
<xsl:if test="not(position()=1)">
<xsl:text>&newl;</xsl:text>
</xsl:if>
<!-- date -->
<xsl:value-of select="$date" />
<!-- two spaces -->
<xsl:text>&space;&space;</xsl:text>
<!-- author's name -->
<xsl:apply-templates select="author" />
<!-- two newlines -->
<xsl:text>&newl;</xsl:text>
<xsl:if test="$separate-daylogs!='yes'"><xsl:text>&newl;</xsl:text></xsl:if>
</xsl:if>
</xsl:when>
<!-- write the log header -->
<xsl:otherwise>
<!-- add newline -->
<xsl:if test="not(position()=1)">
<xsl:text>&newl;</xsl:text>
</xsl:if>
<!-- date -->
<xsl:apply-templates select="date" />
<!-- two spaces -->
<xsl:text>&space;&space;</xsl:text>
<!-- author's name -->
<xsl:apply-templates select="author" />
<!-- two newlines -->
<xsl:text>&newl;&newl;</xsl:text>
</xsl:otherwise>
</xsl:choose>
<!-- get paths string -->
<xsl:variable name="paths">
<xsl:apply-templates select="paths" />
<xsl:text>:&space;</xsl:text>
</xsl:variable>
<!-- get revision number -->
<xsl:variable name="rev">
<xsl:if test="$include-rev='yes'">
<xsl:text>[r</xsl:text>
<xsl:value-of select="@revision" />
<xsl:text>]&space;</xsl:text>
</xsl:if>
</xsl:variable>
<!-- trim trailing newlines -->
<xsl:variable name="msg">
<!-- add a line break before the log message -->
<xsl:choose>
<xsl:when test="$breakbeforemsg='yes'">
<xsl:text>&newl;</xsl:text>
</xsl:when>
<xsl:when test="number($breakbeforemsg)&gt;0">
<xsl:call-template name="newlines">
<xsl:with-param name="count" select="number($breakbeforemsg)" />
</xsl:call-template>
</xsl:when>
</xsl:choose>
<xsl:call-template name="trim-newln">
<xsl:with-param name="txt" select="msg" />
</xsl:call-template>
</xsl:variable>
<!-- add newline here if separate-daylogs is in effect -->
<xsl:if test="$groupbyday='yes' and $separate-daylogs='yes'"><xsl:text>&newl;</xsl:text></xsl:if>
<!-- first line is indented (other indents are done in wrap template) -->
<xsl:text>&tab;*&space;</xsl:text>
<!-- print the paths and message nicely wrapped -->
<xsl:call-template name="wrap">
<xsl:with-param name="txt" select="concat($rev,$msg)" />
</xsl:call-template>
</xsl:template>
<!-- format date -->
<xsl:template match="date">
<xsl:variable name="date" select="normalize-space(.)" />
<!-- output date part -->
<xsl:value-of select="substring($date,1,10)" />
<!-- output time part -->
<xsl:if test="$groupbyday!='yes'">
<xsl:text>&space;</xsl:text>
<xsl:value-of select="substring($date,12,5)" />
</xsl:if>
</xsl:template>
<!-- format author -->
<xsl:template match="author">
<xsl:variable name="uid" select="normalize-space(.)" />
<!-- try to lookup author in authorsfile -->
<xsl:choose>
<xsl:when test="$authorsfile!=''">
<xsl:for-each select="$authors-top">
<xsl:variable name="author" select="key('author-lookup',$uid)" />
<!-- present result -->
<xsl:choose>
<xsl:when test="string($author/.)">
<xsl:apply-templates select="$author/node()" mode="copy" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$uid" />
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$uid" />
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- copy but normalize text -->
<xsl:template match="text()" mode="copy">
<xsl:value-of select="normalize-space(.)" />
</xsl:template>
<!-- simple copy template -->
<xsl:template match="@*|node()" mode="copy">
<xsl:copy>
<xsl:apply-templates select="@*|node()" mode="copy" />
</xsl:copy>
</xsl:template>
<!-- present a list of paths names -->
<xsl:template match="paths">
<xsl:choose>
<!-- only handle paths that begin with the path and strip the path -->
<xsl:when test="$strip-prefix != ''">
<!-- if strip-prefix does not start with a slash, prepend it -->
<xsl:variable name="tmpstrip1">
<xsl:choose>
<xsl:when test="starts-with($strip-prefix,'/')">
<xsl:value-of select="$strip-prefix" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="concat('/',$strip-prefix)" />
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!-- strip trailing slash from strip-prefix -->
<xsl:variable name="tmpstrip2">
<xsl:choose>
<xsl:when test="substring($tmpstrip1,string-length($tmpstrip1),1)='/'">
<xsl:value-of select="substring($tmpstrip1,1,string-length($tmpstrip1)-1)" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$tmpstrip1" />
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!-- filter on all entries within directory -->
<xsl:for-each select="path[starts-with(concat(normalize-space(.),'/'),concat($tmpstrip2,'/'))]">
<xsl:sort select="normalize-space(.)" data-type="text" />
<!-- unless we are the first entry, add a comma -->
<xsl:if test="not(position()=1)">
<xsl:text>,&space;</xsl:text>
</xsl:if>
<!-- print the path name -->
<xsl:call-template name="printpath">
<xsl:with-param name="path" select="substring(normalize-space(.),string-length($strip-prefix)+3)" />
</xsl:call-template>
</xsl:for-each>
</xsl:when>
<!-- print a simple list of all paths -->
<xsl:otherwise>
<xsl:for-each select="path">
<xsl:sort select="normalize-space(.)" data-type="text" />
<!-- unless we are the first entry, add a comma -->
<xsl:if test="not(position()=1)">
<xsl:text>,&space;</xsl:text>
</xsl:if>
<!-- print the path name -->
<xsl:value-of select="normalize-space(.)" />
</xsl:for-each>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- transform path to something printable -->
<xsl:template name="printpath">
<!-- fetch the pathname -->
<xsl:param name="path" />
<!-- strip leading slash -->
<xsl:variable name="tmp1">
<xsl:choose>
<xsl:when test="starts-with($path,'/')">
<xsl:value-of select="substring($path,2)" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$path" />
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!-- translate empty string to dot -->
<xsl:choose>
<xsl:when test="$tmp1 = ''">
<xsl:text>.</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$tmp1" />
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- string-wrapping template -->
<xsl:template name="wrap">
<xsl:param name="txt" />
<xsl:variable name="normtxt" select="normalize-space($txt)" />
<xsl:choose>
<xsl:when test="contains($txt,'&newl;')">
<!-- text contains newlines, do the first line -->
<xsl:call-template name="wrap">
<xsl:with-param name="txt" select="substring-before($txt,'&newl;')" />
</xsl:call-template>
<!-- print tab -->
<xsl:text>&tab;&space;&space;</xsl:text>
<!-- wrap the rest of the text -->
<xsl:call-template name="wrap">
<xsl:with-param name="txt" select="substring-after($txt,'&newl;')" />
</xsl:call-template>
</xsl:when>
<xsl:when test="(string-length($normtxt) &lt; (($linelen)-9)) or not(contains($normtxt,' '))">
<!-- this is easy, nothing to do -->
<xsl:value-of select="$normtxt" />
<!-- add newline -->
<xsl:text>&newl;</xsl:text>
</xsl:when>
<xsl:otherwise>
<!-- find the first line -->
<xsl:variable name="tmp" select="substring($normtxt,1,(($linelen)-9))" />
<xsl:variable name="line">
<xsl:choose>
<!-- if our attempt contains spaces wrap on that -->
<xsl:when test="contains($tmp,' ')">
<xsl:call-template name="find-line">
<xsl:with-param name="txt" select="$tmp" />
</xsl:call-template>
</xsl:when>
<!-- otherwise use the first non-space characters from the text -->
<xsl:otherwise>
<xsl:value-of select="substring-before($normtxt,' ')" />
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!-- print line -->
<xsl:value-of select="$line" />
<!-- print newline and tab -->
<xsl:text>&newl;&tab;&space;&space;</xsl:text>
<!-- wrap the rest of the text -->
<xsl:call-template name="wrap">
<xsl:with-param name="txt" select="normalize-space(substring($normtxt,string-length($line)+1))" />
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- template to trim line to contain space as last char -->
<xsl:template name="find-line">
<xsl:param name="txt" />
<xsl:choose>
<xsl:when test="substring($txt,string-length($txt),1)=' '">
<xsl:value-of select="substring($txt,1,string-length($txt)-1)" />
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="find-line">
<xsl:with-param name="txt" select="substring($txt,1,string-length($txt)-1)" />
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- template to trim trailing and starting newlines -->
<xsl:template name="trim-newln">
<xsl:param name="txt" />
<xsl:choose>
<!-- find starting newlines -->
<xsl:when test="substring($txt,1,1) = '&newl;'">
<xsl:call-template name="trim-newln">
<xsl:with-param name="txt" select="substring($txt,2)" />
</xsl:call-template>
</xsl:when>
<!-- find trailing newlines -->
<xsl:when test="substring($txt,string-length($txt),1) = '&newl;'">
<xsl:call-template name="trim-newln">
<xsl:with-param name="txt" select="substring($txt,1,string-length($txt)-1)" />
</xsl:call-template>
</xsl:when>
<!-- if the message has paragrapgs, find the first one -->
<xsl:when test="$reparagraph='yes' and contains($txt,'&newl;&newl;')">
<!-- remove newlines from first paragraph -->
<xsl:value-of select="normalize-space(substring-before($txt,'&newl;&newl;'))" />
<!-- paragraph separator -->
<xsl:text>&newl;&newl;</xsl:text>
<!-- do the rest of the text -->
<xsl:call-template name="trim-newln">
<xsl:with-param name="txt" select="substring-after($txt,'&newl;&newl;')" />
</xsl:call-template>
</xsl:when>
<!-- remove more single newlines -->
<xsl:when test="$reparagraph='yes'">
<xsl:value-of select="normalize-space($txt)" />
</xsl:when>
<!-- no newlines found, we're done -->
<xsl:otherwise>
<xsl:value-of select="$txt" />
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- insert a number of newlines -->
<xsl:template name="newlines">
<xsl:param name="count" />
<xsl:text>&newl;</xsl:text>
<xsl:if test="$count&gt;1">
<xsl:call-template name="newlines">
<xsl:with-param name="count" select="($count)-1" />
</xsl:call-template>
</xsl:if>
</xsl:template>
</xsl:stylesheet>

View File

@ -81,7 +81,7 @@ class Doctrine_Relation_OneToOne_TestCase extends Doctrine_UnitTestCase
$user->Email = $email;
$user->save();
$this->assertTrue($user->Email instanceOf Email);
$user->Email = Email::getNullObject();
$user->Email = Doctrine_Null::$INSTANCE;
$user->save();
$this->assertTrue($user->Email instanceOf Doctrine_Null);
}

View File

@ -303,6 +303,11 @@ $data->addTestCase(new Doctrine_Data_Import_TestCase());
$data->addTestCase(new Doctrine_Data_Export_TestCase());
$test->addTestCase($data);
$s = microtime(true);
$test->run();
$e = microtime(true);
echo memory_get_peak_usage() / 1024 . "\n";
echo 'test run took: ' . ($e - $s) . ' seconds<br />';
echo "peak memory usage: " . memory_get_peak_usage() / 1024 . "KB\n";