NAME

XML::NewsML_G2::Writer - base class for XML DOM tree creation conforming to NewsML-G2 News Items, Package Items and News Messages

SYNOPSIS

    my $w = XML::NewsML_G2::Writer::News_Item->new
        (news_item => $ni, scheme_manager => $sm, g2_version => 2.18);

    my $p = $w->create_element('p', class => 'main', _text => 'blah');

    my $dom = $w->create_dom();

DESCRIPTION

This module acts as a NewsML-G2 version-independent base class for all writer classes. Depending on whether you want to create output for a News Item, Package Item or News Message, use one of the subclasses XML::NewsML_G2::Writer::News_Item, XML::NewsML_G2::Writer::Package_Item or XML::NewsML_G2::Writer::News_Message instead.

ATTRIBUTES

news_item

XML::NewsML_G2::News_Item instance used to create the output document

encoding

Encoding used to create the output document, defaults to utf-8

scheme_manager

XML::NewsML_G2::Scheme_Manager instance used to create qcodes

doc

XML::LibXML::Document instance used to create the output document

g2_ns

XML Namespace of NewsML-G2

xhtml_n2

XML Namespace of XHTML

g2_version

Use this attribute to specify the NewsML-G2 version to be created. Defaults to 2.18, other valid options are: 2.9, 2.12 and 2.15. Be aware that only the later versions offer all features.

schema_location

Specified by subclass.

g2_catalog_url

URL of the G2 catalog, specified by subclass.

g2_catalog_schemes

Reference to a hash of schemes that are covered by the G2 catalog. If the value is undefined, it defaults to the name of the scheme.

generator_version

Version of the generating software, as written to the output. Defaults to the version of XML::NewsML_G2, but can be overwritten here (mainly to ease automated testing).

METHODS

create_element

Helper method that creates XML elements, e.g. to be used in the paragraphs element of the XML::NewsML_G2::News_Item.

create_dom

Returns the XML::LibXML::Document element containing the requested output. Be careful not to use $dom->serialize(2) for formatting, as this creates invalid NewsML-G2 files because it adds whitespace where none is allowed (e.g. in xs:dateTime elements).

AUTHOR

Philipp Gortan <philipp.gortan@apa.at>

LICENCE AND COPYRIGHT

Copyright (c) 2013-2014, APA-IT. All rights reserved.

See XML::NewsML_G2 for the license.