XML::C...emplate(3pm)

πŸ“¦
version 1.64 Β· 3 versions
, in debian trixie, ubuntu resolute, ubuntu stonking

πŸ’– 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