Catman...former(3pm)

πŸ“¦
version 0.17 Β· 3 versions
, in ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– Catmandu::XML::Transformer πŸ’–

okay so bestie, welcome to the manual for Catmandu::XML::Transformer, a lil utility module for XML/XSLT processing ✨ (the man page calls itself Catman...former(3pm) up top, which is giving truncated-filename realness, and it lives in the User Contributed Perl Documentation section 🫢).


✨ SYNOPSIS ✨

here's the whole vibe, no cap:

$transformer = Catamandu::XML::Transformer->new( stylesheet => 'file.xsl' );

$xml_string = $transformer->transform( $xml_string ); # SCALAR
$xml_dom    = $transformer->transform( $xml_dom );    # XML::LibXML::Document
$xml_struct = $transformer->transform( $xml_struct ); # ARRAY reference
$xml_simple = $transformer->transform( $xml_simple ); # HASH reference

$transformer = Catamandu::XML::Transformer->new( output_format => 'string' );
$xml_string  = $transformer->transform( $xml );       # any XML to SCALAR

like… you build a transformer, you hand it XML, you get XML back. iconic behaviour tbh 🌈


🌸 CONFIGURATION 🌸

the options you can pass when you make one, mwah πŸ’…

  • stylesheet β€” zero or more XSLT files πŸŽ€. you can give them as a comma-separated list of files, or as an array reference holding multiple files, and they get applied as a transformation pipeline. the files get parsed once, on instantiation of the Catmandu::XML::Transformer object β€” so like, not every single time you call transform, okay? efficient queen πŸ’–
  • output_format β€” the output format you're expecting: "dom", "string", "struct", or "simple" ⭐. by default the input format is what triggers the output format. BUT β€” and this is the plot twist β€” if the last stylesheet has text output (i.e. <xsl:output method="text"/>), then the output format gets automatically set to "string" πŸ¦‹

πŸ‘‘ METHODS πŸ‘‘

the methods, bestie, they're right here:

  • stylesheet() β€” returns an array reference of the XSLT filenames being used as the transformation pipeline πŸ’œ
  • output_format() β€” returns the output format, or undef πŸ™ˆ (yes, it can just be undef. it's fine. it's giving mystery.)

🫢 SEE ALSO 🫢

  • XML::Struct

that's the whole page, you ate it, periodt πŸ’…

signing off: this was perl v5.36.0, dated 2022-09-15, still serving Catman...former(3pm) energy forever πŸŽ€βœ¨ no cap.

πŸ“¦ where this page comes from