Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kentnl/gentoo-xml
Work with various Gentoo XML documents in an object oriented manner
https://github.com/kentnl/gentoo-xml
Last synced: 4 days ago
JSON representation
Work with various Gentoo XML documents in an object oriented manner
- Host: GitHub
- URL: https://github.com/kentnl/gentoo-xml
- Owner: kentnl
- License: other
- Created: 2015-09-19T14:51:22.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2015-09-20T14:16:52.000Z (about 9 years ago)
- Last Synced: 2023-04-16T05:55:56.686Z (over 1 year ago)
- Language: Perl
- Size: 164 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.mkdn
- Changelog: Changes
- Contributing: CONTRIBUTING.pod
- License: LICENSE
Awesome Lists containing this project
README
# NAME
Gentoo::XML - Work with various Gentoo XML documents in an object oriented manner
# VERSION
version 0.001000
# DESCRIPTION
This module is a toolkit for reading, inspecting, modifying, and writing XML files
in Gentoo.`Gentoo::XML` is the primary gateway.
my $object = Gentoo::XML->load_xml( string => $xml );
Parses the given XML and then reads its `DTD` to divine its handler.
Known `DTD`'s and their Handler classes are mapped in `%Gentoo::XML::DTDS`.
The relevant handler class is then `load`'ed and the parsed document is
passed along with the discovered `DOCTYPE` name.my $object = Gentoo::XML::Metadata->inflate( $xml_libxml_document, 'pkgmetadata' );
That class, ( At least, when underwritten by `Gentoo::XML::NodeSet` ) will
in turn look up `'pkgmetadata'` ( The `DOCTYPE` name ) in its `%ELEMENTS`
hash and combine it with its `$PREFIX` to find the final node class.That class is in turn loaded and inflated:
my $object = Gentoo::XML::Metadata::PkgMetadata->inflate( $xml_libxml_document, 'pkgmetadata' );
Which leads you with:
A "Root" node object describing the document.
When underwritten by `Gentoo::XML::Node`, nodes can have generated accessors for
child nodes.if ( $object->has_longdescription() ) {
for my $desc ( $object->longdescription_collection ) {
$desc->isa('Gentoo::XML::Metadata::LongDescription') # true
}
}# METHODS
## `handler_for_dtd`
Given a `SYSTEM` `DTD` Identifier, returns the class that handles the given `DTD`.
my $handler_class = Gentoo::XML->handler_for_dtd('http://www.gentoo.org/dtd/metadata.dtd');
Class will be loaded for you.
## `load_xml`
my $object = Gentoo::XML->load_xml( $type => $value );
- `$type = `**`"string"`**
Load `$value` as either a scalar or scalar reference.
- `$type = `**`"IO"`**
Read `$value` as a File Handle
- `$type = `**`"location"`**
Read `$value` by opening the URI
See related documentation on `XML DOM` Parsing in
[`XML::LibXML::Parser`](https://metacpan.org/pod/XML::LibXML::Parser#DOM-Parser)# AUTHOR
Kent Fredric <[email protected]>
# COPYRIGHT AND LICENSE
This software is copyright (c) 2015 by Kent Fredric <[email protected]>.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.