=head1 NAME

XML::Compile::Util - Utility routines for XML::Compile components

=head1 INHERITANCE

 XML::Compile::Util
   is a Exporter

=head1 SYNOPSIS

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

=head1 DESCRIPTION

The functions provided by this package are used by various XML::Compile
components, which on their own may be unrelated.

=head1 FUNCTIONS

B<block_label>(KIND, LABEL)

=over 4

Particle blocks, like `sequence' and `choice', which have a maxOccurs
(maximum occurrence) which is 2 of more, are represented by an ARRAY
of HASHs.  The label with such a block is derived from its first element.
This function determines how.

The KIND of block is abbreviated, and prepended before the LABEL.  When
the LABEL already had a block abbreviation (which may be caused by nested
blocks), that will be stripped first.

An element KIND of block is found in substitution groups.  That label
will not change.

example: labels for blocks with maxOccurs > 1

  seq_address      # sequence get seq_ prepended
  cho_gender       # choices get cho_ before them
  all_money        # an all block can also be repreated in spec >1.1
  gr_people        # group refers to a block of above type, but
                   #    that type is not reflected in the name

=back

B<odd_elements>(LIST)

=over 4

Returns the odd-numbered elements in the list.

=back

B<pack_id>(NAMESPACE, ID)

=over 4

Translates the two arguments into one compact string representation of
the node id.

example: 

 print pack_id 'http://my-ns', 'my-id';
 # shows:  http://my-ns#my-id

=back

B<pack_type>([NAMESPACE], LOCALNAME)

=over 4

Translates the arguments into one compact string representation of
the node type.  When the NAMESPACE is not present, C<undef>, or an
empty string, then no namespace is presumed, and no curly braces
part made.

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

=back

B<unpack_type>(STRING)

=over 4

Returns a LIST of two elements: the name-space and the id, as
included in the STRING.  That STRING must be compatible with the
result of L<pack_id()|XML::Compile::Util/"FUNCTIONS">.

=back

=head1 SEE ALSO

This module is part of XML-Compile distribution version 0.56,
built on October 18, 2007. Website: F<http://perl.overmeer.net/xml-compile/>

=head1 LICENSE

Copyrights 2006-2007 by Mark Overmeer. 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 F<http://www.perl.com/perl/misc/Artistic.html>

