[Gnucash-changes] r13566 - gnucash/trunk - Optional XSL stylesheets
and support - prototypes
Neil Williams
codehelp at cvs.gnucash.org
Thu Mar 9 11:54:46 EST 2006
Author: codehelp
Date: 2006-03-09 11:54:44 -0500 (Thu, 09 Mar 2006)
New Revision: 13566
Trac: http://svn.gnucash.org/trac/changeset/13566
Added:
gnucash/trunk/src/optional/xsl/
gnucash/trunk/src/optional/xsl/Makefile.am
gnucash/trunk/src/optional/xsl/README
gnucash/trunk/src/optional/xsl/date-time.xsl
gnucash/trunk/src/optional/xsl/gnucash-gnccustomer-vcard2.xsl
gnucash/trunk/src/optional/xsl/gnucash-std.xsl
gnucash/trunk/src/optional/xsl/string.xsl
gnucash/trunk/src/optional/xsl/vcard-gnccustomer.pl
Modified:
gnucash/trunk/ChangeLog
gnucash/trunk/configure.in
gnucash/trunk/src/optional/Makefile.am
Log:
Optional XSL stylesheets and support - prototypes
Modified: gnucash/trunk/ChangeLog
===================================================================
--- gnucash/trunk/ChangeLog 2006-03-09 16:50:39 UTC (rev 13565)
+++ gnucash/trunk/ChangeLog 2006-03-09 16:54:44 UTC (rev 13566)
@@ -1,5 +1,22 @@
2006-03-09 Neil Williams <linux at codehelp.co.uk>
+ * src/optional/xsl : New directory for optional XSL
+ * src/optional/xsl/vcard-gnccustomer.pl : Perl script
+ to create QSF from VCards
+ * src/optional/xsl/gnucash-gnccustomer-vcard2.xsl :
+ XSL to generate vcards from QSF (gncCustomer)
+ * src/optional/xsl/gnucash-std.xsl : Common routines
+ for gnucash XSL stylesheets
+ * src/optional/xsl/Makefile.am : Don't build, just install.
+ * src/optional/xsl/string.xsl : xsltsl standard library XSL
+ in place until available as a package.
+ * src/optional/xsl/README : Notes on using XSL and examples.
+ * src/optional/xsl/date-time.xsl : xsltsl standard library.
+ * src/optional/Makefile.am : install only.
+ * configure.in : Add instruction to build a Makefile in
+ src/optional/xsl
+2006-03-09 Neil Williams <linux at codehelp.co.uk>
+
* src/business/business-core/gncInvoice.c : Enable
QOF_TYPE_COLLECT to allow recursive copying of gncEntry
within a gncInvoice for QSF export.
Modified: gnucash/trunk/configure.in
===================================================================
--- gnucash/trunk/configure.in 2006-03-09 16:50:39 UTC (rev 13565)
+++ gnucash/trunk/configure.in 2006-03-09 16:54:44 UTC (rev 13566)
@@ -2228,6 +2228,7 @@
src/optional/Makefile
src/optional/swig/Makefile
src/optional/swig/examples/Makefile
+ src/optional/xsl/Makefile
src/pixmaps/Makefile
src/quotes/Makefile
src/register/Makefile
Modified: gnucash/trunk/src/optional/Makefile.am
===================================================================
--- gnucash/trunk/src/optional/Makefile.am 2006-03-09 16:50:39 UTC (rev 13565)
+++ gnucash/trunk/src/optional/Makefile.am 2006-03-09 16:54:44 UTC (rev 13566)
@@ -6,4 +6,4 @@
# get this to work (automake 1.4p5).
SUBDIRS =
-DIST_SUBDIRS = swig
+DIST_SUBDIRS = swig xsl
Property changes on: gnucash/trunk/src/optional/xsl
___________________________________________________________________
Name: svn:ignore
+ Makefile.in
Makefile
Added: gnucash/trunk/src/optional/xsl/Makefile.am
===================================================================
--- gnucash/trunk/src/optional/xsl/Makefile.am 2006-03-09 16:50:39 UTC (rev 13565)
+++ gnucash/trunk/src/optional/xsl/Makefile.am 2006-03-09 16:54:44 UTC (rev 13566)
@@ -0,0 +1,13 @@
+xsldir = ${datadir}/xml/gnucash/xsl
+
+xsl_DATA = \
+ README \
+ date-time.xsl \
+ gnucash-std.xsl \
+ string.xsl \
+ gnucash-gnccustomer-vcard2.xsl \
+ vcard-gnccustomer.pl
+
+EXTRA_DIST = \
+ ${xsl_DATA}
+
Added: gnucash/trunk/src/optional/xsl/README
===================================================================
--- gnucash/trunk/src/optional/xsl/README 2006-03-09 16:50:39 UTC (rev 13565)
+++ gnucash/trunk/src/optional/xsl/README 2006-03-09 16:54:44 UTC (rev 13566)
@@ -0,0 +1,98 @@
+GnuCash, XSL and QSF.
+====================
+
+ If you need to convert gnucash QSF data into other formats, take a look at the example
+ stylesheets installed with gnucash. You are welcome to contribute new or amended
+ stylesheets - just post them on the QOF-devel mailing list.
+
+ http://lists.sourceforge.net/lists/listinfo/qof-devel
+
+ Depending on your package manager, the XSL stylesheets should be installed in
+ /usr/share/xml/gnucash/xsl/, or on Fink /sw/share/xml/gnucash/xsl/.
+
+ Current stylesheets are works in progress, but include:
+
+ · gnucash-gnccustomer-vcard2.xsl
+
+ This stylesheet converts QSF export gnucash customer data into a brief Vcard,
+ suitable for upload to Kaddressbook. Each VCard is written into a separate .vcf
+ file, named after the contact described in the pilot_address records. Spaces are
+ replaced with underscores. Specify the '-o dir/' option to xsltproc to output all
+ vcards into a directory.
+
+ · Others
+
+ Stylesheets for ICS, vcal and possibly LDAP are planned. Any plain text, XML or HTML
+ format can be generated, theoretically. If you have a request for an XSL stylesheet
+ or if you have a stylesheet you would like to make available to others, mention it
+ on the QOF-devel mailing list.
+
+ Also included is a perl script:
+
+ · vcard-gnccustomer.pl
+
+ The script uses the Text::vCard::Addressbook CPAN module to parse VCard files,
+ including those from other applications, into QSF XML that could be imported into
+ gnucash and merged into your gnucash customer list. With a few tweaks, this could
+ also be configured to create QSF XML suitable for gnucash vendor or employee records.
+
+ You are free to copy and modify these stylesheets to your own requirements, including
+ translations and customised formats. Depending on your package manager, this is often
+ best done by copying the installed file to a local directory before modifying it.
+ GnuCash does not reference these stylesheets directly. If your modifications could be
+ useful to others, please contribute them to gnucash via the QOF-devel mailing list or
+ gnucash-devel mailing list. Submitted stylesheets should be licenced under the GNU GPL.
+
+
+LOCALISATION (l10N) OF STYLESHEET OUTPUT.
+========================================
+
+ Later HTML stylesheets will support providing translatable strings and user-specific
+ encodings via external parameters. This can make the command line very long so is best
+ performed using a script. Each descriptive word in the output is configured as a string
+ parameter for the stylesheet and can be replaced with a translated version. HTML output
+ supports setting the HTML language (as would be specified in the <html> lang attribute)
+ and the encoding (as would be specified in the <meta> charset value in the content
+ attribute). If you use these stylesheets via a scripting language - like bash, PHP or
+ Perl - you could automate the translation by passing values obtained from a normal get-
+ text PO file. Copy the translatable strings into your script file as normal variables
+ then mark up those variables for translation by gettext. When the script is called, get-
+ text will assign the translated values to the variables and your script can simply echo
+ those values to the calls to the XSL parser routines.
+
+ It is important that the HTML language and the encoding match each other AND the
+ expected content of the HTML output generated from the gnucash QSF data.
+
+ When providing translated strings, the same constraints apply as if you were using get-
+ text and a normal PO file: the context and format of the translation should match the
+ intention expressed in the default value of the parameter. If the default is plural, the
+ translation should be plural. If the default is capitalised, the translation should be
+ capitalised - subject to grammatical rules for that language - even if the parameter
+ name itself is not capitalised.
+
+ Each stylesheet specifies the translatable strings in a block near the top of the file,
+ marked as for the attention of translators. Common settings, like the HTML language
+ parameter and the encoding support, are in the gnucash-std.xsl stylesheet and are
+ available in all HTML stylesheets by using the string parameters html_lang and encoding.
+
+ For more information, please ask on the gnucash-devel mailing list, the QOF-devel mailing
+ list or see the pilot-qof source: http://pilot-qof.sourceforge.net/
+
+EXAMPLES
+========
+
+ Convert a QSF XML file containing gncCustomer records, into individual VCard .vcf files
+ in the vcards/ directory - which must already exist. Files are named according to either
+ the company or name of the gncAddress record.
+
+ $ xsltproc -o vcards/ gnucash-gnccustomer-vcard2.xsl addresses.xml
+
+ This example is based on an "in-progress" QSF invoice stylesheet for gnucash that is based
+ on the existing pilot-qof HTML invoice stylesheet. It overrides the default mileage-rate
+ (0.30 currency units per unit distance) and the default hourly-rate (20 currency units per
+ hour) provided by the stylesheet with user specific values. The example is here just to
+ indicate how --stringparam would be used.
+
+ $ xsltproc --stringparam mileage-rate 0.45 --stringparam hourly-rate 21 -o invoices/
+ pilot-qof-invoice-xhtml.xsl invoice.xml
+
Added: gnucash/trunk/src/optional/xsl/date-time.xsl
===================================================================
--- gnucash/trunk/src/optional/xsl/date-time.xsl 2006-03-09 16:50:39 UTC (rev 13565)
+++ gnucash/trunk/src/optional/xsl/date-time.xsl 2006-03-09 16:54:44 UTC (rev 13566)
@@ -0,0 +1,1447 @@
+<?xml version="1.0"?>
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:doc="http://xsltsl.org/xsl/documentation/1.0"
+ xmlns:dt="http://xsltsl.org/date-time"
+ xmlns:str="http://xsltsl.org/string"
+ extension-element-prefixes="doc str">
+
+ <doc:reference xmlns="">
+ <referenceinfo>
+ <releaseinfo role="meta">
+ $Id: date-time.xsl,v 1.1.2.1 2006/02/28 08:47:05 neil Exp $
+ </releaseinfo>
+ <author>
+ <surname>Diamond</surname>
+ <firstname>Jason</firstname>
+ </author>
+ <copyright>
+ <year>2004</year>
+ <holder>Steve Ball</holder>
+ </copyright>
+ <copyright>
+ <year>2001</year>
+ <holder>Jason Diamond</holder>
+ </copyright>
+ </referenceinfo>
+
+ <title>Date/Time Processing</title>
+
+ <partintro>
+ <section>
+ <title>Introduction</title>
+
+ <para>This module provides templates for formatting and parsing date/time strings.</para>
+
+ <para>See <ulink url="http://www.tondering.dk/claus/calendar.html">http://www.tondering.dk/claus/calendar.html</ulink> for more information on calendars and the calculations this library performs.</para>
+
+ </section>
+ </partintro>
+
+ </doc:reference>
+
+ <doc:template name="dt:format-date-time" xmlns="">
+ <refpurpose>Returns a string with a formatted date/time.</refpurpose>
+
+ <refdescription>
+ <para>The formatted date/time is determined by the format parameter. The default format is %Y-%m-%dT%H:%M:%S%z, the W3C format.</para>
+ </refdescription>
+
+ <refparameter>
+ <variablelist>
+
+ <varlistentry>
+ <term>xsd-date-time</term>
+ <listitem>
+ <para>The date-time value in XML Schemas (WXS) format.</para>
+ <para>If this value is specified, it takes priority over other parameters.</para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>year</term>
+ <listitem>
+ <para>Year</para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>month</term>
+ <listitem>
+ <para>Month (1 - 12; January = 1)</para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>day</term>
+ <listitem>
+ <para>Day of month (1 - 31)</para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>hour</term>
+ <listitem>
+ <para>Hours since midnight (0 - 23)</para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>minute</term>
+ <listitem>
+ <para>Minutes after hour (0 - 59)</para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>second</term>
+ <listitem>
+ <para>Seconds after minute (0 - 59)</para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>time-zone</term>
+ <listitem>
+ <para>Time zone string (e.g., 'Z' or '-08:00')</para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>format</term>
+ <listitem>
+ <para>The format specification.</para>
+ <variablelist>
+
+ <varlistentry>
+ <term>%a</term>
+ <listitem>
+ <para>Abbreviated weekday name</para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>%A</term>
+ <listitem>
+ <para>Full weekday name</para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>%b</term>
+ <listitem>
+ <para>Abbreviated month name</para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>%B</term>
+ <listitem>
+ <para>Full month name</para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>%c</term>
+ <listitem>
+ <para>Date and time representation appropriate for locale</para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>%d</term>
+ <listitem>
+ <para>Day of month as decimal number (01 - 31)</para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>%e</term>
+ <listitem>
+ <para>Day of month as decimal number (1 - 31)</para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>%H</term>
+ <listitem>
+ <para>Hour in 24-hour format (00 - 23)</para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>%I</term>
+ <listitem>
+ <para>Hour in 12-hour format (01 - 12)</para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>%i</term>
+ <listitem>
+ <para>Hour in 12-hour format (1 - 12)</para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>%j</term>
+ <listitem>
+ <para>Day of year as decimal number (001 - 366)</para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>%m</term>
+ <listitem>
+ <para>Month as decimal number (01 - 12)</para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>%n</term>
+ <listitem>
+ <para>Month as decimal number (1 - 12)</para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>%M</term>
+ <listitem>
+ <para>Minute as decimal number (00 - 59)</para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>%P</term>
+ <listitem>
+ <para>Current locale's A.M./P.M. indicator for 12-hour clock, uppercase</para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>%Q</term>
+ <listitem>
+ <para>Current locale's A.M./P.M. indicator for 12-hour clock, uppercase with periods</para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>%p</term>
+ <listitem>
+ <para>Current locale's A.M./P.M. indicator for 12-hour clock, lowercase</para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>%q</term>
+ <listitem>
+ <para>Current locale's A.M./P.M. indicator for 12-hour clock, lowercase with periods</para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>%S</term>
+ <listitem>
+ <para>Second as decimal number (00 - 59)</para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>%U</term>
+ <listitem>
+ <para>Week of year as decimal number, with Sunday as first day of week (00 - 53)</para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>%w</term>
+ <listitem>
+ <para>Weekday as decimal number (0 - 6; Sunday is 0)</para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>%W</term>
+ <listitem>
+ <para>Week of year as decimal number, with Monday as first day of week (00 - 53)</para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>%x</term>
+ <listitem>
+ <para>Date representation for current locale </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>%X</term>
+ <listitem>
+ <para>Time representation for current locale</para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>%y</term>
+ <listitem>
+ <para>Year without century, as decimal number (00 - 99)</para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>%Y</term>
+ <listitem>
+ <para>Year with century, as decimal number</para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>%z</term>
+ <listitem>
+ <para>Time-zone name or abbreviation; no characters if time zone is unknown</para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>%%</term>
+ <listitem>
+ <para>Percent sign</para>
+ </listitem>
+ </varlistentry>
+
+ </variablelist>
+ </listitem>
+ </varlistentry>
+
+ </variablelist>
+ </refparameter>
+
+ <refreturn>
+ <para>Returns a formatted date/time string.</para>
+ </refreturn>
+
+ </doc:template>
+
+ <xsl:template name="dt:format-date-time">
+ <xsl:param name='xsd-date-time'/>
+ <xsl:param name="year"/>
+ <xsl:param name="month"/>
+ <xsl:param name="day"/>
+ <xsl:param name="hour"/>
+ <xsl:param name="minute"/>
+ <xsl:param name="second"/>
+ <xsl:param name="time-zone"/>
+ <xsl:param name="format" select="'%Y-%m-%dT%H:%M:%S%z'"/>
+
+ <xsl:value-of select="substring-before($format, '%')"/>
+
+ <xsl:variable name="code" select="substring(substring-after($format, '%'), 1, 1)"/>
+
+ <xsl:choose>
+
+ <xsl:when test='$xsd-date-time'>
+ <xsl:call-template name='dt:format-date-time'>
+ <xsl:with-param name='year'>
+ <xsl:call-template name='dt:get-xsd-datetime-year'>
+ <xsl:with-param name='xsd-date-time' select='$xsd-date-time'/>
+ </xsl:call-template>
+ </xsl:with-param>
+ <xsl:with-param name='month'>
+ <xsl:call-template name='dt:get-xsd-datetime-month'>
+ <xsl:with-param name='xsd-date-time' select='$xsd-date-time'/>
+ </xsl:call-template>
+ </xsl:with-param>
+ <xsl:with-param name='day'>
+ <xsl:call-template name='dt:get-xsd-datetime-day'>
+ <xsl:with-param name='xsd-date-time' select='$xsd-date-time'/>
+ </xsl:call-template>
+ </xsl:with-param>
+ <xsl:with-param name='hour'>
+ <xsl:call-template name='dt:get-xsd-datetime-hour'>
+ <xsl:with-param name='xsd-date-time' select='$xsd-date-time'/>
+ </xsl:call-template>
+ </xsl:with-param>
+ <xsl:with-param name='minute'>
+ <xsl:call-template name='dt:get-xsd-datetime-minute'>
+ <xsl:with-param name='xsd-date-time' select='$xsd-date-time'/>
+ </xsl:call-template>
+ </xsl:with-param>
+ <xsl:with-param name='second'>
+ <xsl:call-template name='dt:get-xsd-datetime-second'>
+ <xsl:with-param name='xsd-date-time' select='$xsd-date-time'/>
+ </xsl:call-template>
+ </xsl:with-param>
+ <xsl:with-param name='time-zone'>
+ <xsl:call-template name='dt:get-xsd-datetime-timezone'>
+ <xsl:with-param name='xsd-date-time' select='$xsd-date-time'/>
+ </xsl:call-template>
+ </xsl:with-param>
+ <xsl:with-param name='format'>
+ <xsl:choose>
+ <xsl:when test='contains($format, "%")'>
+ <xsl:text>%</xsl:text>
+ <xsl:value-of select='substring-after($format, "%")'/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select='$format'/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:with-param>
+ </xsl:call-template>
+ </xsl:when>
+
+ <!-- Abbreviated weekday name -->
+ <xsl:when test="$code='a'">
+ <xsl:variable name="day-of-the-week">
+ <xsl:call-template name="dt:calculate-day-of-the-week">
+ <xsl:with-param name="year" select="$year"/>
+ <xsl:with-param name="month" select="$month"/>
+ <xsl:with-param name="day" select="$day"/>
+ </xsl:call-template>
+ </xsl:variable>
+ <xsl:call-template name="dt:get-day-of-the-week-abbreviation">
+ <xsl:with-param name="day-of-the-week" select="$day-of-the-week"/>
+ </xsl:call-template>
+ </xsl:when>
+
+ <!-- Full weekday name -->
+ <xsl:when test="$code='A'">
+ <xsl:variable name="day-of-the-week">
+ <xsl:call-template name="dt:calculate-day-of-the-week">
+ <xsl:with-param name="year" select="$year"/>
+ <xsl:with-param name="month" select="$month"/>
+ <xsl:with-param name="day" select="$day"/>
+ </xsl:call-template>
+ </xsl:variable>
+ <xsl:call-template name="dt:get-day-of-the-week-name">
+ <xsl:with-param name="day-of-the-week" select="$day-of-the-week"/>
+ </xsl:call-template>
+ </xsl:when>
+
+ <!-- Abbreviated month name -->
+ <xsl:when test="$code='b'">
+ <xsl:call-template name="dt:get-month-abbreviation">
+ <xsl:with-param name="month" select="$month"/>
+ </xsl:call-template>
+ </xsl:when>
+
+ <!-- Full month name -->
+ <xsl:when test="$code='B'">
+ <xsl:call-template name="dt:get-month-name">
+ <xsl:with-param name="month" select="$month"/>
+ </xsl:call-template>
+ </xsl:when>
+
+ <!-- Date and time representation appropriate for locale -->
+ <xsl:when test="$code='c'">
+ <xsl:text>[not implemented]</xsl:text>
+ </xsl:when>
+
+ <!-- Day of month as decimal number (01 - 31) -->
+ <xsl:when test="$code='d'">
+ <xsl:if test="$day < 10">0</xsl:if>
+ <xsl:value-of select="number($day)"/>
+ </xsl:when>
+ <!-- Day of month as decimal number (1 - 31) -->
+ <xsl:when test="$code='e'">
+ <xsl:value-of select="number($day)"/>
+ </xsl:when>
+
+ <!-- Hour in 24-hour format (00 - 23) -->
+ <xsl:when test="$code='H'">
+ <xsl:if test="$hour < 10">0</xsl:if>
+ <xsl:value-of select="number($hour)"/>
+ </xsl:when>
+
+ <!-- Hour in 12-hour format (01 - 12) -->
+ <xsl:when test="$code='I'">
+ <xsl:choose>
+ <xsl:when test="$hour = 0">12</xsl:when>
+ <xsl:when test="$hour < 10">0<xsl:value-of select="$hour - 0"/></xsl:when>
+ <xsl:when test="$hour < 13"><xsl:value-of select="$hour - 0"/></xsl:when>
+ <xsl:when test="$hour < 22">0<xsl:value-of select="$hour - 12"/></xsl:when>
+ <xsl:otherwise><xsl:value-of select="$hour - 12"/></xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <!-- Hour in 12-hour format (1 - 12) -->
+ <xsl:when test="$code='i'">
+ <xsl:choose>
+ <xsl:when test="$hour = 0">12</xsl:when>
+ <xsl:when test="$hour < 10"><xsl:value-of select="$hour - 0"/></xsl:when>
+ <xsl:when test="$hour < 13"><xsl:value-of select="$hour - 0"/></xsl:when>
+ <xsl:when test="$hour < 22"><xsl:value-of select="$hour - 12"/></xsl:when>
+ <xsl:otherwise><xsl:value-of select="$hour - 12"/></xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+
+ <!-- Day of year as decimal number (001 - 366) -->
+ <xsl:when test="$code='j'">
+ <xsl:text>[not implemented]</xsl:text>
+ </xsl:when>
+
+ <!-- Month as decimal number (01 - 12) -->
+ <xsl:when test="$code='m'">
+ <xsl:if test="$month < 10">0</xsl:if>
+ <xsl:value-of select="number($month)"/>
+ </xsl:when>
+ <!-- Month as decimal number (1 - 12) -->
+ <xsl:when test="$code='n'">
+ <xsl:value-of select="number($month)"/>
+ </xsl:when>
+
+ <!-- Minute as decimal number (00 - 59) -->
+ <xsl:when test="$code='M'">
+ <xsl:if test="$minute < 10">0</xsl:if>
+ <xsl:value-of select="number($minute)"/>
+ </xsl:when>
+
+ <!-- Current locale's A.M./P.M. indicator for 12-hour clock -->
+ <xsl:when test="$code='p'">
+ <xsl:choose>
+ <xsl:when test="$hour < 12">am</xsl:when>
+ <xsl:otherwise>pm</xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <!-- Current locale's A.M./P.M. indicator for 12-hour clock with periods -->
+ <xsl:when test="$code='q'">
+ <xsl:choose>
+ <xsl:when test="$hour < 12">am</xsl:when>
+ <xsl:otherwise>p.m.</xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <!-- Current locale's A.M./P.M. indicator for 12-hour clock -->
+ <xsl:when test="$code='P'">
+ <xsl:choose>
+ <xsl:when test="$hour < 12">AM</xsl:when>
+ <xsl:otherwise>PM</xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <!-- Current locale's A.M./P.M. indicator for 12-hour clock with periods -->
+ <xsl:when test="$code='Q'">
+ <xsl:choose>
+ <xsl:when test="$hour < 12">AM</xsl:when>
+ <xsl:otherwise>P.M.</xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+
+ <!-- Second as decimal number (00 - 59) -->
+ <xsl:when test="$code='S'">
+ <xsl:if test="$second < 10">0</xsl:if>
+ <xsl:value-of select="number($second)"/>
+ </xsl:when>
+
+ <!-- Week of year as decimal number, with Sunday as first day of week (00 - 53) -->
+ <xsl:when test="$code='U'">
+ <!-- add 1 to day -->
+ <xsl:call-template name="dt:calculate-week-number">
+ <xsl:with-param name="year" select="$year"/>
+ <xsl:with-param name="month" select="$month"/>
+ <xsl:with-param name="day" select="$day + 1"/>
+ </xsl:call-template>
+ </xsl:when>
+
+ <!-- Weekday as decimal number (0 - 6; Sunday is 0) -->
+ <xsl:when test="$code='w'">
+ <xsl:call-template name="dt:calculate-day-of-the-week">
+ <xsl:with-param name="year" select="$year"/>
+ <xsl:with-param name="month" select="$month"/>
+ <xsl:with-param name="day" select="$day"/>
+ </xsl:call-template>
+ </xsl:when>
+
+ <!-- Week of year as decimal number, with Monday as first day of week (00 - 53) -->
+ <xsl:when test="$code='W'">
+ <xsl:call-template name="dt:calculate-week-number">
+ <xsl:with-param name="year" select="$year"/>
+ <xsl:with-param name="month" select="$month"/>
+ <xsl:with-param name="day" select="$day"/>
+ </xsl:call-template>
+ </xsl:when>
+
+ <!-- Date representation for current locale -->
+ <xsl:when test="$code='x'">
+ <xsl:text>[not implemented]</xsl:text>
+ </xsl:when>
+
+ <!-- Time representation for current locale -->
+ <xsl:when test="$code='X'">
+ <xsl:text>[not implemented]</xsl:text>
+ </xsl:when>
+
+ <!-- Year without century, as decimal number (00 - 99) -->
+ <xsl:when test="$code='y'">
+ <xsl:text>[not implemented]</xsl:text>
+ </xsl:when>
+
+ <!-- Year with century, as decimal number -->
+ <xsl:when test="$code='Y'">
+ <xsl:value-of select="concat(substring('000', string-length(number($year))), $year)"/>
+ </xsl:when>
+
+ <!-- Time-zone name or abbreviation; no characters if time zone is unknown -->
+ <xsl:when test="$code='z'">
+ <xsl:value-of select="$time-zone"/>
+ </xsl:when>
+
+ <!-- Percent sign -->
+ <xsl:when test="$code='%'">
+ <xsl:text>%</xsl:text>
+ </xsl:when>
+
+ </xsl:choose>
+
+ <xsl:variable name="remainder" select="substring(substring-after($format, '%'), 2)"/>
+
+ <xsl:if test="not($xsd-date-time) and $remainder">
+ <xsl:call-template name="dt:format-date-time">
+ <xsl:with-param name="year" select="$year"/>
+ <xsl:with-param name="month" select="$month"/>
+ <xsl:with-param name="day" select="$day"/>
+ <xsl:with-param name="hour" select="$hour"/>
+ <xsl:with-param name="minute" select="$minute"/>
+ <xsl:with-param name="second" select="$second"/>
+ <xsl:with-param name="time-zone" select="$time-zone"/>
+ <xsl:with-param name="format" select="$remainder"/>
+ </xsl:call-template>
+ </xsl:if>
+
+ </xsl:template>
+
+ <doc:template name="dt:calculate-day-of-the-week" xmlns="">
+ <refpurpose>Calculates the day of the week.</refpurpose>
+
+ <refdescription>
+ <para>Given any Gregorian date, this calculates the day of the week.</para>
+ </refdescription>
+
+ <refparameter>
+ <variablelist>
+ <varlistentry>
+ <term>year</term>
+ <listitem>
+ <para>Year</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>month</term>
+ <listitem>
+ <para>Month (1 - 12; January = 1)</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>day</term>
+ <listitem>
+ <para>Day of month (1 - 31)</para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refparameter>
+
+ <refreturn>
+ <para>Returns the day of the week (0 - 6; Sunday = 0).</para>
+ </refreturn>
+
+ </doc:template>
+
+ <xsl:template name="dt:calculate-day-of-the-week">
+ <xsl:param name="year"/>
+ <xsl:param name="month"/>
+ <xsl:param name="day"/>
+
+ <xsl:variable name="a" select="floor((14 - $month) div 12)"/>
+ <xsl:variable name="y" select="$year - $a"/>
+ <xsl:variable name="m" select="$month + 12 * $a - 2"/>
+
+ <xsl:value-of select="($day + $y + floor($y div 4) - floor($y div 100) + floor($y div 400) + floor((31 * $m) div 12)) mod 7"/>
+
+ </xsl:template>
+
+ <doc:template name="dt:calculate-last-day-of-month" xmlns="">
+ <refpurpose>Calculates the number of days for a specified month.</refpurpose>
+
+ <refdescription>
+ <para>Given any Gregorian month, this calculates the last day of the month.</para>
+ </refdescription>
+
+ <refparameter>
+ <variablelist>
+ <varlistentry>
+ <term>year</term>
+ <listitem>
+ <para>Year</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>month</term>
+ <listitem>
+ <para>Month (1 - 12; January = 1)</para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refparameter>
+
+ <refreturn>
+ <para>Returns the number of days in given month as a decimal number.</para>
+ </refreturn>
+ </doc:template>
+
+ <xsl:template name="dt:calculate-last-day-of-month">
+ <xsl:param name="year"/>
+ <xsl:param name="month"/>
+
+ <xsl:choose>
+ <xsl:when test="$month = 2">
+ <xsl:choose>
+ <xsl:when test="($year mod 4) = 0 and (($year mod 400) = 0
+ or ($year mod 100) != 0)">29</xsl:when>
+ <xsl:otherwise>28</xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:when test="$month < 8">
+ <xsl:choose>
+ <xsl:when test="$month mod 2 = 0">30</xsl:when>
+ <xsl:otherwise>31</xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:choose>
+ <xsl:when test="$month mod 2 = 1">30</xsl:when>
+ <xsl:otherwise>31</xsl:otherwise>
+ </xsl:choose>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+ <doc:template name="dt:get-day-of-the-week-name" xmlns="">
+ <refpurpose>Gets the day of the week's full name.</refpurpose>
+
+ <refdescription>
+ <para>Converts a numeric day of the week value into a string representing the day's full name.</para>
+ </refdescription>
+
+ <refparameter>
+ <variablelist>
+ <varlistentry>
+ <term>day-of-the-week</term>
+ <listitem>
+ <para>Day of the week (0 - 6; Sunday = 0)</para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refparameter>
+
+ <refreturn>
+ <para>Returns a string.</para>
+ </refreturn>
+
+ </doc:template>
+
+ <xsl:template name="dt:get-day-of-the-week-name">
+ <xsl:param name="day-of-the-week"/>
+
+ <xsl:choose>
+ <xsl:when test="$day-of-the-week = 0">Sunday</xsl:when>
+ <xsl:when test="$day-of-the-week = 1">Monday</xsl:when>
+ <xsl:when test="$day-of-the-week = 2">Tuesday</xsl:when>
+ <xsl:when test="$day-of-the-week = 3">Wednesday</xsl:when>
+ <xsl:when test="$day-of-the-week = 4">Thursday</xsl:when>
+ <xsl:when test="$day-of-the-week = 5">Friday</xsl:when>
+ <xsl:when test="$day-of-the-week = 6">Saturday</xsl:when>
+ <xsl:otherwise>error: <xsl:value-of select="$day-of-the-week"/></xsl:otherwise>
+ </xsl:choose>
+
+ </xsl:template>
+
+ <doc:template name="dt:get-day-of-the-week-abbreviation" xmlns="">
+ <refpurpose>Gets the day of the week's abbreviation.</refpurpose>
+
+ <refdescription>
+ <para>Converts a numeric day of the week value into a string representing the day's abbreviation.</para>
+ </refdescription>
+
+ <refparameter>
+ <variablelist>
+ <varlistentry>
+ <term>day-of-the-week</term>
+ <listitem>
+ <para>Day of the week (0 - 6; Sunday = 0)</para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refparameter>
+
+ <refreturn>
+ <para>Returns a string.</para>
+ </refreturn>
+
+ </doc:template>
+
+ <xsl:template name="dt:get-day-of-the-week-abbreviation">
+ <xsl:param name="day-of-the-week"/>
+
+ <xsl:choose>
+ <xsl:when test="$day-of-the-week = 0">Sun</xsl:when>
+ <xsl:when test="$day-of-the-week = 1">Mon</xsl:when>
+ <xsl:when test="$day-of-the-week = 2">Tue</xsl:when>
+ <xsl:when test="$day-of-the-week = 3">Wed</xsl:when>
+ <xsl:when test="$day-of-the-week = 4">Thu</xsl:when>
+ <xsl:when test="$day-of-the-week = 5">Fri</xsl:when>
+ <xsl:when test="$day-of-the-week = 6">Sat</xsl:when>
+ <xsl:otherwise>error: <xsl:value-of select="$day-of-the-week"/></xsl:otherwise>
+ </xsl:choose>
+
+ </xsl:template>
+
+ <doc:template name="dt:get-month-name" xmlns="">
+ <refpurpose>Gets the month's full name.</refpurpose>
+
+ <refdescription>
+ <para>Converts a numeric month value into a string representing the month's full name.</para>
+ </refdescription>
+
+ <refparameter>
+ <variablelist>
+ <varlistentry>
+ <term>month</term>
+ <listitem>
+ <para>Month (1 - 12; Januaray = 1)</para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refparameter>
+
+ <refreturn>
+ <para>Returns a string.</para>
+ </refreturn>
+
+ </doc:template>
+
+ <xsl:template name="dt:get-month-name">
+ <xsl:param name="month"/>
+
+ <xsl:choose>
+ <xsl:when test="$month = 1">January</xsl:when>
+ <xsl:when test="$month = 2">February</xsl:when>
+ <xsl:when test="$month = 3">March</xsl:when>
+ <xsl:when test="$month = 4">April</xsl:when>
+ <xsl:when test="$month = 5">May</xsl:when>
+ <xsl:when test="$month = 6">June</xsl:when>
+ <xsl:when test="$month = 7">July</xsl:when>
+ <xsl:when test="$month = 8">August</xsl:when>
+ <xsl:when test="$month = 9">September</xsl:when>
+ <xsl:when test="$month = 10">October</xsl:when>
+ <xsl:when test="$month = 11">November</xsl:when>
+ <xsl:when test="$month = 12">December</xsl:when>
+ <xsl:otherwise>error: <xsl:value-of select="$month"/></xsl:otherwise>
+ </xsl:choose>
+
+ </xsl:template>
+
+ <doc:template name="dt:get-month-abbreviation" xmlns="">
+ <refpurpose>Gets the month's abbreviation.</refpurpose>
+
+ <refdescription>
+ <para>Converts a numeric month value into a string representing the month's abbreviation.</para>
+ </refdescription>
+
+ <refparameter>
+ <variablelist>
+ <varlistentry>
+ <term>month</term>
+ <listitem>
+ <para>Month (1 - 12; Januaray = 1)</para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refparameter>
+
+ <refreturn>
+ <para>Returns a string.</para>
+ </refreturn>
+
+ </doc:template>
+
+ <xsl:template name="dt:get-month-abbreviation">
+ <xsl:param name="month"/>
+
+ <xsl:choose>
+ <xsl:when test="$month = 1">Jan</xsl:when>
+ <xsl:when test="$month = 2">Feb</xsl:when>
+ <xsl:when test="$month = 3">Mar</xsl:when>
+ <xsl:when test="$month = 4">Apr</xsl:when>
+ <xsl:when test="$month = 5">May</xsl:when>
+ <xsl:when test="$month = 6">Jun</xsl:when>
+ <xsl:when test="$month = 7">Jul</xsl:when>
+ <xsl:when test="$month = 8">Aug</xsl:when>
+ <xsl:when test="$month = 9">Sep</xsl:when>
+ <xsl:when test="$month = 10">Oct</xsl:when>
+ <xsl:when test="$month = 11">Nov</xsl:when>
+ <xsl:when test="$month = 12">Dec</xsl:when>
+ <xsl:otherwise>error: <xsl:value-of select="$month"/></xsl:otherwise>
+ </xsl:choose>
+
+ </xsl:template>
+
+ <doc:template name="dt:calculate-julian-day" xmlns="">
+ <refpurpose>Calculates the Julian Day for a specified date.</refpurpose>
+
+ <refdescription>
+ <para>Given any Gregorian date, this calculates the Julian Day.</para>
+ </refdescription>
+
+ <refparameter>
+ <variablelist>
+ <varlistentry>
+ <term>year</term>
+ <listitem>
+ <para>Year</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>month</term>
+ <listitem>
+ <para>Month (1 - 12; January = 1)</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>day</term>
+ <listitem>
+ <para>Day of month (1 - 31)</para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refparameter>
+
+ <refreturn>
+ <para>Returns the Julian Day as a decimal number.</para>
+ </refreturn>
+
+ </doc:template>
+
+ <xsl:template name="dt:calculate-julian-day">
+ <xsl:param name="year"/>
+ <xsl:param name="month"/>
+ <xsl:param name="day"/>
+
+ <xsl:variable name="a" select="floor((14 - $month) div 12)"/>
+ <xsl:variable name="y" select="$year + 4800 - $a"/>
+ <xsl:variable name="m" select="$month + 12 * $a - 3"/>
+
+ <xsl:value-of select="$day + floor((153 * $m + 2) div 5) + $y * 365 + floor($y div 4) - floor($y div 100) + floor($y div 400) - 32045"/>
+
+ </xsl:template>
+
+ <doc:template name="dt:format-julian-day" xmlns="">
+ <refpurpose>Returns a string with a formatted date for a specified Julian Day.</refpurpose>
+
+ <refdescription>
+ <para>Given any Julian Day, this returns a string according to the format specification.</para>
+ </refdescription>
+
+ <refparameter>
+ <variablelist>
+ <varlistentry>
+ <term>julian-day</term>
+ <listitem>
+ <para>A Julian Day</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>format</term>
+ <listitem>
+ <para>The format specification. See dt:format-date-time for more details.</para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refparameter>
+
+ <refreturn>
+ <para>A string.</para>
+ </refreturn>
+
+ </doc:template>
+
+ <xsl:template name="dt:format-julian-day">
+ <xsl:param name="julian-day"/>
+ <xsl:param name="format" select="'%Y-%m-%d'"/>
+
+ <xsl:variable name="a" select="$julian-day + 32044"/>
+ <xsl:variable name="b" select="floor((4 * $a + 3) div 146097)"/>
+ <xsl:variable name="c" select="$a - floor(($b * 146097) div 4)"/>
+
+ <xsl:variable name="d" select="floor((4 * $c + 3) div 1461)"/>
+ <xsl:variable name="e" select="$c - floor((1461 * $d) div 4)"/>
+ <xsl:variable name="m" select="floor((5 * $e + 2) div 153)"/>
+
+ <xsl:variable name="day" select="$e - floor((153 * $m + 2) div 5) + 1"/>
+ <xsl:variable name="month" select="$m + 3 - 12 * floor($m div 10)"/>
+ <xsl:variable name="year" select="$b * 100 + $d - 4800 + floor($m div 10)"/>
+
+ <xsl:call-template name="dt:format-date-time">
+ <xsl:with-param name="year" select="$year"/>
+ <xsl:with-param name="month" select="$month"/>
+ <xsl:with-param name="day" select="$day"/>
+ <xsl:with-param name="format" select="$format"/>
+ </xsl:call-template>
+
+ </xsl:template>
+
+ <doc:template name="dt:calculate-week-number" xmlns="">
+ <refpurpose>Calculates the week number for a specified date.</refpurpose>
+
+ <refdescription>
+ <para>Assumes Monday is the first day of the week.</para>
+ </refdescription>
+
+ <refparameter>
+ <variablelist>
+ <varlistentry>
+ <term>year</term>
+ <listitem>
+ <para>Year</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>month</term>
+ <listitem>
+ <para>Month (1 - 12; January = 1)</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>day</term>
+ <listitem>
+ <para>Day of month (1 - 31)</para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refparameter>
+
+ <refreturn>
+ <para>Returns the week number as a decimal number.</para>
+ </refreturn>
+
+ </doc:template>
+
+ <xsl:template name="dt:calculate-week-number">
+ <xsl:param name="year"/>
+ <xsl:param name="month"/>
+ <xsl:param name="day"/>
+
+ <xsl:variable name="J">
+ <xsl:call-template name="dt:calculate-julian-day">
+ <xsl:with-param name="year" select="$year"/>
+ <xsl:with-param name="month" select="$month"/>
+ <xsl:with-param name="day" select="$day"/>
+ </xsl:call-template>
+ </xsl:variable>
+
+ <xsl:variable name="d4" select="($J + 31741 - ($J mod 7)) mod 146097 mod 36524 mod 1461"/>
+ <xsl:variable name="L" select="floor($d4 div 1460)"/>
+ <xsl:variable name="d1" select="(($d4 - $L) mod 365) + $L"/>
+
+ <xsl:value-of select="floor($d1 div 7) + 1"/>
+
+ </xsl:template>
+
+ <doc:template name="dt:get-month-number" xmlns="">
+ <refpurpose>Take a month by name and return a number which can be used as input to the templates. </refpurpose>
+
+ <refdescription>
+ <para>Input</para>
+ </refdescription>
+
+ <refparameter>
+ <variablelist>
+ <varlistentry>
+ <term>month</term>
+ <listitem>
+ <para>Month as described either by full name or abbreviation.</para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refparameter>
+
+ <refreturn>
+ <para>Return a month as a decimal number. (Jan = 1)</para>
+ </refreturn>
+ </doc:template>
+
+ <xsl:template name='dt:get-month-number'>
+ <xsl:param name='month'/>
+
+ <xsl:variable name='monToUpper'>
+ <xsl:call-template name='str:to-upper'>
+ <xsl:with-param name='text' select='$month'/>
+ </xsl:call-template>
+ </xsl:variable>
+
+ <xsl:choose>
+ <xsl:when test='starts-with($monToUpper,"JAN")'>
+ <xsl:value-of select='"1"'/>
+ </xsl:when>
+ <xsl:when test='starts-with($monToUpper,"FEB")'>
+ <xsl:value-of select='2'/>
+ </xsl:when>
+ <xsl:when test='starts-with($monToUpper,"MAR")'>
+ <xsl:value-of select='3'/>
+ </xsl:when>
+ <xsl:when test='starts-with($monToUpper,"APR")'>
+ <xsl:value-of select='4'/>
+ </xsl:when>
+ <xsl:when test='starts-with($monToUpper,"MAY")'>
+ <xsl:value-of select='5'/>
+ </xsl:when>
+ <xsl:when test='starts-with($monToUpper,"JUN")'>
+ <xsl:value-of select='6'/>
+ </xsl:when>
+ <xsl:when test='starts-with($monToUpper,"JUL")'>
+ <xsl:value-of select='7'/>
+ </xsl:when>
+ <xsl:when test='starts-with($monToUpper,"AUG")'>
+ <xsl:value-of select='8'/>
+ </xsl:when>
+ <xsl:when test='starts-with($monToUpper,"SEP")'>
+ <xsl:value-of select='9'/>
+ </xsl:when>
+ <xsl:when test='starts-with($monToUpper,"OCT")'>
+ <xsl:value-of select='10'/>
+ </xsl:when>
+ <xsl:when test='starts-with($monToUpper,"NOV")'>
+ <xsl:value-of select='11'/>
+ </xsl:when>
+ <xsl:when test='starts-with($monToUpper,"DEC")'>
+ <xsl:value-of select='"12"'/>
+ </xsl:when>
+ </xsl:choose>
+ </xsl:template>
+
+ <doc:template name="dt:get-xsd-datetime-year" xmlns="">
+ <refpurpose>Return year component of XSD DateTime value.</refpurpose>
+
+ <refdescription>
+ <para>Extract component of XML Schemas DateTime value.</para>
+ </refdescription>
+
+ <refparameter>
+ <variablelist>
+ <varlistentry>
+ <term>xsd-date-time</term>
+ <listitem>
+ <para>A value in XSD DateTime format.</para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refparameter>
+
+ <refreturn>
+ <para>Returns year component.</para>
+ </refreturn>
+ </doc:template>
+
+ <xsl:template name='dt:get-xsd-datetime-year'>
+ <xsl:param name='xsd-date-time'/>
+
+ <xsl:choose>
+ <xsl:when test='contains($xsd-date-time, "T")'>
+ <xsl:call-template name='dt:get-xsd-datetime-year'>
+ <xsl:with-param name='xsd-date-time' select='substring-before($xsd-date-time, "T")'/>
+ </xsl:call-template>
+ </xsl:when>
+
+ <!-- Check for time -->
+ <xsl:when test='substring($xsd-date-time, 3, 1) = ":"'/>
+
+ <xsl:otherwise>
+ <!-- This is a date -->
+ <xsl:value-of select='substring-before($xsd-date-time, "-")'/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+ <doc:template name="dt:get-xsd-datetime-month" xmlns="">
+ <refpurpose>Return month component of XSD DateTime value.</refpurpose>
+
+ <refdescription>
+ <para>Extract component of XML Schemas DateTime value.</para>
+ </refdescription>
+
+ <refparameter>
+ <variablelist>
+ <varlistentry>
+ <term>xsd-date-time</term>
+ <listitem>
+ <para>A value in XSD DateTime format.</para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refparameter>
+
+ <refreturn>
+ <para>Returns month component.</para>
+ </refreturn>
+ </doc:template>
+
+ <xsl:template name='dt:get-xsd-datetime-month'>
+ <xsl:param name='xsd-date-time'/>
+
+ <xsl:choose>
+ <xsl:when test='contains($xsd-date-time, "T")'>
+ <xsl:call-template name='dt:get-xsd-datetime-month'>
+ <xsl:with-param name='xsd-date-time' select='substring-before($xsd-date-time, "T")'/>
+ </xsl:call-template>
+ </xsl:when>
+
+ <!-- Check for time -->
+ <xsl:when test='substring($xsd-date-time, 3, 1) = ":"'/>
+
+ <xsl:otherwise>
+ <!-- This is a date -->
+ <xsl:value-of select='substring(substring-after($xsd-date-time, "-"), 1, 2)'/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+ <doc:template name="dt:get-xsd-datetime-day" xmlns="">
+ <refpurpose>Return day component of XSD DateTime value.</refpurpose>
+
+ <refdescription>
+ <para>Extract component of XML Schemas DateTime value.</para>
+ </refdescription>
+
+ <refparameter>
+ <variablelist>
+ <varlistentry>
+ <term>xsd-date-time</term>
+ <listitem>
+ <para>A value in XSD DateTime format.</para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refparameter>
+
+ <refreturn>
+ <para>Returns day component.</para>
+ </refreturn>
+ </doc:template>
+
+ <xsl:template name='dt:get-xsd-datetime-day'>
+ <xsl:param name='xsd-date-time'/>
+
+ <xsl:choose>
+ <xsl:when test='contains($xsd-date-time, "T")'>
+ <xsl:call-template name='dt:get-xsd-datetime-day'>
+ <xsl:with-param name='xsd-date-time' select='substring-before($xsd-date-time, "T")'/>
+ </xsl:call-template>
+ </xsl:when>
+
+ <!-- Check for time -->
+ <xsl:when test='substring($xsd-date-time, 3, 1) = ":"'/>
+
+ <xsl:otherwise>
+ <!-- This is a date -->
+ <xsl:value-of select='substring(substring-after($xsd-date-time, "-"), 4, 2)'/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+ <doc:template name="dt:get-xsd-datetime-hour" xmlns="">
+ <refpurpose>Return hour component of XSD DateTime value.</refpurpose>
+
+ <refdescription>
+ <para>Extract component of XML Schemas DateTime value.</para>
+ </refdescription>
+
+ <refparameter>
+ <variablelist>
+ <varlistentry>
+ <term>xsd-date-time</term>
+ <listitem>
+ <para>A value in XSD DateTime format.</para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refparameter>
+
+ <refreturn>
+ <para>Returns hour component.</para>
+ </refreturn>
+ </doc:template>
+
+ <xsl:template name='dt:get-xsd-datetime-hour'>
+ <xsl:param name='xsd-date-time'/>
+
+ <xsl:choose>
+ <xsl:when test='contains($xsd-date-time, "T")'>
+ <xsl:call-template name='dt:get-xsd-datetime-hour'>
+ <xsl:with-param name='xsd-date-time' select='substring-after($xsd-date-time, "T")'/>
+ </xsl:call-template>
+ </xsl:when>
+
+ <!-- Check for time -->
+ <xsl:when test='substring($xsd-date-time, 3, 1) = ":"'>
+ <xsl:value-of select='substring($xsd-date-time, 1, 2)'/>
+ </xsl:when>
+
+ <xsl:otherwise>
+ <!-- This is a date -->
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+ <doc:template name="dt:get-xsd-datetime-minute" xmlns="">
+ <refpurpose>Return minute component of XSD DateTime value.</refpurpose>
+
+ <refdescription>
+ <para>Extract component of XML Schemas DateTime value.</para>
+ </refdescription>
+
+ <refparameter>
+ <variablelist>
+ <varlistentry>
+ <term>xsd-date-time</term>
+ <listitem>
+ <para>A value in XSD DateTime format.</para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refparameter>
+
+ <refreturn>
+ <para>Returns minute component.</para>
+ </refreturn>
+ </doc:template>
+
+ <xsl:template name='dt:get-xsd-datetime-minute'>
+ <xsl:param name='xsd-date-time'/>
+
+ <xsl:choose>
+ <xsl:when test='contains($xsd-date-time, "T")'>
+ <xsl:call-template name='dt:get-xsd-datetime-minute'>
+ <xsl:with-param name='xsd-date-time' select='substring-after($xsd-date-time, "T")'/>
+ </xsl:call-template>
+ </xsl:when>
+
+ <!-- Check for time -->
+ <xsl:when test='substring($xsd-date-time, 3, 1) = ":"'>
+ <xsl:value-of select='substring($xsd-date-time, 4, 2)'/>
+ </xsl:when>
+
+ <xsl:otherwise>
+ <!-- This is a date -->
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+ <doc:template name="dt:get-xsd-datetime-second" xmlns="">
+ <refpurpose>Return second component of XSD DateTime value.</refpurpose>
+
+ <refdescription>
+ <para>Extract component of XML Schemas DateTime value.</para>
+ </refdescription>
+
+ <refparameter>
+ <variablelist>
+ <varlistentry>
+ <term>xsd-date-time</term>
+ <listitem>
+ <para>A value in XSD DateTime format.</para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refparameter>
+
+ <refreturn>
+ <para>Returns second component.</para>
+ </refreturn>
+ </doc:template>
+
+ <xsl:template name='dt:get-xsd-datetime-second'>
+ <xsl:param name='xsd-date-time'/>
+
+ <xsl:choose>
+ <xsl:when test='contains($xsd-date-time, "T")'>
+ <xsl:call-template name='dt:get-xsd-datetime-second'>
+ <xsl:with-param name='xsd-date-time' select='substring-after($xsd-date-time, "T")'/>
+ </xsl:call-template>
+ </xsl:when>
+
+ <!-- Check for time -->
+ <xsl:when test='substring($xsd-date-time, 3, 1) = ":"'>
+ <xsl:variable name='part' select='substring($xsd-date-time, 7)'/>
+ <xsl:choose>
+ <xsl:when test='contains($part, "Z")'>
+ <xsl:value-of select='substring-before($part, "Z")'/>
+ </xsl:when>
+ <xsl:when test='contains($part, "+")'>
+ <xsl:value-of select='substring-before($part, "+")'/>
+ </xsl:when>
+ <xsl:when test='contains($part, "-")'>
+ <xsl:value-of select='substring-before($part, "-")'/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select='$part'/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+
+ <xsl:otherwise>
+ <!-- This is a date -->
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+ <doc:template name="dt:get-xsd-datetime-timezone" xmlns="">
+ <refpurpose>Return timezone component of XSD DateTime value.</refpurpose>
+
+ <refdescription>
+ <para>Extract component of XML Schemas DateTime value.</para>
+ </refdescription>
+
+ <refparameter>
+ <variablelist>
+ <varlistentry>
+ <term>xsd-date-time</term>
+ <listitem>
+ <para>A value in XSD DateTime format.</para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refparameter>
+
+ <refreturn>
+ <para>Returns timezone component.</para>
+ </refreturn>
+ </doc:template>
+
+ <xsl:template name='dt:get-xsd-datetime-timezone'>
+ <xsl:param name='xsd-date-time'/>
+
+ <xsl:choose>
+ <xsl:when test='contains($xsd-date-time, "Z")'>Z</xsl:when>
+ <xsl:when test='contains($xsd-date-time, "T")'>
+ <xsl:call-template name='dt:get-xsd-datetime-timezone'>
+ <xsl:with-param name='xsd-date-time' select='substring-after($xsd-date-time, "T")'/>
+ </xsl:call-template>
+ </xsl:when>
+
+ <xsl:when test='substring($xsd-date-time, 3, 1) = ":"'>
+ <!-- This is a time -->
+ <xsl:choose>
+ <xsl:when test='contains($xsd-date-time, "+")'>
+ <xsl:text>+</xsl:text>
+ <xsl:value-of select='substring-after($xsd-date-time, "+")'/>
+ </xsl:when>
+ <xsl:when test='contains($xsd-date-time, "-")'>
+ <xsl:text>-</xsl:text>
+ <xsl:value-of select='substring-after($xsd-date-time, "-")'/>
+ </xsl:when>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:otherwise>
+ <!-- This is a date -->
+ <xsl:value-of select='substring(substring-after($xsd-date-time, "-"), 6)'/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+</xsl:stylesheet>
Added: gnucash/trunk/src/optional/xsl/gnucash-gnccustomer-vcard2.xsl
===================================================================
--- gnucash/trunk/src/optional/xsl/gnucash-gnccustomer-vcard2.xsl 2006-03-09 16:50:39 UTC (rev 13565)
+++ gnucash/trunk/src/optional/xsl/gnucash-gnccustomer-vcard2.xsl 2006-03-09 16:54:44 UTC (rev 13566)
@@ -0,0 +1,74 @@
+<?xml version="1.0"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:qof-qsf="http://qof.sourceforge.net/" xmlns:str="http://xsltsl.org/string" version="1.1">
+ <xsl:import href="string.xsl"/>
+ <!-- our own gnucash standard routines -->
+ <xsl:import href="gnucash-std.xsl"/>
+ <xsl:output method="text"/>
+ <!-- Representing QSF gncAddress data in a 2.1 extended VCard
+
+ This stylesheet converts the GnuCash output from Export Customers
+ into a simple Vcard, suitable for import into KAdddressbook. For other
+ VCard support (e.g. for mobile phones), see other vcard XSL stylesheets in the
+ gnucash collection.
+
+ Each VCard is written into a separate .vcf file, named after the
+ contact described in the gncAddress records. Spaces are replaced with
+ underscores. Specify the '-o dir/' option to xsltproc to output all vcards
+ into a directory.
+ -->
+ <!-- Licence
+
+ This file is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ -->
+ <xsl:template match="/*/qof-qsf:book/qof-qsf:object[@type='gncAddress']">
+ <xsl:text>TEL;TYPE=WORK:</xsl:text>
+ <xsl:value-of select="qof-qsf:string[@type='phone']"/>
+ <xsl:text> TEL;TYPE=FAX:</xsl:text>
+ <xsl:value-of select="qof-qsf:string[@type='fax']"/>
+ <xsl:text> EMAIL:</xsl:text>
+ <xsl:value-of select="qof-qsf:string[@type='email']"/>
+ <xsl:text> ADR;TYPE=work:;;</xsl:text>
+ <xsl:value-of select="qof-qsf:string[@type='number']"/>
+ <xsl:text>;</xsl:text>
+ <xsl:value-of select="qof-qsf:string[@type='street']"/>
+ <xsl:text>;</xsl:text>
+ <xsl:value-of select="qof-qsf:string[@type='locality']"/>
+ <xsl:text>;</xsl:text>
+ <xsl:value-of select="qof-qsf:string[@type='city']"/>
+ <xsl:text> N:</xsl:text>
+ <xsl:value-of select="qof-qsf:string[@type='name']"/>
+ <xsl:text> </xsl:text>
+ </xsl:template>
+ <xsl:template match="/">
+ <xsl:for-each select="/*/qof-qsf:book/qof-qsf:object[@type='gncCustomer']">
+ <xsl:variable name="contactName">
+ <xsl:value-of select="qof-qsf:string[@type='name']"/>
+ </xsl:variable>
+ <xsl:variable name="card_title">
+ <xsl:call-template name="get_chunk_name">
+ <xsl:with-param name="entryName" select="$contactName"/>
+ </xsl:call-template>
+ </xsl:variable>
+ <!-- chunking support -->
+ <xsl:document href="{$card_title}.vcf" method="text">
+ <xsl:text>BEGIN:VCARD VERSION:2.1 </xsl:text>
+ <xsl:call-template name="locate_child">
+ <xsl:with-param name="customer_object" select="."/>
+ </xsl:call-template>
+ <xsl:text>END:VCARD </xsl:text>
+ </xsl:document>
+ </xsl:for-each>
+ </xsl:template>
+</xsl:stylesheet>
Added: gnucash/trunk/src/optional/xsl/gnucash-std.xsl
===================================================================
--- gnucash/trunk/src/optional/xsl/gnucash-std.xsl 2006-03-09 16:50:39 UTC (rev 13565)
+++ gnucash/trunk/src/optional/xsl/gnucash-std.xsl 2006-03-09 16:54:44 UTC (rev 13566)
@@ -0,0 +1,140 @@
+<?xml version="1.0"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:qof-qsf="http://qof.sourceforge.net/" xmlns:html="http://www.w3.org/1999/xhtml" xmlns:dt="http://xsltsl.org/date-time" xmlns:str="http://xsltsl.org/string" version="1.0" exclude-result-prefixes="qof-qsf html dt str">
+ <xsl:import href="date-time.xsl"/>
+ <xsl:import href="string.xsl"/>
+ <!--This stylesheet contains standard templates for QOF QSF.-->
+ <!--This is only a working prototype -->
+ <!-- Licence
+
+ This file is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ -->
+ <!-- Translation support via external parameters -->
+ <xsl:param name="html_lang">en</xsl:param>
+ <xsl:param name="encoding">iso-8859-15</xsl:param>
+ <!-- Convert gnc_numeric notation to an XSL number -->
+ <xsl:template name="numeric_to_double">
+ <xsl:param name="numeric_string"/>
+ <xsl:variable name="before" select="substring-before($numeric_string, '/')"/>
+ <xsl:variable name="after" select="substring-after($numeric_string, '/')"/>
+ <xsl:variable name="numeric" select="$before div $after"/>
+ <xsl:value-of select="number($numeric)"/>
+ </xsl:template>
+ <xsl:template name="get_chunk_name">
+ <xsl:param name="entryName"/>
+ <xsl:param name="entryCompany"/>
+ <xsl:variable name="result">
+ <xsl:choose>
+ <xsl:when test="$entryName = ''">
+ <xsl:call-template name="str:subst">
+ <xsl:with-param name="text" select="$entryCompany"/>
+ <xsl:with-param name="replace">
+ <xsl:text> </xsl:text>
+ </xsl:with-param>
+ <xsl:with-param name="with">
+ <xsl:text>_</xsl:text>
+ </xsl:with-param>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:variable name="temp">
+ <xsl:call-template name="str:subst">
+ <xsl:with-param name="text" select="$entryName"/>
+ <xsl:with-param name="replace">
+ <xsl:text> </xsl:text>
+ </xsl:with-param>
+ <xsl:with-param name="with">
+ <xsl:text>_</xsl:text>
+ </xsl:with-param>
+ </xsl:call-template>
+ </xsl:variable>
+ <xsl:call-template name="str:subst">
+ <xsl:with-param name="text" select="$temp"/>
+ <xsl:with-param name="replace">
+ <xsl:text>;</xsl:text>
+ </xsl:with-param>
+ <xsl:with-param name="with">
+ <xsl:text>_</xsl:text>
+ </xsl:with-param>
+ </xsl:call-template>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+ <xsl:value-of select="$result"/>
+ </xsl:template>
+ <xsl:template name="prepare_address_div">
+ <xsl:param name="address_object" select="."/>
+ <xsl:comment>this address panel can be located precisely using CSS</xsl:comment>
+ <xsl:text> </xsl:text>
+ <div class="address">
+ <h2>Customer address</h2>
+ <p class="address_para">
+ <xsl:text> </xsl:text>
+ <b>
+ <xsl:value-of select="qof-qsf:string[@type='entryCompany']"/>
+ </b>
+ <br/>
+ <xsl:text> </xsl:text>
+ <xsl:value-of select="qof-qsf:string[@type='entryAddress']"/>
+ <br/>
+ <xsl:text> </xsl:text>
+ <xsl:value-of select="qof-qsf:string[@type='entryCity']"/>
+ <br/>
+ <xsl:text> </xsl:text>
+ <xsl:value-of select="qof-qsf:string[@type='entryState']"/>
+ <br/>
+ <xsl:text> </xsl:text>
+ <xsl:value-of select="qof-qsf:string[@type='entryZip']"/>
+ <br/>
+ <xsl:text> </xsl:text>
+ <xsl:value-of select="qof-qsf:string[@type='entryCountry']"/>
+ <br/>
+ <br/>
+ <xsl:text> </xsl:text>
+ <xsl:value-of select="qof-qsf:string[@type='entryPhone1']"/>
+ </p>
+ </div>
+ </xsl:template>
+ <xsl:template name="vcard_safe">
+ <xsl:param name="address_string"/>
+ <xsl:variable name="safe_string">
+ <xsl:call-template name="str:subst">
+ <xsl:with-param name="text" select="$entryCompany"/>
+ <xsl:with-param name="replace">
+ <xsl:text>,</xsl:text>
+ </xsl:with-param>
+ <xsl:with-param name="with">
+ <xsl:text>\,</xsl:text>
+ </xsl:with-param>
+ </xsl:call-template>
+ </xsl:variable>
+ <xsl:value-of select="$safe_string"/>
+ </xsl:template>
+ <!-- hierarchy support -->
+ <xsl:template name="locate_child">
+ <xsl:param name="customer_object"/>
+ <xsl:variable name="cust_addr_guid">
+ <xsl:value-of select="qof-qsf:guid[@type='addr']"/>
+ </xsl:variable>
+ <xsl:for-each select="/*/qof-qsf:book/qof-qsf:object[@type='gncAddress']">
+ <xsl:variable name="addr_guid">
+ <xsl:value-of select="qof-qsf:guid[@type='guid']"/>
+ </xsl:variable>
+ <xsl:if test="$addr_guid = $cust_addr_guid">
+ <xsl:variable name="set" select="."/>
+ <xsl:apply-templates select="$set"/>
+ </xsl:if>
+ </xsl:for-each>
+ </xsl:template>
+</xsl:stylesheet>
Added: gnucash/trunk/src/optional/xsl/string.xsl
===================================================================
--- gnucash/trunk/src/optional/xsl/string.xsl 2006-03-09 16:50:39 UTC (rev 13565)
+++ gnucash/trunk/src/optional/xsl/string.xsl 2006-03-09 16:54:44 UTC (rev 13566)
@@ -0,0 +1,1233 @@
+<?xml version="1.0"?>
+
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:doc="http://xsltsl.org/xsl/documentation/1.0"
+ xmlns:str="http://xsltsl.org/string"
+ extension-element-prefixes="doc str">
+
+ <doc:reference xmlns="">
+ <referenceinfo>
+ <releaseinfo role="meta">
+ $Id: string.xsl,v 1.1.2.1 2006/02/28 08:47:05 neil Exp $
+ </releaseinfo>
+ <author>
+ <surname>Ball</surname>
+ <firstname>Steve</firstname>
+ </author>
+ <copyright>
+ <year>2002</year>
+ <year>2001</year>
+ <holder>Steve Ball</holder>
+ </copyright>
+ </referenceinfo>
+
+ <title>String Processing</title>
+
+ <partintro>
+ <section>
+ <title>Introduction</title>
+
+ <para>This module provides templates for manipulating strings.</para>
+
+ </section>
+ </partintro>
+
+ </doc:reference>
+
+ <!-- Common string constants and datasets as XSL variables -->
+
+ <!-- str:lower and str:upper contain pairs of lower and upper case
+ characters. Below insanely long strings should contain the
+ official lower/uppercase pairs, making this stylesheet working
+ for every language on earth. Hopefully. -->
+ <!-- These values are not enough, however. There are some
+ exceptions, dealt with below. -->
+ <xsl:variable name="xsltsl-str-lower" select="'abcdefghijklmnopqrstuvwxyzµàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿāăąćĉċčďđēĕėęěĝğġģĥħĩīĭįıijĵķĺļľŀłńņňŋōŏőœŕŗřśŝşšţťŧũūŭůűųŵŷźżžſƃƅƈƌƒƕƙơƣƥƨƭưƴƶƹƽƿDždžLjljNjnjǎǐǒǔǖǘǚǜǝǟǡǣǥǧǩǫǭǯDzdzǵǹǻǽǿȁȃȅȇȉȋȍȏȑȓȕȗșțȝȟȣȥȧȩȫȭȯȱȳɓɔɖɗəɛɠɣɨɩɯɲɵʀʃʈʊʋʒͅάέήίαβγδεζηθικλμνξοπρςστυφχψωϊϋόύ!
CE;
D0;ϑϕϖϛϝϟϡϣϥϧϩϫϭϯϰϱϲϵабвгдежзийклмнопрстуфхцчшщъыьэюяѐёђѓєѕіїјљњћќѝўџѡѣѥѧѩѫѭѯѱѳѵѷѹѻѽѿҁҍҏґғҕҗҙқҝҟҡңҥҧҩҫҭүұҳҵҷҹһҽҿӂӄӈӌӑӓӕӗәӛӝӟӡӣӥӧөӫӭӯӱӳӵӹաբգդեզէըթժիլխծկհձղճմյնշոչպջռսվտրցւփքօֆḁḃḅḇḉḋḍḏḑḓḕḗḙḛḝḟḡḣḥḧḩḫḭḯḱḳḵḷḹḻḽḿṁṃṅṇṉṋṍṏṑṓṕṗṙṛṝṟṡṣṥṧṩṫṭṯṱṳṵṷṹṻṽṿẁẃẅẇẉẋẍẏẑẓẕẛạảấầẩẫậ!
EAF;
EB1;ẳẵặẹẻẽếềểễệỉịọỏốồổỗộớờởỡợụủứừửữựỳỵỷỹἀἁἂἃἄἅἆἇἐἑἒἓἔἕἠἡἢἣἤἥἦἧἰἱἲἳἴἵἶἷὀὁὂὃὄὅὑὓὕὗὠὡὢὣὤὥὦὧὰάὲέὴήὶίὸόὺύὼώᾀᾁᾂᾃᾄᾅᾆᾇᾐᾑᾒᾓᾔᾕᾖᾗᾠᾡᾢᾣᾤᾥᾦᾧᾰᾱᾳιῃῐῑῠῡῥῳⅰⅱⅲⅳⅴⅵⅶⅷⅸⅹⅺⅻⅼⅽⅾⅿⓐⓑⓒⓓⓔⓕⓖⓗⓘⓙⓚⓛⓜⓝⓞⓟⓠⓡⓢⓣⓤⓥⓦⓧⓨⓩabcdefghijklmnopqrstuvwxyz𐐨𐐩𐐪𐐫𐐬𐐭𐐮𐐯𐐰𐐱𐐲𐐳𐐴𐐵𐐶𐐷𐐸𐐹𐐺𐐻𐐼𐐽𐐾𐐿𐑀𐑁𐑂𐑃𐑄𐑅𐑆𐑇𐑈𐑉𐑊𐑋𐑌𐑍'"/>
+ <xsl:variable name="xsltsl-str-upper" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZΜÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞŸĀĂĄĆĈĊČĎĐĒĔĖĘĚĜĞĠĢĤĦĨĪĬĮIIJĴĶĹĻĽĿŁŃŅŇŊŌŎŐŒŔŖŘŚŜŞŠŢŤŦŨŪŬŮŰŲŴŶŹŻŽSƂƄƇƋƑǶƘƠƢƤƧƬƯƳƵƸƼǷDŽDŽLJLJNJNJǍǏǑǓǕǗǙǛƎǞǠǢǤǦǨǪǬǮDZDZǴǸǺǼǾȀȂȄȆȈȊȌȎȐȒȔȖȘȚȜȞȢȤȦȨȪȬȮȰȲƁƆƉƊƏƐƓƔƗƖƜƝƟƦƩƮƱƲƷΙΆΈΉΊΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΣΤΥΦΧΨΩΪΫΌΎ!
8F;
92;ΘΦΠϚϜϞϠϢϤϦϨϪϬϮΚΡΣΕАБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯЀЁЂЃЄЅІЇЈЉЊЋЌЍЎЏѠѢѤѦѨѪѬѮѰѲѴѶѸѺѼѾҀҌҎҐҒҔҖҘҚҜҞҠҢҤҦҨҪҬҮҰҲҴҶҸҺҼҾӁӃӇӋӐӒӔӖӘӚӜӞӠӢӤӦӨӪӬӮӰӲӴӸԱԲԳԴԵԶԷԸԹԺԻԼԽԾԿՀՁՂՃՄՅՆՇՈՉՊՋՌՍՎՏՐՑՒՓՔՕՖḀḂḄḆḈḊḌḎḐḒḔḖḘḚḜḞḠḢḤḦḨḪḬḮḰḲḴḶḸḺḼḾṀṂṄṆṈṊṌṎṐṒṔṖṘṚṜṞṠṢṤṦṨṪṬṮṰṲṴṶṸṺṼṾẀẂẄẆẈẊẌẎẐẒẔṠẠẢẤẦẨẪẬ!
EAE;
EB0;ẲẴẶẸẺẼẾỀỂỄỆỈỊỌỎỐỒỔỖỘỚỜỞỠỢỤỦỨỪỬỮỰỲỴỶỸἈἉἊἋἌἍἎἏἘἙἚἛἜἝἨἩἪἫἬἭἮἯἸἹἺἻἼἽἾἿὈὉὊὋὌὍὙὛὝὟὨὩὪὫὬὭὮὯᾺΆῈΈῊΉῚΊῸΌῪΎῺΏᾈᾉᾊᾋᾌᾍᾎᾏᾘᾙᾚᾛᾜᾝᾞᾟᾨᾩᾪᾫᾬᾭᾮᾯᾸᾹᾼΙῌῘῙῨῩῬῼⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫⅬⅭⅮⅯⒶⒷⒸⒹⒺⒻⒼⒽⒾⒿⓀⓁⓂⓃⓄⓅⓆⓇⓈⓉⓊⓋⓌⓍⓎⓏABCDEFGHIJKLMNOPQRSTUVWXYZ𐐀𐐁𐐂𐐃𐐄𐐅𐐆𐐇𐐈𐐉𐐊𐐋𐐌𐐍𐐎𐐏𐐐𐐑𐐒𐐓𐐔𐐕𐐖𐐗𐐘𐐙𐐚𐐛𐐜𐐝𐐞𐐟𐐠𐐡𐐢𐐣𐐤𐐥'"/>
+ <xsl:variable name="xsltsl-str-digits" select="'0123456789'"/>
+ <!-- space (#x20) characters, carriage returns, line feeds, or tabs. -->
+ <xsl:variable name="xsltsl-str-ws" select="' 	
'"/>
+
+ <doc:template name="str:to-upper" xmlns="">
+ <refpurpose>Make string uppercase</refpurpose>
+
+ <refdescription>
+ <para>Converts all lowercase letters to uppercase.</para>
+ </refdescription>
+
+ <refparameter>
+ <variablelist>
+ <varlistentry>
+ <term>text</term>
+ <listitem>
+ <para>The string to be converted</para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refparameter>
+
+ <refreturn>
+ <para>Returns string with all uppercase letters.</para>
+ </refreturn>
+ </doc:template>
+
+ <xsl:template name="str:to-upper">
+ <xsl:param name="text"/>
+
+ <!-- Below exception is extracted from unicode's SpecialCasing.txt
+ file. It's the german lowercase "eszett" (the thing looking
+ like a greek beta) that's to become "SS" in uppercase (note:
+ that are *two* characters, that's why it doesn't fit in the
+ list of upper/lowercase characters). There are more
+ characters in that file (103, excluding the locale-specific
+ ones), but they seemed to be much less used to me and they
+ add up to a hellish long stylesheet.... - Reinout -->
+ <xsl:param name="modified-text">
+ <xsl:call-template name="str:subst">
+ <xsl:with-param name="text">
+ <xsl:value-of select="$text"/>
+ </xsl:with-param>
+ <xsl:with-param name="replace">
+ <xsl:text>ß</xsl:text>
+ </xsl:with-param>
+ <xsl:with-param name="with">
+ <xsl:text>S</xsl:text>
+ <xsl:text>S</xsl:text>
+ </xsl:with-param>
+ </xsl:call-template>
+ </xsl:param>
+
+ <xsl:value-of select="translate($modified-text, $xsltsl-str-lower, $xsltsl-str-upper)"/>
+ </xsl:template>
+
+ <doc:template name="str:to-lower" xmlns="">
+ <refpurpose>Make string lowercase</refpurpose>
+
+ <refdescription>
+ <para>Converts all uppercase letters to lowercase.</para>
+ </refdescription>
+
+ <refparameter>
+ <variablelist>
+ <varlistentry>
+ <term>text</term>
+ <listitem>
+ <para>The string to be converted</para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refparameter>
+
+ <refreturn>
+ <para>Returns string with all lowercase letters.</para>
+ </refreturn>
+ </doc:template>
+
+ <xsl:template name="str:to-lower">
+ <xsl:param name="text"/>
+
+ <xsl:value-of select="translate($text, $xsltsl-str-upper, $xsltsl-str-lower)"/>
+ </xsl:template>
+
+ <doc:template name="str:capitalise" xmlns="">
+ <refpurpose>Capitalise string</refpurpose>
+
+ <refdescription>
+ <para>Converts first character of string to an uppercase letter. All remaining characters are converted to lowercase.</para>
+ </refdescription>
+
+ <refparameter>
+ <variablelist>
+ <varlistentry>
+ <term>text</term>
+ <listitem>
+ <para>The string to be capitalised</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>all</term>
+ <listitem>
+ <para>Boolean controlling whether all words in the string are capitalised.</para>
+ <para>Default is true.</para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refparameter>
+
+ <refreturn>
+ <para>Returns string with first character uppcase and all remaining characters lowercase.</para>
+ </refreturn>
+ </doc:template>
+
+ <xsl:template name="str:capitalise">
+ <xsl:param name="text"/>
+ <xsl:param name="all" select="true()"/>
+
+ <xsl:choose>
+ <xsl:when test="$all and (contains($text, ' ') or contains($text, ' ') or contains($text, ' '))">
+ <xsl:variable name="firstword">
+ <xsl:call-template name="str:substring-before-first">
+ <xsl:with-param name="text" select="$text"/>
+ <xsl:with-param name="chars" select="$xsltsl-str-ws"/>
+ </xsl:call-template>
+ </xsl:variable>
+ <xsl:call-template name="str:capitalise">
+ <xsl:with-param name="text">
+ <xsl:value-of select="$firstword"/>
+ </xsl:with-param>
+ <xsl:with-param name="all" select="false()"/>
+ </xsl:call-template>
+ <xsl:value-of select="substring($text, string-length($firstword) + 1, 1)"/>
+ <xsl:call-template name="str:capitalise">
+ <xsl:with-param name="text">
+ <xsl:value-of select="substring($text, string-length($firstword) + 2)"/>
+ </xsl:with-param>
+ </xsl:call-template>
+ </xsl:when>
+
+ <xsl:otherwise>
+ <xsl:call-template name="str:to-upper">
+ <xsl:with-param name="text" select="substring($text, 1, 1)"/>
+ </xsl:call-template>
+ <xsl:call-template name="str:to-lower">
+ <xsl:with-param name="text" select="substring($text, 2)"/>
+ </xsl:call-template>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+ <doc:template name="str:to-camelcase" xmlns="">
+ <refpurpose>Convert a string to one camelcase word</refpurpose>
+
+ <refdescription>
+ <para>Converts a string to one lowerCamelCase or UpperCamelCase
+ word, depending on the setting of the "upper"
+ parameter. UpperCamelCase is also called MixedCase while
+ lowerCamelCase is also called just camelCase. The template
+ removes any spaces, tabs and slashes, but doesn't deal with
+ other punctuation. It's purpose is to convert strings like
+ "hollow timber flush door" to a term suitable as identifier or
+ XML tag like "HollowTimberFlushDoor".
+ </para>
+ </refdescription>
+
+ <refparameter>
+ <variablelist>
+ <varlistentry>
+ <term>text</term>
+ <listitem>
+ <para>The string to be capitalised</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>upper</term>
+ <listitem>
+ <para>Boolean controlling whether the string becomes an
+ UpperCamelCase word or a lowerCamelCase word.</para>
+ <para>Default is true.</para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refparameter>
+
+ <refreturn>
+ <para>Returns string with first character uppcase and all remaining characters lowercase.</para>
+ </refreturn>
+ </doc:template>
+
+ <xsl:template name="str:to-camelcase">
+ <xsl:param name="text"/>
+ <xsl:param name="upper" select="true()"/>
+ <!-- First change all 'strange' characters to spaces -->
+ <xsl:param name="string-with-only-spaces">
+ <xsl:value-of select="translate($text,concat($xsltsl-str-ws,'/'),' ')"/>
+ </xsl:param>
+ <!-- Then process them -->
+ <xsl:param name="before-space-removal">
+ <xsl:variable name="firstword">
+ <xsl:call-template name="str:substring-before-first">
+ <xsl:with-param name="text" select="$string-with-only-spaces"/>
+ <xsl:with-param name="chars" select="$xsltsl-str-ws"/>
+ </xsl:call-template>
+ </xsl:variable>
+ <xsl:choose>
+ <xsl:when test="$upper">
+ <xsl:call-template name="str:to-upper">
+ <xsl:with-param name="text" select="substring($firstword, 1, 1)"/>
+ </xsl:call-template>
+ <xsl:call-template name="str:to-lower">
+ <xsl:with-param name="text" select="substring($firstword, 2)"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:call-template name="str:to-lower">
+ <xsl:with-param name="text" select="$firstword"/>
+ </xsl:call-template>
+ </xsl:otherwise>
+ </xsl:choose>
+
+ <xsl:call-template name="str:capitalise">
+ <xsl:with-param name="text">
+ <xsl:value-of select="substring($string-with-only-spaces, string-length($firstword) + 2)"/>
+ </xsl:with-param>
+ <xsl:with-param name="all" select="true()"/>
+ </xsl:call-template>
+ </xsl:param>
+ <xsl:value-of select="translate($before-space-removal,' ','')"/>
+ </xsl:template>
+
+ <doc:template name="str:substring-before-first" xmlns="">
+ <refpurpose>String extraction</refpurpose>
+
+ <refdescription>
+ <para>Extracts the portion of string 'text' which occurs before any of the characters in string 'chars'.</para>
+ </refdescription>
+
+ <refparameter>
+ <variablelist>
+ <varlistentry>
+ <term>text</term>
+ <listitem>
+ <para>The string from which to extract a substring.</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>chars</term>
+ <listitem>
+ <para>The string containing characters to find.</para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refparameter>
+
+ <refreturn>
+ <para>Returns string.</para>
+ </refreturn>
+ </doc:template>
+
+ <xsl:template name="str:substring-before-first">
+ <xsl:param name="text"/>
+ <xsl:param name="chars"/>
+
+ <xsl:choose>
+
+ <xsl:when test="string-length($text) = 0"/>
+
+ <xsl:when test="string-length($chars) = 0">
+ <xsl:value-of select="$text"/>
+ </xsl:when>
+
+ <xsl:when test="contains($text, substring($chars, 1, 1))">
+ <xsl:variable name="this" select="substring-before($text, substring($chars, 1, 1))"/>
+ <xsl:variable name="rest">
+ <xsl:call-template name="str:substring-before-first">
+ <xsl:with-param name="text" select="$text"/>
+ <xsl:with-param name="chars" select="substring($chars, 2)"/>
+ </xsl:call-template>
+ </xsl:variable>
+
+ <xsl:choose>
+ <xsl:when test="string-length($this) < string-length($rest)">
+ <xsl:value-of select="$this"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$rest"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+
+ <xsl:otherwise>
+ <xsl:call-template name="str:substring-before-first">
+ <xsl:with-param name="text" select="$text"/>
+ <xsl:with-param name="chars" select="substring($chars, 2)"/>
+ </xsl:call-template>
+ </xsl:otherwise>
+
+ </xsl:choose>
+ </xsl:template>
+
+ <doc:template name="str:substring-after-last" xmlns="">
+ <refpurpose>String extraction</refpurpose>
+
+ <refdescription>
+ <para>Extracts the portion of string 'text' which occurs after the last of the character in string 'chars'.</para>
+ </refdescription>
+
+ <refparameter>
+ <variablelist>
+ <varlistentry>
+ <term>text</term>
+ <listitem>
+ <para>The string from which to extract a substring.</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>chars</term>
+ <listitem>
+ <para>The string containing characters to find.</para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refparameter>
+
+ <refreturn>
+ <para>Returns string.</para>
+ </refreturn>
+ </doc:template>
+
+ <xsl:template name="str:substring-after-last">
+ <xsl:param name="text"/>
+ <xsl:param name="chars"/>
+
+ <xsl:choose>
+
+ <xsl:when test="contains($text, $chars)">
+ <xsl:variable name="last" select="substring-after($text, $chars)"/>
+
+ <xsl:choose>
+ <xsl:when test="contains($last, $chars)">
+ <xsl:call-template name="str:substring-after-last">
+ <xsl:with-param name="text" select="$last"/>
+ <xsl:with-param name="chars" select="$chars"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$last"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+
+ <xsl:otherwise>
+ <xsl:value-of select="$text"/>
+ </xsl:otherwise>
+
+ </xsl:choose>
+ </xsl:template>
+
+ <doc:template name="str:substring-before-last" xmlns="">
+ <refpurpose>String extraction</refpurpose>
+
+ <refdescription>
+ <para>Extracts the portion of string 'text' which occurs before the first character of the last occurance of string 'chars'.</para>
+ </refdescription>
+
+ <refparameter>
+ <variablelist>
+ <varlistentry>
+ <term>text</term>
+ <listitem>
+ <para>The string from which to extract a substring.</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>chars</term>
+ <listitem>
+ <para>The string containing characters to find.</para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refparameter>
+
+ <refreturn>
+ <para>Returns string.</para>
+ </refreturn>
+ </doc:template>
+
+ <xsl:template name="str:substring-before-last">
+ <xsl:param name="text"/>
+ <xsl:param name="chars"/>
+
+ <xsl:choose>
+
+ <xsl:when test="string-length($text) = 0"/>
+
+ <xsl:when test="string-length($chars) = 0">
+ <xsl:value-of select="$text"/>
+ </xsl:when>
+
+ <xsl:when test="contains($text, $chars)">
+ <xsl:call-template name="str:substring-before-last-aux">
+ <xsl:with-param name="text" select="$text"/>
+ <xsl:with-param name="chars" select="$chars"/>
+ </xsl:call-template>
+ </xsl:when>
+
+ <xsl:otherwise>
+ <xsl:value-of select="$text"/>
+ </xsl:otherwise>
+
+ </xsl:choose>
+ </xsl:template>
+
+ <xsl:template name="str:substring-before-last-aux">
+ <xsl:param name="text"/>
+ <xsl:param name="chars"/>
+
+ <xsl:choose>
+ <xsl:when test="string-length($text) = 0"/>
+
+ <xsl:when test="contains($text, $chars)">
+ <xsl:variable name="after">
+ <xsl:call-template name="str:substring-before-last-aux">
+ <xsl:with-param name="text" select="substring-after($text, $chars)"/>
+ <xsl:with-param name="chars" select="$chars"/>
+ </xsl:call-template>
+ </xsl:variable>
+
+ <xsl:value-of select="substring-before($text, $chars)"/>
+ <xsl:if test="string-length($after) > 0">
+ <xsl:value-of select="$chars"/>
+ <xsl:copy-of select="$after"/>
+ </xsl:if>
+ </xsl:when>
+
+ <xsl:otherwise/>
+ </xsl:choose>
+ </xsl:template>
+
+ <doc:template name="str:subst" xmlns="">
+ <refpurpose>String substitution</refpurpose>
+
+ <refdescription>
+ <para>Substitute 'replace' for 'with' in string 'text'.</para>
+ </refdescription>
+
+ <refparameter>
+ <variablelist>
+ <varlistentry>
+ <term>text</term>
+ <listitem>
+ <para>The string upon which to perform substitution.</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>replace</term>
+ <listitem>
+ <para>The string to substitute.</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>with</term>
+ <listitem>
+ <para>The string to be substituted.</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>disable-output-escaping</term>
+ <listitem>
+ <para>A value of <literal>yes</literal> indicates that the result should have output escaping disabled. Any other value allows normal escaping of text values. The default is to enable output escaping.</para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refparameter>
+
+ <refreturn>
+ <para>Returns string.</para>
+ </refreturn>
+ </doc:template>
+
+ <xsl:template name="str:subst">
+ <xsl:param name="text"/>
+ <xsl:param name="replace"/>
+ <xsl:param name="with"/>
+ <xsl:param name='disable-output-escaping'>no</xsl:param>
+
+ <xsl:choose>
+ <xsl:when test="string-length($replace) = 0 and $disable-output-escaping = 'yes'">
+ <xsl:value-of select="$text" disable-output-escaping='yes'/>
+ </xsl:when>
+ <xsl:when test="string-length($replace) = 0">
+ <xsl:value-of select="$text"/>
+ </xsl:when>
+ <xsl:when test="contains($text, $replace)">
+
+ <xsl:variable name="before" select="substring-before($text, $replace)"/>
+ <xsl:variable name="after" select="substring-after($text, $replace)"/>
+
+ <xsl:choose>
+ <xsl:when test='$disable-output-escaping = "yes"'>
+ <xsl:value-of select="$before" disable-output-escaping="yes"/>
+ <xsl:value-of select="$with" disable-output-escaping="yes"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$before"/>
+ <xsl:value-of select="$with"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ <xsl:call-template name="str:subst">
+ <xsl:with-param name="text" select="$after"/>
+ <xsl:with-param name="replace" select="$replace"/>
+ <xsl:with-param name="with" select="$with"/>
+ <xsl:with-param name="disable-output-escaping" select="$disable-output-escaping"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:when test='$disable-output-escaping = "yes"'>
+ <xsl:value-of select="$text" disable-output-escaping="yes"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$text"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+ <doc:template name="str:count-substring" xmlns="">
+ <refpurpose>Count Substrings</refpurpose>
+
+ <refdescription>
+ <para>Counts the number of times a substring occurs in a string. This can also counts the number of times a character occurs in a string, since a character is simply a string of length 1.</para>
+ </refdescription>
+
+ <example>
+ <title>Counting Lines</title>
+ <programlisting><![CDATA[
+<xsl:call-template name="str:count-substring">
+ <xsl:with-param name="text" select="$mytext"/>
+ <xsl:with-param name="chars" select="'
'"/>
+</xsl:call-template>
+]]></programlisting>
+ </example>
+
+ <refparameter>
+ <variablelist>
+ <varlistentry>
+ <term>text</term>
+ <listitem>
+ <para>The source string.</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>chars</term>
+ <listitem>
+ <para>The substring to count.</para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refparameter>
+
+ <refreturn>
+ <para>Returns a non-negative integer value.</para>
+ </refreturn>
+ </doc:template>
+
+ <xsl:template name="str:count-substring">
+ <xsl:param name="text"/>
+ <xsl:param name="chars"/>
+
+ <xsl:choose>
+ <xsl:when test="string-length($text) = 0 or string-length($chars) = 0">
+ <xsl:text>0</xsl:text>
+ </xsl:when>
+ <xsl:when test="contains($text, $chars)">
+ <xsl:variable name="remaining">
+ <xsl:call-template name="str:count-substring">
+ <xsl:with-param name="text" select="substring-after($text, $chars)"/>
+ <xsl:with-param name="chars" select="$chars"/>
+ </xsl:call-template>
+ </xsl:variable>
+ <xsl:value-of select="$remaining + 1"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:text>0</xsl:text>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+ <doc:template name="str:substring-after-at" xmlns="">
+ <refpurpose>String extraction</refpurpose>
+ <refdescription>
+ <para>Extracts the portion of a 'char' delimited 'text' string "array" at a given 'position'.</para>
+ </refdescription>
+ <refparameter>
+ <variablelist>
+ <varlistentry>
+ <term>text</term>
+ <listitem>
+ <para>The string from which to extract a substring.</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>chars</term>
+ <listitem>
+ <para>delimiters</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>position</term>
+ <listitem>
+ <para>position of the elements</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>all</term>
+ <listitem>
+ <para>If true all of the remaining string is returned, otherwise only the element at the given position is returned. Default: false().</para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refparameter>
+ <refreturn>
+ <para>Returns string.</para>
+ </refreturn>
+ </doc:template>
+
+
+ <xsl:template name="str:substring-after-at">
+ <xsl:param name="text"/>
+ <xsl:param name="chars"/>
+ <xsl:param name="position"/>
+ <xsl:param name="all" select='false()'/>
+
+ <xsl:choose>
+ <xsl:when test='number($position) = 0 and $all'>
+ <xsl:value-of select='$text'/>
+ </xsl:when>
+ <xsl:when test='number($position) = 0 and not($chars)'>
+ <xsl:value-of select='$text'/>
+ </xsl:when>
+ <xsl:when test='number($position) = 0 and not(contains($text, $chars))'>
+ <xsl:value-of select='$text'/>
+ </xsl:when>
+ <xsl:when test='not(contains($text, $chars))'>
+ </xsl:when>
+ <xsl:when test="number($position) = 0">
+ <xsl:value-of select="substring-before($text, $chars)"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:call-template name="str:substring-after-at">
+ <xsl:with-param name="text" select="substring-after($text, $chars)"/>
+ <xsl:with-param name="chars" select="$chars"/>
+ <xsl:with-param name="all" select="$all"/>
+ <xsl:with-param name="position" select="$position - 1"/>
+ </xsl:call-template>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+ <doc:template name="str:substring-before-at" xmlns="">
+ <refpurpose>String extraction</refpurpose>
+ <refdescription>
+ <para>Extracts the portion of a 'char' delimited 'text' string "array" at a given 'position' </para>
+ </refdescription>
+ <refparameter>
+ <variablelist>
+ <varlistentry>
+ <term>text</term>
+ <listitem>
+ <para>The string from which to extract a substring.</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>chars</term>
+ <listitem>
+ <para>delimiters</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>position</term>
+ <listitem>
+ <para>position of the elements</para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refparameter>
+ <refreturn>
+ <para>Returns string.</para>
+ </refreturn>
+ </doc:template>
+
+ <xsl:template name="str:substring-before-at">
+ <xsl:param name="text"/>
+ <xsl:param name="chars"/>
+ <xsl:param name="position"/>
+
+ <xsl:choose>
+ <xsl:when test="$position <= 0"/>
+ <xsl:when test="not(contains($text, $chars))"/>
+ <xsl:otherwise>
+ <xsl:value-of select='substring-before($text, $chars)'/>
+ <xsl:value-of select='$chars'/>
+
+ <xsl:call-template name="str:substring-before-at">
+ <xsl:with-param name="text" select="substring-after($text, $chars)"/>
+ <xsl:with-param name="position" select="$position - 1"/>
+ <xsl:with-param name="chars" select="$chars"/>
+ </xsl:call-template>
+
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+ <doc:template name="str:insert-at" xmlns="">
+ <refpurpose>String insertion</refpurpose>
+ <refdescription>
+ <para>Insert 'chars' into "text' at any given "position'</para>
+ </refdescription>
+ <refparameter>
+ <variablelist>
+ <varlistentry>
+ <term>text</term>
+ <listitem>
+ <para>The string upon which to perform insertion</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>position</term>
+ <listitem>
+ <para>the position where insertion will be performed</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>with</term>
+ <listitem>
+ <para>The string to be inserted</para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refparameter>
+ <refreturn>
+ <para>Returns string.</para>
+ </refreturn>
+ </doc:template>
+
+ <xsl:template name="str:insert-at">
+ <xsl:param name="text"/>
+ <xsl:param name="position"/>
+ <xsl:param name="chars"/>
+
+ <xsl:variable name="firstpart" select="substring($text, 0, $position)"/>
+ <xsl:variable name="secondpart" select="substring($text, $position, string-length($text))"/>
+
+ <xsl:value-of select="concat($firstpart, $chars, $secondpart)"/>
+ </xsl:template>
+
+
+ <doc:template name="str:backward" xmlns="">
+ <refpurpose>String reversal</refpurpose>
+
+ <refdescription>
+ <para>Reverse the content of a given string</para>
+ </refdescription>
+
+ <refparameter>
+ <variablelist>
+ <varlistentry>
+ <term>text</term>
+ <listitem>
+ <para>The string to be reversed</para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refparameter>
+
+ <refreturn>
+ <para>Returns string.</para>
+ </refreturn>
+ </doc:template>
+
+ <xsl:template name="str:backward">
+ <xsl:param name="text"/>
+ <xsl:variable name="mirror">
+ <xsl:call-template name="str:build-mirror">
+ <xsl:with-param name="text" select="$text"/>
+ <xsl:with-param name="position" select="string-length($text)"/>
+ </xsl:call-template>
+ </xsl:variable>
+ <xsl:value-of select="substring($mirror, string-length($text) + 1, string-length($text))"/>
+ </xsl:template>
+
+ <xsl:template name="str:build-mirror">
+ <xsl:param name="text"/>
+ <xsl:param name="position"/>
+
+ <xsl:choose>
+ <xsl:when test="$position > 0">
+ <xsl:call-template name="str:build-mirror">
+ <xsl:with-param name="text" select="concat($text, substring($text, $position, 1))"/>
+ <xsl:with-param name="position" select="$position - 1"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$text"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+ <doc:template name="str:justify" xmlns="">
+ <refpurpose>Format a string</refpurpose>
+
+ <refdescription>
+ <para>Inserts newlines and spaces into a string to format it as a block of text.</para>
+ </refdescription>
+
+ <refparameter>
+ <variablelist>
+ <varlistentry>
+ <term>text</term>
+ <listitem>
+ <para>String to be formatted.</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>max</term>
+ <listitem>
+ <para>Maximum line length.</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>indent</term>
+ <listitem>
+ <para>Number of spaces to insert at the beginning of each line.</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>justify</term>
+ <listitem>
+ <para>Justify left, right or both. Not currently implemented (fixed at "left").</para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refparameter>
+
+ <refreturn>
+ <para>Formatted block of text.</para>
+ </refreturn>
+ </doc:template>
+
+ <xsl:template name='str:justify'>
+ <xsl:param name='text'/>
+ <xsl:param name='max' select='"80"'/>
+ <xsl:param name='indent' select='"0"'/>
+ <xsl:param name='justify' select='"left"'/>
+
+ <xsl:choose>
+ <xsl:when test='string-length($text) = 0 or $max <= 0'/>
+
+ <xsl:when test='string-length($text) > $max and contains($text, " ") and string-length(substring-before($text, " ")) > $max'>
+ <xsl:call-template name='str:generate-string'>
+ <xsl:with-param name='text' select='" "'/>
+ <xsl:with-param name='count' select='$indent'/>
+ </xsl:call-template>
+ <xsl:value-of select='substring-before($text, " ")'/>
+ <xsl:text>
+</xsl:text>
+ <xsl:call-template name='str:justify'>
+ <xsl:with-param name='text' select='substring-after($text, " ")'/>
+ <xsl:with-param name='max' select='$max'/>
+ <xsl:with-param name='indent' select='$indent'/>
+ <xsl:with-param name='justify' select='$justify'/>
+ </xsl:call-template>
+ </xsl:when>
+
+ <xsl:when test='string-length($text) > $max and contains($text, " ")'>
+ <xsl:variable name='first'>
+ <xsl:call-template name='str:substring-before-last'>
+ <xsl:with-param name='text' select='substring($text, 1, $max)'/>
+ <xsl:with-param name='chars' select='" "'/>
+ </xsl:call-template>
+ </xsl:variable>
+
+ <xsl:call-template name='str:generate-string'>
+ <xsl:with-param name='text' select='" "'/>
+ <xsl:with-param name='count' select='$indent'/>
+ </xsl:call-template>
+ <xsl:value-of select='$first'/>
+ <xsl:text>
+</xsl:text>
+ <xsl:call-template name='str:justify'>
+ <xsl:with-param name='text' select='substring($text, string-length($first) + 2)'/>
+ <xsl:with-param name='max' select='$max'/>
+ <xsl:with-param name='indent' select='$indent'/>
+ <xsl:with-param name='justify' select='$justify'/>
+ </xsl:call-template>
+ </xsl:when>
+
+ <xsl:otherwise>
+ <xsl:call-template name='str:generate-string'>
+ <xsl:with-param name='text' select='" "'/>
+ <xsl:with-param name='count' select='$indent'/>
+ </xsl:call-template>
+ <xsl:value-of select='$text'/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+ <doc:template name="str:character-first" xmlns="">
+ <refpurpose>Find first occurring character in a string</refpurpose>
+
+ <refdescription>
+ <para>Finds which of the given characters occurs first in a string.</para>
+ </refdescription>
+
+ <refparameter>
+ <variablelist>
+ <varlistentry>
+ <term>text</term>
+ <listitem>
+ <para>The source string.</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>chars</term>
+ <listitem>
+ <para>The characters to search for.</para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refparameter>
+ </doc:template>
+
+ <xsl:template name="str:character-first">
+ <xsl:param name="text"/>
+ <xsl:param name="chars"/>
+
+ <xsl:choose>
+ <xsl:when test="string-length($text) = 0 or string-length($chars) = 0"/>
+
+ <xsl:when test="contains($text, substring($chars, 1, 1))">
+ <xsl:variable name="next-character">
+ <xsl:call-template name="str:character-first">
+ <xsl:with-param name="text" select="$text"/>
+ <xsl:with-param name="chars" select="substring($chars, 2)"/>
+ </xsl:call-template>
+ </xsl:variable>
+
+ <xsl:choose>
+ <xsl:when test="string-length($next-character)">
+ <xsl:variable name="first-character-position" select="string-length(substring-before($text, substring($chars, 1, 1)))"/>
+ <xsl:variable name="next-character-position" select="string-length(substring-before($text, $next-character))"/>
+
+ <xsl:choose>
+ <xsl:when test="$first-character-position < $next-character-position">
+ <xsl:value-of select="substring($chars, 1, 1)"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$next-character"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="substring($chars, 1, 1)"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:call-template name="str:character-first">
+ <xsl:with-param name="text" select="$text"/>
+ <xsl:with-param name="chars" select="substring($chars, 2)"/>
+ </xsl:call-template>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+ <doc:template name="str:string-match" xmlns="">
+ <refpurpose>Match A String To A Pattern</refpurpose>
+
+ <refdescription>
+ <para>Performs globbing-style pattern matching on a string.</para>
+ </refdescription>
+
+ <example>
+ <title>Match Pattern</title>
+ <programlisting><![CDATA[
+<xsl:call-template name="str:string-match">
+ <xsl:with-param name="text" select="$mytext"/>
+ <xsl:with-param name="pattern" select="'abc*def?g'"/>
+</xsl:call-template>
+]]></programlisting>
+ </example>
+
+ <refparameter>
+ <variablelist>
+ <varlistentry>
+ <term>text</term>
+ <listitem>
+ <para>The source string.</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>pattern</term>
+ <listitem>
+ <para>The pattern to match against. Certain characters have special meaning:</para>
+ <variablelist>
+ <varlistentry>
+ <term>*</term>
+ <listitem>
+ <para>Matches zero or more characters.</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>?</term>
+ <listitem>
+ <para>Matches a single character.</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>\</term>
+ <listitem>
+ <para>Character escape. The next character is taken as a literal character.</para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refparameter>
+
+ <refreturn>
+ <para>Returns "1" if the string matches the pattern, "0" otherwise.</para>
+ </refreturn>
+ </doc:template>
+
+ <xsl:template name="str:string-match">
+ <xsl:param name="text"/>
+ <xsl:param name="pattern"/>
+
+ <xsl:choose>
+ <xsl:when test="$pattern = '*'">
+ <!-- Special case: always matches -->
+ <xsl:text>1</xsl:text>
+ </xsl:when>
+ <xsl:when test="string-length($text) = 0 and string-length($pattern) = 0">
+ <xsl:text>1</xsl:text>
+ </xsl:when>
+ <xsl:when test="string-length($text) = 0 or string-length($pattern) = 0">
+ <xsl:text>0</xsl:text>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:variable name='before-special'>
+ <xsl:call-template name='str:substring-before-first'>
+ <xsl:with-param name='text' select='$pattern'/>
+ <xsl:with-param name='chars' select='"*?\"'/>
+ </xsl:call-template>
+ </xsl:variable>
+ <xsl:variable name='special'>
+ <xsl:call-template name='str:character-first'>
+ <xsl:with-param name='text' select='$pattern'/>
+ <xsl:with-param name='chars' select='"*?\"'/>
+ </xsl:call-template>
+ </xsl:variable>
+
+ <xsl:variable name='new-text' select='substring($text, string-length($before-special) + 1)'/>
+ <xsl:variable name='new-pattern' select='substring($pattern, string-length($before-special) + 1)'/>
+
+ <xsl:choose>
+ <xsl:when test="not(starts-with($text, $before-special))">
+ <!-- Verbatim characters don't match -->
+ <xsl:text>0</xsl:text>
+ </xsl:when>
+
+ <xsl:when test="$special = '*' and string-length($new-pattern) = 1">
+ <xsl:text>1</xsl:text>
+ </xsl:when>
+ <xsl:when test="$special = '*'">
+ <xsl:call-template name='str:match-postfix'>
+ <xsl:with-param name='text' select='$new-text'/>
+ <xsl:with-param name='pattern' select='substring($new-pattern, 2)'/>
+ </xsl:call-template>
+ </xsl:when>
+
+ <xsl:when test="$special = '?'">
+ <xsl:call-template name="str:string-match">
+ <xsl:with-param name='text' select='substring($new-text, 2)'/>
+ <xsl:with-param name='pattern' select='substring($new-pattern, 2)'/>
+ </xsl:call-template>
+ </xsl:when>
+
+ <xsl:when test="$special = '\' and substring($new-text, 1, 1) = substring($new-pattern, 2, 1)">
+ <xsl:call-template name="str:string-match">
+ <xsl:with-param name='text' select='substring($new-text, 2)'/>
+ <xsl:with-param name='pattern' select='substring($new-pattern, 3)'/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:when test="$special = '\' and substring($new-text, 1, 1) != substring($new-pattern, 2, 1)">
+ <xsl:text>0</xsl:text>
+ </xsl:when>
+
+ <xsl:otherwise>
+ <!-- There were no special characters in the pattern -->
+ <xsl:choose>
+ <xsl:when test='$text = $pattern'>
+ <xsl:text>1</xsl:text>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:text>0</xsl:text>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+ <xsl:template name="str:match-postfix">
+ <xsl:param name="text"/>
+ <xsl:param name="pattern"/>
+
+ <xsl:variable name='result'>
+ <xsl:call-template name='str:string-match'>
+ <xsl:with-param name='text' select='$text'/>
+ <xsl:with-param name='pattern' select='$pattern'/>
+ </xsl:call-template>
+ </xsl:variable>
+
+ <xsl:choose>
+ <xsl:when test='$result = "1"'>
+ <xsl:value-of select='$result'/>
+ </xsl:when>
+ <xsl:when test='string-length($text) = 0'>
+ <xsl:text>0</xsl:text>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:call-template name='str:match-postfix'>
+ <xsl:with-param name='text' select='substring($text, 2)'/>
+ <xsl:with-param name='pattern' select='$pattern'/>
+ </xsl:call-template>
+ </xsl:otherwise>
+ </xsl:choose>
+
+ </xsl:template>
+
+ <doc:template name="str:generate-string" xmlns="">
+ <refpurpose>Create A Repeating Sequence of Characters</refpurpose>
+
+ <refdescription>
+ <para>Repeats a string a given number of times.</para>
+ </refdescription>
+
+ <refparameter>
+ <variablelist>
+ <varlistentry>
+ <term>text</term>
+ <listitem>
+ <para>The string to repeat.</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>count</term>
+ <listitem>
+ <para>The number of times to repeat the string.</para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refparameter>
+ </doc:template>
+
+ <xsl:template name="str:generate-string">
+ <xsl:param name="text"/>
+ <xsl:param name="count"/>
+
+ <xsl:choose>
+ <xsl:when test="string-length($text) = 0 or $count <= 0"/>
+ <xsl:otherwise>
+ <xsl:value-of select="$text"/>
+ <xsl:call-template name="str:generate-string">
+ <xsl:with-param name="text" select="$text"/>
+ <xsl:with-param name="count" select="$count - 1"/>
+ </xsl:call-template>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+</xsl:stylesheet>
+
Added: gnucash/trunk/src/optional/xsl/vcard-gnccustomer.pl
===================================================================
--- gnucash/trunk/src/optional/xsl/vcard-gnccustomer.pl 2006-03-09 16:50:39 UTC (rev 13565)
+++ gnucash/trunk/src/optional/xsl/vcard-gnccustomer.pl 2006-03-09 16:54:44 UTC (rev 13566)
@@ -0,0 +1,103 @@
+#!/usr/bin/perl -w
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+use Text::vCard::Addressbook;
+use strict;
+use vars qw($address_book $hex_string $num $c $d $e $i $vcard $names $name $fullname $email $address $addresses $phones $phone $filename $usage $encoding);
+
+############### USER CONFIGURATION ####################
+# Change to the encoding for you locale if your VCF data
+# contains accented characters etc.
+ $encoding = 'UTF-8';
+############### END CONFIGURATION ####################
+
+# About
+#
+# This is a very simple file and should be simple to customise.
+# A similar file is included in pilot-qof. Currently, the script
+# needs to be told where to find the VCF file to transform and
+# expects the user to redirect output to a file:
+# $ perl vcard-gnccustomer.pl contact.vcf > contact.xml
+
+ $usage = $#ARGV + 1;
+ if($usage < 1)
+ {
+ print ("Error: please specify a .vcf file.\n\n");
+ exit;
+ }
+ $filename = $ARGV[0];
+ $address_book = Text::vCard::Addressbook->new({
+ 'source_file' => $filename, });
+ # generate a temporary GUID to relate the address to the customer
+ $hex_string = '';
+ for($d = 1;$d < 5;$d++)
+ {
+ for($c = 1; $c < 8; $c++)
+ {
+ $num = (int(rand(99)) + 1) * 10**$c;
+ }
+ $hex_string .= sprintf("%x", $num);
+ }
+ print "<?xml version=\"1.0\" encoding=\"$encoding\"?>\n";
+ print "<qof-qsf xmlns=\"http://qof.sourceforge.net/\">\n";
+ print " <book count=\"1\">\n";
+ print " <book-guid/>\n";
+ print " <object type=\"gncAddress\" count=\"1\">\n";
+ foreach $vcard ($address_book->vcards()) {
+ $names = $vcard->get({ 'node_type' => 'name' });
+ foreach $name (@{$names}){
+ if($name->given()) {
+ $fullname = $name->given() . " " . $name->family();
+ }
+ else {
+ $fullname = $name->family();
+ }
+ &wrap_in_qsf($fullname, "name");
+ }
+ $phones = $vcard->get('tel');
+ $i = 0;
+ foreach $phone (@{$phones}){
+ if($i == 0) {
+ &wrap_in_qsf($phone->value(), "phone");
+ }
+ if($i == 1) {
+ &wrap_in_qsf($phone->value(), "fax");
+ }
+ $i++;
+ }
+ $email = $vcard->get('email');
+ foreach $e (@{$email}){ &wrap_in_qsf($e->value(), "email"); }
+ $addresses = $vcard->get({ 'node_type' => 'addresses' });
+ foreach $address (@{$addresses}) {
+ &wrap_in_qsf($address->street(), "street");
+ &wrap_in_qsf($address->city(), "city");
+ &wrap_in_qsf($address->region(), "locality");
+ }
+ print " <guid type=\"guid\">$hex_string</guid>\n";
+ }
+ print " </object>\n";
+ print " <object type=\"gncCustomer\" count=\"1\">\n";
+ &wrap_in_qsf($fullname, "name");
+ print " <boolean type=\"active\">true</boolean\n";
+ print " <guid type=\"addr\">$hex_string</guid>\n";
+ print " </book>\n";
+ print "</qof-qsf>\n\n";
+
+sub wrap_in_qsf()
+{
+ if($_[0]) { print " <string type=\"$_[1]\">$_[0]</string>\n"; }
+ else { print " <string type=\"$_[1]\"/>\n"; }
+};
Property changes on: gnucash/trunk/src/optional/xsl/vcard-gnccustomer.pl
___________________________________________________________________
Name: svn:executable
+ *
More information about the gnucash-changes
mailing list