Catman...er::XSD(3pm)
π Catmandu::Exporter::XSD π
okay bestie, welcome to Catmandu::Exporter::XSD, part of the User Contributed Perl Documentation situation β¨ this is the page for the exporter that takes your Perl data and turns it into XML that's actually valid, like a good little citizen π
β¨ NAME β¨
Catmandu::Exporter::XSD β Export and validate XML documents π¦
πΈ SYNOPSIS πΈ
# Convert one shiporder YAML to XML
catmandu convert YAML to XSD --root '{}shiporder'
--schemas demo/order/*.xsd < shiporder.YAML
# Same as above but store multiple shiporders in the YAML into a separate file
catmandu convert YAML to XSD --root '{}shiporder'
--schemas demo/order/*.xsd
--split 1
< shiporder.YAML
# Same as above but use template toolkit to pack the XML into an container
# (The xml record is stored in the 'xml' key which can be retrieved in the
# template by [% xml %])
catmandu convert YAML to XSD --root '{}shiporder'
--schemas demo/order/*.xsd
--template_before t/xml_header.tt
--template t/xml_record.tt
--template t/xml_footer.tt
< shiporder.YAML
use Catmandu;
# Print to STDOUT
my $exporter = Catmandu->exporter('XSD',
root => ...
schemas => ...
);
$exporter->add_many($arrayref);
$exporter->add_many($iterator);
$exporter->add_many(sub { });
$exporter->add($hashref);
$exporter->commit;
no cap, those code blocks are verbatim, I would never touch them π
π DESCRIPTION π
So basically this is a Catmandu::Exporter for converting Perl into valided XML documents using an XSD schema file. It's giving "your data, but make it schema-compliant" π β¨
π CONFIGURATION π
Every option, every default, let's go π«Ά
fileβ Write output to a local file given by its path. Alternatively a scalar reference can be passed to write to a string. iconic behavior honestlyfhβ Write output to anIO::Handle. If not specified,Catmandu::Util::iois used to create the output stream from the"file"argument or by usingSTDOUT. lowkey the fallback queen πsplitβ Optional. Don't write to the file (orSTDOUT) and split the output documents into one or more files. E.g.
catmandu ... to XSD --root ... --schemas ... --split 1 < data
split_patternβ Optional. Use a FORMAT as template for naming output files. Uses the'_id'field in the data or an incremental counter as input. E.g.
# Creates 000001.xml , 000002.xml, etc
catmandu ... to XSD --root ... --schemas ... --split 1 --split_pattern '%-6.6d.xml' < data
split_directoryβ Optional. Specify the directory in which the split files need to be written. πtemplateβ Optional. A template toolkit template to be used for creating each XML output record. Gets as input the input data plus the XML serialized form in the'xml'field. the way that it feeds you the xml too?? so thoughtful πtemplate_beforeβ Optional. The template toolkit template to be used as XML header. πΈtemplate_afterβ Optional. The template toolkit template to be used as XML footer. πΈfixβ An ARRAY of one or more fixes or file scripts to be applied to imported items. get that data cleaned up bestie π§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. no schemas, no vibes πprefixesβ 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' ,
... => ...
]
mixedβ Optional. The handling of mixed element content. One ofATTRIBUTES(default),TEXTUAL,STRUCTURAL,XML_NODE,XML_STRING,CODEreference. See alsoCatmandu::XSDandXML::Compile::Translate::Reader. note thatATTRIBUTESis the default, bestie, don't forget it π
π METHODS π
Every Catmandu::Importer is a Catmandu::Iterable all its methods are inherited. so like, you get a whole inheritance glow-up for free β¨
π¦ SEE ALSO π¦
Catmandu::ExporterCatmandu::XSDTemplate
π AUTHOR π
Patrick Hochstenbach , "patrick.hochstenbach at ugent.be" β ty king π«Ά
π 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.
okay so that's the whole page bestie, every flag, every default, every ... left exactly where it was, I did not touch a single character of the code π
and for the cute sign-off: this was perl v5.36.0, dated 2022-11-29, filed under Catman...er::XSD(3pm) β periodt β¨ππ¦
π¦ 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