XML::ComicsML - create, write, and parse ComicsML files
# parse an existing ComicsML file my $parser = XML::ComicsML::Parser->new; my $comic = $parser->parsefile('my_comic.xml');
my $title = $comic->title; print "The title of this comic is $title\n";
my @strips = $comic->strips; print "It has ".scalar(@strips)." strips associated with it.\n";
# build a comic object out of thin air, instead of parsing my $comic2 = XML::ComicsML::Comic->new; $comic2->title('Perl Adventures'); $comic2->url('http://www.jmac.org/perlcomix/index.html');
# define a person for it my $me = $comic2->new_person; $me->firstname('Emma'); $me->surname('Shrimphaven'); $me->email('firstname.lastname@example.org');
# add a strip my $strip1 = $comic2->new_strip('PA-1'); # My arbitrary ID for this strip $strip1->url('http://www.jmac.org/perlcomix/pa-1.html'); $strip1->description('Captain Perl learns about list context.');
# I could add some panel description here, but I am too lazy. # Let's just print out what we have to STDOUT. $comic2->as_string;
This module provides a programmer interface for creating, parsing, and otherwise working with documents written according to the ComicsML format for describing digital comics, much as XML::RSS does for the RSS syndication format.
The main object class that this module defines is XML::ComicsML::Comic, which represents an entire document, and holds various fields and other objects representing the document's content. There are two main ways to create this object:
The parser performs several checks specific to ComicsML validity as it traverses a document, and will croak if it finds any errors.
Of course, you can combine these strategies, parsing an existing file to create a Comic object with some content in it and then manipulating, adding to, and subtracting from that content however you like through the methods available through that object and all its content objects.
From this point on, we'll use a lot of terms specific to ComicsML, such as the particular things 'comic' and 'strip' mean in its context, so we'll assume you're already familiar with them. If not, please refer to the general ComicsML documentation, a URL to which you can find in the SEE ALSO section of this manpage.
Note about language: An object's language attribute corresponds to the special ``xml:lang'' XML attribute, and ComicsML treats this as a lexically scoped value. Therefore, if you set a value through the language accessor of any object in the XML::ComicsML hiearchy, then all the objects it contains will be able to read the same langauge value through the language accessor -- unless, of course, one of these objects sets its own langauge value, which will in turn get passed on to its own contents.
None of the other simple accessors anywhere else in the ComicsML object tree are this wacky; they get or set values only as they might appear on that one object, with no mind given to parents or children. So there you have it.
Passes along any arguments it recives as a hash to the underlying constructor call to XML::Writer, so you can feed this method, for example, a filehandle reference keyed under 'OUTPUT', and have the ComicsML document wind up there.
By default, it prints to STDOUT, and uses a two-space indentation style.
The order in which a Strip object keeps its Panel objects is the same as the order in which a human reader should encounter them -- in other words, the order in which they would appear in an actual ComicsML document.
Note: description sets the description that will appear in the strip's teaser section.
If called with an argument, it understands it as a language code, and files this new panel-desc object under that language. If called with no arguments, then the panel will file this desc under the same language code as the one the panel had set as its own language.
If called in scalar context, returns only the default desc.
If called with no arguments, returns the default Panel::Desc object.
Objects of this class hold the actual text of panel descriptions.
Called with two arguments, adds the first as text with the second argument understood as a style to apply to it -- in effect, adding an XML inline element to this line.
...will simply add 'Foo' as plain text to the current line. And:
...will ``Bar'' with an ``emphasis'' style to the current line. If you were to print this line as XML at this point, it would look like this:
( ['Foo', 'normal'], ['Bar', 'emphasis'] )
Note how unstyled text actually gets 'normal' as a default style.
Note that it automatically inserts a space in between text segments (unless they had space already between them).
Probably lots. Don't hesitate to email me if you find any, or see sorely lacking features.
The ComicsML resource page: http://www.jmac.org/projects/comics_ml/
Jason McIntosh <email@example.com>
Copyright (c) 2001 by Jason McIntosh <firstname.lastname@example.org>.
This is free software; you can redistribute it and/or modify it under the same terms as Perl itself.