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

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

πŸ’– XML::Compile::Util β€” utility routines for XML::Compile components πŸ’–

okay so hi bestie!! ✨ this is XML::C...::Util from the 3pm section of your manual pages, and it's literally just a lil grab-bag of helper routines that the various XML::Compile components use. They're kind of unrelated to each other?? like a group chat where nobody knows how everyone met. but they're all useful, so. 🫢


🌈 INHERITANCE

  • XML::Compile::Util
    • is an Exporter πŸ‘‘

so yeah she exports stuff. that's the whole personality trait. iconic.


✨ SYNOPSIS

use XML::Compile::Util;
my $node_type = pack_type $ns, $localname;
my ($ns, $localname) = unpack_type $node_type;

🌸 DESCRIPTION

The functions in this package get used by all sorts of XML::Compile components, and ngl those components might have zero to do with each other. It's giving "found family" energy fr fr. πŸ’…


πŸŽ€ FUNCTIONS

🧚 Constants

These URIs are exported as constants, so you don't have to sit there typing the same giant URI over and over like a clown: XMLNS, SCHEMA1999, SCHEMA2000, SCHEMA2001, and SCHEMA2001i. ur welcome bestie πŸ’–

πŸ“¦ Packing

  • pack_id($ns, $id) β€” squishes those two args into one compact string representation of the node id. 🫢

example:

print pack_id 'http://my-ns', 'my-id';
# shows:  http://my-ns#my-id
  • pack_type( [$ns], $localname ) β€” turns the args into one compact string representation of the node type. and listen: when $ns isn't there, or it's undef, or it's an empty string, then no namespace is presumed and no curly-brace part gets made. periodt. πŸ’…

example:

print pack_type 'http://my-ns', 'my-type';
# shows:  {http://my-ns}my-type

print pack_type 'my-type';
print pack_type undef, 'my-type';
print pack_type '', 'my-type';
# all three show:   my-type
  • unpack_id($string) β€” returns a LIST of two elements: the name-space and the id, exactly as included in $string. that $string has to be compatible with whatever pack_id() spits out, no cap. 🌟
  • unpack_type($string) β€” returns a LIST of two elements: the name-space and the localname, as included in $string. again, $string must be compatible with the result of pack_type(). when there's no name-space present, an empty string is used. πŸ¦‹

πŸ“ Other

  • add_duration( $duration, [$time] ) β€” [1.44] adds the $duration to the $time (which defaults to 'now'). heads up though: this is an expensive operation 😭 in many cases duration2secs() produces useful results as well, so consider that before you go spending all your CPU.

example:

my $now      = time;
my $deadline = add_duration 'P1M', $now;  # deadline in 1 month
  • duration2secs($duration) β€” [1.44] translates any format into seconds. here's an example of a valid duration: "-PT1M30.5S" ⏱️ average month and year lengths are used, so if you need more precise calculations, then use add_duration() instead. iykyk.
  • even_elements(LIST) β€” returns the even-numbered elements from the LIST. ✨
  • odd_elements(LIST) β€” returns the odd-numbered elements from the LIST. ✨
  • type_of_node($node) β€” translates an XML::LibXML::Node into a packed type. πŸ’œ

πŸ‘€ 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 look, bestie, it's right there. πŸ”₯


πŸ“œ 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/ 🌈


okay and for the cute lil sign-off: this whole vibe is perl v5.40.0, dated 2024-10-27, and the manual page name is XML::C...::Util(3pm) in case you forgot where you were. slay, go pack some types πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from