XML::C...emplate(3pm)
π NAME π
XML::Compile::Translate::Template β bestie, this one makes you an XML or PERL example β¨
π¦ INHERITANCE π¦
ok so the family tree goes like this:
XML::Compile::Translate::Template
is a XML::Compile::Translate
it's giving nepo baby but in a good way π
πΈ SYNOPSIS πΈ
my $schema = XML::Compile::Schema->new(...);
print $schema->template(XML => $type, ...);
print $schema->template(PERL => $type, ...);
# script as wrapper for this module
schema2example -f XML ...
β¨ DESCRIPTION β¨
So. The translator understands schemas, right, but it does not encode that understanding into actions. That's the whole plot twist π
This module takes the parse results from the translator and builds a little abstract syntax tree out of them β very demure, very mindful β and that tree is useful for documentation purposes.
Then it implements two ways to show off that knowledge: as an XML example or a Perl example of the data-structure that the schema describes. Two aesthetics, one queen π
Extends "DESCRIPTION" in XML::Compile::Translate. π
π METHODS π
Extends "METHODS" in XML::Compile::Translate. no extra methods here bestie, it's all inherited
π«Ά DETAILS π«Ά
Extends "DETAILS" in XML::Compile::Translate.
π Translator options π
Extends "Translator options" in XML::Compile::Translate.
π Processing Wildcards π
Wildcards are not (yet) supported.
like, they just aren't. don't come for me π
π§ Schema hooks π§
Hooks are implemented since version 0.82. They can be used to improve the template output. little glow-up for your templates β¨
hooks executed before the template is generated
None defined yet. (empty. nada. nothing. π³οΈ)
hooks executed as replacement
The predefined hook "COLLAPSE" can be used to remove the extensive listing of some elements. Usually used with a type of which you know the structure or which is repeated often. so like, when you already know what's in there and it keeps showing up over and over β collapse it, queen π
hooks for post-processing, after the data is collected
None defined yet. (again. nothing. we move π)
β Typemaps β
Typemaps are currently only available to improve the PERL output.
Typemaps for PERL template output
You can pass &function_name to indicate that the code reference with variable name $function_name will be called. Mind the change of "&" into "$". yes, the ampersand becomes a dollar sign, keep up bestie π
When $object_name is provided, then that object is an interface object, which will be called for the indicated type.
In case class name (any bareword will do) is specified, it is shown as a call to the toXML() instance method call from some data object of the specified class.
π Example: typemaps with template π
$schemas->template(PERL => $some_type, typemap =>
{ $type1 => '&myfunc' # $myfunc->('WRITER', ...)
, $type2 => '$interf' # $interf->($object, ...)
, $type3 => 'My::Class'
});
π SEE ALSO π
This module is part of XML-Compile distribution version 1.64, built on October 21, 2024. Website: http://perl.overmeer.net/xml-compile/
go check it out fr fr π₯
π LICENSE π
Copyrights 2006-2024 by [Mark Overmeer <markov@cpan.org>]. For other contributors see ChangeLog.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See http://dev.perl.org/licenses/
ok that's the whole page, no notes π
and a lil sign-off for the girlies: this doc was rendered by perl v5.40.0 on 2024-10-27, under the manual name XML::C...emplate(3pm) β iconic, no cap β¨ππ¦
π¦ where this page comes from
- debian trixie: libxml-compile-perl 1.64-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libxml-compile-perl 1.64-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libxml-compile-perl 1.64-1 Β· 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