Catman...er::XSD(3pm)
π Catmandu::Importer::XSD π
okay bestie, gather round, because this one is a whole mood. we're looking at Catmandu::Importer::XSD, a page from the User Contributed Perl Documentation set (the header line calls it Catman...er::XSD(3pm), which is giving "truncated by the terminal, but make it fashion" π
).
β¨ NAME β¨
Catmandu::Importer::XSD β Import and validate serialized XML documents π¦
πΈ SYNOPSIS πΈ
# 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];
# ...
});
no cap, that last bit is the one you'll actually use in your Perl scripts π
π DESCRIPTION π
okay so this is a Catmandu::Importer β and its whole job? parsing and validating XML data using one or more XSD schema files. it's giving "glow up your XML, but with receipts" β¨
π CONFIGURATION π
fileβ read input from a local file, and you give it the path. alternatively you can hand it a scalar reference and it'll read from that string instead. iconic flexibility π«Άfhβ read input from anIO::Handle. if you don't specify one,Catmandu::Util::iois used to build the input stream from the"file"argument, or by falling back toSTDIN. default queen behavior πfilesβ optional! instead of reading content from standard input, use the'files'parameter as a glob for one or more filenames. e.g.
catmandu ... --files 'data/input/*.xml'
examplesβ optional. doesn't actually do anything β it just shows you an example output of how a document should be structured in the given XSD scheme. a little preview, a little vibe check π e.g.
catmandu convert XSD --root {}shiporder --schemas "t/demo/ead/*xsd" --example 1 to YAML
fixβ an ARRAY of one or more fixes or file scripts that get applied to imported items. your lil makeover station π§rootβ 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
schemasβ Required. an array or comma separated list of XSD schema locations.xpathβ optional. an XPath expression: the XML container in which the PNX record can be found. default is:
/oai:OAI-PMH/oai:ListRecords//oai:record/oai:metadata/*
prefixesβ optional. an array or comma delimited string of namespace prefixes to be used when 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' ,
... => ...
]
mixedβ optional. how mixed element content gets handled. one ofATTRIBUTES(that's the default),TEXTUAL,STRUCTURAL,XML_NODE,XML_STRING, or aCODEreference. see alsoCatmandu::XSDandXML::Compile::Translate::Reader.any_elementβ optional. how<any">content in schemas gets handled. one ofTAKE_ALL(default: process asXML::LibXML::Node),SKIP_ALL(just ignore these),XML_STRING(process as string), orCODE(provide a reference to parse the data). seeXML::Compile::Translate::Reader.
π¦ METHODS π¦
every Catmandu::Importer is a Catmandu::Iterable, so all its methods are inherited. periodt. π
π SEE ALSO π
Catmandu::ImporterCatmandu::XSD
π AUTHOR π
Patrick Hochstenbach, "patrick.hochstenbach at ugent.be" β legend behavior, fr fr π«Ά
π LICENSE AND COPYRIGHT π
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.
and that's the whole page, bestie! π this one shipped as perl v5.36.0, dated 2022-11-29, under the header Catman...er::XSD(3pm) β go forth and validate your XML, you absolute main character ππ
π¦ where this page comes from
- debian bookworm: libcatmandu-xsd-perl 0.05-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libcatmandu-xsd-perl 0.05-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms