NAME
Meta::Lang::Xml::Xml - help you with xml related tasks.
COPYRIGHT
Copyright (C) 2001, 2002 Mark Veltzer; All rights reserved.
LICENSE
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., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
DETAILS
MANIFEST: Xml.pm
PROJECT: meta
VERSION: 0.07
SYNOPSIS
package foo;
use Meta::Lang::Xml::Xml qw();
my($object)=Meta::Lang::Xml::Xml->new();
my($result)=$object->method();
DESCRIPTION
This class will help you with xml related tasks. 0. checking an xml file for correctness according to dtd. 1. setting up the search path for xml parser to find dtds. 2. extracting dependencies from XML files. 3. resolving dtds and xmls. 4. give you the type (root element) of XML files. 5. setup search path for XML CATALOG files. 6. Be able to strip all from XML file but content.
FUNCTIONS
catalog_setup()
get_prefix()
get_search_list($)
setup($)
setup_path()
fail_check($)
check($$$)
c2deps($)
c2chun($)
chunk($)
odeps($$$$)
resolve_dtd($)
resolve_xml($)
get_type($)
BEGIN()
TEST($)
FUNCTION DOCUMENTATION
- $errors
-
This is a package variable used to count the errors (no other elegant way that I found to count the errors).
- catalog_setup()
-
This method will set the XML_CATALOG_FILES envrionment files according to the Aegis development hierarchy as some XML tools need this variable set to know where to find XML catalog files.
- get_prefix()
-
This method returns the prefix for xml related material in the baseline.
- get_search_list($)
-
This method gives you the search list for XML processing. The input is the original path.
- setup($)
-
This method gets a path and sets up the search path according to this path.
- setup_path()
-
This method will setup path for validating parsers accoding to the baseline.
- fail_check($)
-
This method will be called by the XML::Checker::Parser if there is an error. We just print the error message and thats it. We dont die!!! (remmember we dont die in any routine as it is bad practice...).
- check($)
-
This method checks an XML file for structure according to a DTD. This is achieved by using the XML::Checker::Parser class which is a validating parser to parse the file. The parser will print the errors to STDERR if any are encountered (which is good for us) and will return the number of errros encountered via the global varialbe $errors.
- c2deps($)
-
This method reads a source xml file and produces a deps object which describes the dependencies for that file. This method uses an Expat parser to do it which is quite cheap.
- c2chun($)
-
This method receives an XML file and removes the DOCTYPE declarations from it so it could be included in another SGML file. This also removes the xml version declaration. This method need to be improved since it does not really do correct XML parsing but just uses non accurate perl regexps.
- chunk($)
-
Remove the xml declarations from a file and return the result string.
- odeps($$$$)
-
This method reads a source xml file and produces a deps object which describes the dependencies for that file. This method is doing it using a DOM parser which is quite expensive (it stores the entire docbument in RAM and other problems...).
- resolve_dtd($)
-
This method recevies a system id of a dtd file and resolves it to a physical file. This method should (potentialy) also check that the dtd is a member of the project.
- resolve_xml($)
-
This method recevies a system id of an xml file and resolves it to a physical file. This method should (potentialy) also check that the xml is a member of the project.
- get_type($)
-
This method receives a file name of an XML document and returns the type of the document (the highest element in it).
- BEGIN()
-
This block will be executed whenever you use this module and it will setup the XML search path for you.
- TEST($)
-
Test suite for this module.
SUPER CLASSES
None.
BUGS
None.
AUTHOR
Name: Mark Veltzer
Email: mailto:veltzer@cpan.org
WWW: http://www.veltzer.org
CPAN id: VELTZER
HISTORY
0.00 MV more Class method generation
0.01 MV thumbnail user interface
0.02 MV more thumbnail issues
0.03 MV website construction
0.04 MV web site automation
0.05 MV SEE ALSO section fix
0.06 MV move tests into modules
0.07 MV web site development
SEE ALSO
Meta::Baseline::Aegis(3), Meta::Development::Deps(3), Meta::Utils::Env(3), Meta::Utils::Output(3), Meta::Utils::Parse::Text(3), Meta::Utils::System(3), Meta::Xml::Parsers::Checker(3), Meta::Xml::Parsers::Deps(3), Meta::Xml::Parsers::Type(3), XML::Checker::Parser(3), XML::DOM(3), strict(3)
TODO
-the way im counting errros here is not nice since I'm using a global variable. This could be pretty bad for multi-threading etc... Try to make that nicer and dump the global var. You could see the errors global variable in the vars section.
-make the setup path (which everybody calls before starting to use this module) part of a BEGIN block (if it is at all needed). Think about it.
-the way I'm cutting full xmls into chunks using perl regexps is not right. Use a real XML parser and emit everything except the stuff I'm removing now.
-c2chun and chunk have same code. Unify it using IO:: objects.
-find all modules who use setup_path and make them stop it. (we have it in our begin block).