Catmandu::Importer::XSD - Import and validate serialized XML documents
# Compile an XSD schema file and parse one shiporder.xml file catmandu convert XSD --root '{}shiporder' --schemas demo/order/*.xsd to YAML < shiporder.xml # Same as above but parse more than one file into an array of records catmandu convert XSD --root '{}shiporder' --schemas demo/order/*.xsd --files 'data/*.xml' to YAML # Same as above but all array of records are in a XML container file catmandu convert XSD --root '{}shiporder' --schemas demo/order/*.xsd --xpath '/Container/List//Record/Payload/*' to YAML < data/container.xml # In Perl use Catmandu; my $importer = Catmandu->importer('XSD', file => 'ex/data.xml' root => ..., schemas => [ ...] ); my $n = $importer->each(sub { my $hashref = $_[0]; # ... });
This is a Catmandu::Importer for parsing and validating XML data using one or more XSD schema files.
Read input from a local file given by its path. Alternatively a scalar reference can be passed to read from a string.
Read input from an IO::Handle. If not specified, Catmandu::Util::io is used to create the input stream from the file argument or by using STDIN.
file
Optional. Don't read the content from the standard input but use the 'files' parameter as a glob for one or more filenames. E.g.
catmandu ... --files 'data/input/*.xml'
Optional. Don't do anything only show an example output how a document should be structured in the given XSD scheme. E.g.
catmandu convert XSD --root {}shiporder --schemas "t/demo/ead/*xsd" --example 1 to YAML
An ARRAY of one or more fixes or file scripts to be applied to imported items.
Required. The name (and namespace) of the root element of the XML document. E.g.:
{}shiporder {http://www.loc.gov/mods/v3}mods {urn:isbn:1-931666-22-9}ead
Required. An array or comma separated list of XSD schema locations.
Optional. An XPath expression, the XML container in which the PNX record can be found. Default : /oai:OAI-PMH/oai:ListRecords//oai:record/oai:metadata/*
Optional. An array or comma delimited string of namespace prefixes to be used hand handling XML files. E.g.
# On the command line: catmandu ... --prefixes ead:urn:isbn:1-931666-22-9,... # In Perl prefixes => [ ead => 'urn:isbn:1-931666-22-9' , ... => ... ]
Optional. The handling of mixed element content. One of ATTRIBUTES (default), TEXTUAL, STRUCTURAL, XML_NODE, XML_STRING, CODE reference. See also Catmandu::XSD and XML::Compile::Translate::Reader
Optional. The handling of <any> content in schemas. One of TAKE_ALL (default: process as XML::LibXML::Node) , SKIP_ALL (ignore these) , XML_STRING (process as string) , CODE (provide a reference to parse the data). See XML::Compile::Translate::Reader
<any
Every Catmandu::Importer is a Catmandu::Iterable all its methods are inherited.
Catmandu::Importer, Catmandu::XSD
Patrick Hochstenbach , patrick.hochstenbach at ugent.be
patrick.hochstenbach at ugent.be
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.
To install Catmandu::XSD, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Catmandu::XSD
CPAN shell
perl -MCPAN -e shell install Catmandu::XSD
For more information on module installation, please visit the detailed CPAN module installation guide.