r15621 - in /branches/upstream/libxml-writer-perl/current: ./ examples/
rmayorga-guest at users.alioth.debian.org
rmayorga-guest at users.alioth.debian.org
Tue Feb 26 05:27:19 UTC 2008
Author: rmayorga-guest
Date: Tue Feb 26 05:27:07 2008
New Revision: 15621
URL: http://svn.debian.org/wsvn/?sc=1&rev=15621
Log:
[svn-upgrade] Integrating new upstream version, libxml-writer-perl (0.604)
Added:
branches/upstream/libxml-writer-perl/current/examples/
branches/upstream/libxml-writer-perl/current/examples/data-mode-sample.pl (with props)
branches/upstream/libxml-writer-perl/current/examples/directory-as-atom.pl (with props)
branches/upstream/libxml-writer-perl/current/examples/double-escaping-example.pl (with props)
branches/upstream/libxml-writer-perl/current/examples/namespace-prefixes.pl (with props)
branches/upstream/libxml-writer-perl/current/examples/simple-xml.pl (with props)
branches/upstream/libxml-writer-perl/current/examples/writing-unicode.pl (with props)
branches/upstream/libxml-writer-perl/current/examples/xml-writer-string.pl (with props)
Modified:
branches/upstream/libxml-writer-perl/current/Changes
branches/upstream/libxml-writer-perl/current/MANIFEST
branches/upstream/libxml-writer-perl/current/META.yml
branches/upstream/libxml-writer-perl/current/Makefile.PL
branches/upstream/libxml-writer-perl/current/Writer.pm
Modified: branches/upstream/libxml-writer-perl/current/Changes
URL: http://svn.debian.org/wsvn/branches/upstream/libxml-writer-perl/current/Changes?rev=15621&op=diff
==============================================================================
--- branches/upstream/libxml-writer-perl/current/Changes (original)
+++ branches/upstream/libxml-writer-perl/current/Changes Tue Feb 26 05:27:07 2008
@@ -1,4 +1,8 @@
Revision history for Perl extension XML::Writer.
+
+0.604 Thu Feb 21 00:42:06 GMT 2008 <joe at kafsemo.org>
+ - Patch from Andreas Koenig for lc(undef) warning in 5.11 (#32874).
+ - Include example code.
0.603 Mon Jun 25 22:31:40 BST 2007 <joe at kafsemo.org>
- Escape all necessary white space in attributes (#25499).
Modified: branches/upstream/libxml-writer-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/branches/upstream/libxml-writer-perl/current/MANIFEST?rev=15621&op=diff
==============================================================================
--- branches/upstream/libxml-writer-perl/current/MANIFEST (original)
+++ branches/upstream/libxml-writer-perl/current/MANIFEST Tue Feb 26 05:27:07 2008
@@ -8,3 +8,10 @@
t/pod.t
t/pod-coverage.t
TODO
+examples/simple-xml.pl
+examples/double-escaping-example.pl
+examples/namespace-prefixes.pl
+examples/xml-writer-string.pl
+examples/data-mode-sample.pl
+examples/writing-unicode.pl
+examples/directory-as-atom.pl
Modified: branches/upstream/libxml-writer-perl/current/META.yml
URL: http://svn.debian.org/wsvn/branches/upstream/libxml-writer-perl/current/META.yml?rev=15621&op=diff
==============================================================================
--- branches/upstream/libxml-writer-perl/current/META.yml (original)
+++ branches/upstream/libxml-writer-perl/current/META.yml Tue Feb 26 05:27:07 2008
@@ -3,7 +3,7 @@
version: 1.2
url: http://module-build.sourceforge.net/META-spec-v1.2.html
name: XML-Writer
-version: 0.603
+version: 0.604
abstract: Easily generate well-formed, namespace-aware XML.
author:
- David Megginson <david at megginson.com>
Modified: branches/upstream/libxml-writer-perl/current/Makefile.PL
URL: http://svn.debian.org/wsvn/branches/upstream/libxml-writer-perl/current/Makefile.PL?rev=15621&op=diff
==============================================================================
--- branches/upstream/libxml-writer-perl/current/Makefile.PL (original)
+++ branches/upstream/libxml-writer-perl/current/Makefile.PL Tue Feb 26 05:27:07 2008
@@ -7,7 +7,7 @@
# the contents of the Makefile that is written.
WriteMakefile(
'NAME' => 'XML::Writer',
- 'VERSION' => '0.603',
+ 'VERSION' => '0.604',
# A manually-created META.yml has all the other metadata;
# we don't want it overwritten
Modified: branches/upstream/libxml-writer-perl/current/Writer.pm
URL: http://svn.debian.org/wsvn/branches/upstream/libxml-writer-perl/current/Writer.pm?rev=15621&op=diff
==============================================================================
--- branches/upstream/libxml-writer-perl/current/Writer.pm (original)
+++ branches/upstream/libxml-writer-perl/current/Writer.pm Tue Feb 26 05:27:07 2008
@@ -4,7 +4,7 @@
# Copyright (c) 2004, 2005 by Joseph Walton <joe at kafsemo.org>.
# No warranty. Commercial and non-commercial use freely permitted.
#
-# $Id: Writer.pm 178 2007-06-25 21:35:24Z josephw $
+# $Id: Writer.pm 185 2008-02-21 00:51:34Z josephw $
########################################################################
package XML::Writer;
@@ -15,7 +15,7 @@
use vars qw($VERSION);
use Carp;
use IO::Handle;
-$VERSION = "0.603";
+$VERSION = "0.604";
@@ -58,7 +58,7 @@
$nl = "\n";
}
- my $outputEncoding = $params{ENCODING};
+ my $outputEncoding = $params{ENCODING} || "";
my ($checkUnencodedRepertoire, $escapeEncoding);
if (lc($outputEncoding) eq 'us-ascii') {
$checkUnencodedRepertoire = \&_croakUnlessASCII;
Added: branches/upstream/libxml-writer-perl/current/examples/data-mode-sample.pl
URL: http://svn.debian.org/wsvn/branches/upstream/libxml-writer-perl/current/examples/data-mode-sample.pl?rev=15621&op=file
==============================================================================
--- branches/upstream/libxml-writer-perl/current/examples/data-mode-sample.pl (added)
+++ branches/upstream/libxml-writer-perl/current/examples/data-mode-sample.pl Tue Feb 26 05:27:07 2008
@@ -1,0 +1,21 @@
+#!/usr/bin/perl -w
+
+# Use DATA_MODE and DATA_INDENT to make data documents easier to read
+
+use strict;
+
+use XML::Writer;
+use IO::File;
+
+my $writer = new XML::Writer(DATA_MODE => 1, DATA_INDENT => 2);
+$writer->startTag("doc");
+$writer->startTag("x");
+$writer->dataElement("y", "Hello, world!");
+$writer->dataElement("y", "Hello, world!");
+$writer->endTag("x");
+$writer->startTag("x");
+$writer->dataElement("y", "Hello, world!");
+$writer->dataElement("y", "Hello, world!");
+$writer->endTag("x");
+$writer->endTag("doc");
+$writer->end();
Propchange: branches/upstream/libxml-writer-perl/current/examples/data-mode-sample.pl
------------------------------------------------------------------------------
svn:executable = *
Added: branches/upstream/libxml-writer-perl/current/examples/directory-as-atom.pl
URL: http://svn.debian.org/wsvn/branches/upstream/libxml-writer-perl/current/examples/directory-as-atom.pl?rev=15621&op=file
==============================================================================
--- branches/upstream/libxml-writer-perl/current/examples/directory-as-atom.pl (added)
+++ branches/upstream/libxml-writer-perl/current/examples/directory-as-atom.pl Tue Feb 26 05:27:07 2008
@@ -1,0 +1,148 @@
+#!/usr/bin/perl -w
+
+# A full example that presents a directory as an Atom feed
+# It demonstrates namespace and formatting control.
+# Intended to productise the /junk convention.
+
+# Usage: directory-as-atom.pl <local directory> <public URL> [feed title] [feed subtitle]
+
+# e.g., directory-as-atom.pl /home/user/public_html/junk http://www.example.com/~user/junk/ >index.atom
+
+use strict;
+
+use DirHandle;
+use URI::URL;
+use DateTime;
+
+use XML::Writer;
+
+my ($dir, $base, $title, $subtitle) = @ARGV;
+
+defined($base) or die "Usage: directory-as-atom.pl <local directory> <public URL> [feed title] [feed subtitle]";
+
+$dir ||= '.';
+
+$title ||= '/junk/';
+$subtitle ||= 'ls -ltr $dir | head -10';
+
+
+my $uid = (stat($dir))[4];
+
+my $dh = new DirHandle($dir) || die "Unable to opendir $dir: $!";
+
+my @de;
+
+while(my $e = $dh->read()) {
+ # Skip dotfiles
+ next if ($e =~ /^\./);
+
+ my $n = "$dir/$e";
+
+ next unless (-f $n);
+
+ my ($mtime, $bytes) = (stat($n))[9,7];
+
+ my $desc; # undef, for now
+
+ if (defined($mtime)) {push(@de, [$e, $mtime, $desc, $bytes])};
+}
+
+undef($dh);
+
+# Sort into reverse date order...
+ at de = sort {
+ $b->[1] <=> $a->[1];
+} @de;
+
+# ...take the most recent ten
+if (@de > 10) {
+ @de = @de[0..9];
+}
+
+# Constants for the namespace URIs
+my $ATOM = 'http://www.w3.org/2005/Atom';
+my $HTML = 'http://www.w3.org/1999/xhtml';
+my $XML = 'http://www.w3.org/XML/1998/namespace';
+
+sub toIsoDate($)
+{
+ my $t = shift;
+
+ my $d = DateTime->from_epoch(epoch => $t);
+ $d->set_time_zone('UTC');
+
+ return $d->iso8601 . "Z";
+}
+
+my $w = new XML::Writer(
+ # Use namespaces
+ NAMESPACES => 1,
+
+ # Write in data mode, with indentation
+ DATA_MODE => 1, DATA_INDENT => 1,
+
+ # Use specific namespace prefixes
+ PREFIX_MAP => {$ATOM => '', $HTML => 'html'},
+
+ # Force an xmlns:html declaration on the root element
+ FORCED_NS_DECLS => [$HTML],
+
+ # Encode text as UTF-8
+ ENCODING => 'utf-8'
+);
+
+$base = new URI::URL($base)->abs;
+
+my $feedUrl = new URI::URL('index.atom', $base);
+
+$w->xmlDecl();
+
+# Start the root element with an xml:base declaration
+$w->startTag([$ATOM, 'feed'], [$XML, 'base'] => $base);
+
+$w->dataElement([$ATOM, 'id'], $feedUrl->abs);
+
+# Mandatory Atom feed elements
+$w->dataElement([$ATOM, 'title'], $title);
+$w->dataElement([$ATOM, 'subtitle'], $subtitle);
+$w->dataElement('generator', 'Old-skool directory-based CMS');
+$w->emptyTag('link', 'rel' => 'self', 'href' => $feedUrl) if $feedUrl;
+$w->dataElement([$ATOM, 'updated'] => toIsoDate(time));
+
+# Find out the directory owner's name
+if (my ($name) = (getpwuid($uid))[0]) {
+ $w->startTag([$ATOM, 'author']);
+ $w->dataElement([$ATOM, 'name'], $name);
+ $w->endTag([$ATOM, 'author']);
+}
+
+# Write an entry for each file
+foreach (@de) {
+ my ($n, $mtime, $desc, $bytes) = @{$_};
+
+ my $url = url($n, $base)->abs->as_string;
+
+ $w->startTag([$ATOM, 'entry']);
+
+ $w->dataElement([$ATOM, 'title'], $n);
+ $w->dataElement([$ATOM, 'id'], $url);
+ $w->emptyTag([$ATOM, 'link'], 'href' => $n);
+ $w->dataElement([$ATOM, 'updated'], toIsoDate($mtime));
+
+ # Write atom:content as XHTML; turn off data mode
+ # to control whitespace inside the html:div element
+ $w->startTag([$ATOM, 'content'], 'type' => 'xhtml');
+ $w->startTag([$HTML, 'div']);
+ $w->setDataMode(0);
+ $w->dataElement([$HTML, 'code'], $n);
+ $w->characters(" - ${bytes} bytes");
+ $w->characters(" - ${desc}") if $desc;
+ $w->setDataMode(1);
+ $w->endTag([$HTML, 'div']);
+ $w->endTag([$ATOM, 'content']);
+
+ $w->endTag([$ATOM, 'entry']);
+}
+
+$w->endTag([$ATOM, 'feed']);
+$w->end();
Propchange: branches/upstream/libxml-writer-perl/current/examples/directory-as-atom.pl
------------------------------------------------------------------------------
svn:executable = *
Added: branches/upstream/libxml-writer-perl/current/examples/double-escaping-example.pl
URL: http://svn.debian.org/wsvn/branches/upstream/libxml-writer-perl/current/examples/double-escaping-example.pl?rev=15621&op=file
==============================================================================
--- branches/upstream/libxml-writer-perl/current/examples/double-escaping-example.pl (added)
+++ branches/upstream/libxml-writer-perl/current/examples/double-escaping-example.pl Tue Feb 26 05:27:07 2008
@@ -1,0 +1,17 @@
+#!/usr/bin/perl -w
+
+# Demonstrate that ampersands are double-escaped
+
+# Even if your text looks like already-escaped XML, it will be escaped
+# again to make sure that the same text arrives at the other end.
+
+use strict;
+
+use XML::Writer;
+
+my $w = new XML::Writer();
+
+$w->startTag('doc');
+$w->characters('In HTML and XML, an ampersand must be escaped as &');
+$w->endTag('doc');
+$w->end();
Propchange: branches/upstream/libxml-writer-perl/current/examples/double-escaping-example.pl
------------------------------------------------------------------------------
svn:executable = *
Added: branches/upstream/libxml-writer-perl/current/examples/namespace-prefixes.pl
URL: http://svn.debian.org/wsvn/branches/upstream/libxml-writer-perl/current/examples/namespace-prefixes.pl?rev=15621&op=file
==============================================================================
--- branches/upstream/libxml-writer-perl/current/examples/namespace-prefixes.pl (added)
+++ branches/upstream/libxml-writer-perl/current/examples/namespace-prefixes.pl Tue Feb 26 05:27:07 2008
@@ -1,0 +1,52 @@
+#!/usr/bin/perl -w
+
+# A skeleton Atom document with extensions, to show different
+# behaviour of namespaces and prefixes
+
+use strict;
+
+use XML::Writer;
+
+my $ATOM = 'http://www.w3.org/2005/Atom';
+my $EXT = 'http://www.example.com/feed-extension';
+my $EXT2 = 'http://www.example.com/feed-extension-2';
+my $EXT3 = 'http://www.example.com/feed-extension-3';
+
+my $w = new XML::Writer(
+ NAMESPACES => 1,
+ DATA_MODE => 1,
+
+ # Define prefixes for most of the namespaces
+ PREFIX_MAP => {
+ $ATOM => '',
+ $EXT => 'ext',
+ $EXT2 => 'ext2'
+ },
+
+ # Force a declaration for the first extension on the root element
+ FORCED_NS_DECLS => [$EXT]
+);
+
+
+$w->comment(' An Atom feed with namespace declarations ');
+
+$w->startTag([$ATOM, 'feed']);
+
+# The root element will include a declaration for its own namespace
+# and the contents of FORCED_NS_DECLS
+$w->dataElement([$ATOM, 'title'], "Feed Title");
+
+# This namespace has already been declared on the root as the default
+$w->dataElement([$EXT, 'example'], "true");
+
+# This namespace had its name defined but the declaration hasn't appeared yet.
+# It will be included on demand, on this element.
+$w->dataElement([$EXT2, 'definitely-an-example'], "true");
+
+# This namespace has no prefix defined - an artificial prefix will be
+# used (something like __NS1)
+$w->dataElement([$EXT3, 'most-definitely-an-example'], "true");
+
+$w->endTag([$ATOM, 'feed']);
+
+$w->end();
Propchange: branches/upstream/libxml-writer-perl/current/examples/namespace-prefixes.pl
------------------------------------------------------------------------------
svn:executable = *
Added: branches/upstream/libxml-writer-perl/current/examples/simple-xml.pl
URL: http://svn.debian.org/wsvn/branches/upstream/libxml-writer-perl/current/examples/simple-xml.pl?rev=15621&op=file
==============================================================================
--- branches/upstream/libxml-writer-perl/current/examples/simple-xml.pl (added)
+++ branches/upstream/libxml-writer-perl/current/examples/simple-xml.pl Tue Feb 26 05:27:07 2008
@@ -1,0 +1,19 @@
+#!/usr/bin/perl -w
+
+# Write a simple XML document to a file
+
+use strict;
+
+use XML::Writer;
+
+my $output;
+
+open($output, '>', 'output.xml') or die "Unable to open output file: $!";
+
+my $writer = new XML::Writer(OUTPUT => $output);
+$writer->startTag("greeting",
+ "class" => "simple");
+$writer->characters("Hello, world!");
+$writer->endTag("greeting");
+$writer->end();
+close($output) or die "Failed to close output file: $!";
Propchange: branches/upstream/libxml-writer-perl/current/examples/simple-xml.pl
------------------------------------------------------------------------------
svn:executable = *
Added: branches/upstream/libxml-writer-perl/current/examples/writing-unicode.pl
URL: http://svn.debian.org/wsvn/branches/upstream/libxml-writer-perl/current/examples/writing-unicode.pl?rev=15621&op=file
==============================================================================
--- branches/upstream/libxml-writer-perl/current/examples/writing-unicode.pl (added)
+++ branches/upstream/libxml-writer-perl/current/examples/writing-unicode.pl Tue Feb 26 05:27:07 2008
@@ -1,0 +1,18 @@
+#!/usr/bin/perl -w
+
+# Generate UTF-8 output of a Unicode string
+
+use strict;
+
+use XML::Writer;
+
+my $unicodeString = "\x{201C}This\x{201D} is a test - \$ \x{00A3} \x{20AC}";
+
+my $w = new XML::Writer(ENCODING => 'utf-8');
+
+$w->xmlDecl();
+
+$w->startTag('doc');
+$w->characters($unicodeString);
+$w->endTag('doc');
+$w->end();
Propchange: branches/upstream/libxml-writer-perl/current/examples/writing-unicode.pl
------------------------------------------------------------------------------
svn:executable = *
Added: branches/upstream/libxml-writer-perl/current/examples/xml-writer-string.pl
URL: http://svn.debian.org/wsvn/branches/upstream/libxml-writer-perl/current/examples/xml-writer-string.pl?rev=15621&op=file
==============================================================================
--- branches/upstream/libxml-writer-perl/current/examples/xml-writer-string.pl (added)
+++ branches/upstream/libxml-writer-perl/current/examples/xml-writer-string.pl Tue Feb 26 05:27:07 2008
@@ -1,0 +1,19 @@
+#!/usr/bin/perl -w
+
+# Write to a string, then print the output
+
+use strict;
+
+use XML::Writer;
+
+my $s;
+
+my $w = new XML::Writer(OUTPUT => \$s);
+
+$w->startTag('doc');
+$w->characters('text');
+$w->endTag('doc');
+$w->end();
+
+# Print the string contents
+print $s
Propchange: branches/upstream/libxml-writer-perl/current/examples/xml-writer-string.pl
------------------------------------------------------------------------------
svn:executable = *
More information about the Pkg-perl-cvs-commits
mailing list