XML::Compile::Translate::Template - create an XML or PERL example
Contents
Description
The translator understands schemas, but does not encode that into actions. This module interprets the
parse results of the translator, and creates a kind of abstract syntax tree from it, which can be used
for documentational purposes. Then, it implements to ways to represent that knowledge: as an XML or a
Perl example of the data-structure which the schema describes.
Extends "DESCRIPTION" in XML::Compile::Translate.
Details
Extends "DETAILS" in XML::Compile::Translate.
Translatoroptions
Extends "Translator options" in XML::Compile::Translate.
ProcessingWildcards
Wildcards are not (yet) supported.
Schemahooks
Hooks are implemented since version 0.82. They can be used to improve the template output.
hooksexecutedbeforethetemplateisgenerated
None defined yet.
hooksexecutedasreplacement
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.
hooksforpost-processing,afterthedataiscollected
None defined yet.
Typemaps
Typemaps are currently only available to improve the PERL output.
TypemapsforPERLtemplateoutput
You can pass &function_name to indicate that the code reference with variable name $function_name will be
called. Mind the change of "&" into "$".
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:typemapswithtemplate
$schemas->template(PERL => $some_type, typemap =>
{ $type1 => '&myfunc' # $myfunc->('WRITER', ...)
, $type2 => '$interf' # $interf->($object, ...)
, $type3 => 'My::Class'
});
Inheritance
XML::Compile::Translate::Template
is a XML::Compile::Translate
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/
perl v5.40.0 2024-10-27 XML::Compile::Translate::Template(3pm)
Methods
Extends "METHODS" in XML::Compile::Translate.
Name
XML::Compile::Translate::Template - create an XML or PERL example
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/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 ...
