AxKit-XSP-Util

 view release on metacpan or  search on metacpan

Util.pm  view on Meta::CPAN

        $root = $document->importNode($root);
        $parent->appendChild($root);
    }
    else {
        die "XML::LibXML returned undef";
    }
}

# insert from a SCALAR
sub include_expr {
    my ($document, $parent, $frag) = @_;
    if ($frag || $frag == 0) {
        my $doc = XML::LibXML->new()->parse_string( $frag ); 
        if ($doc) {
            my $root = $doc->getDocumentElement();
            $root = $document->importNode($root);
            $parent->appendChild($root);
        }
        else {
            die "XML::LibXML returned undef";
        }
    }
}

Util.pm  view on Meta::CPAN

    >

And add this taglib to AxKit (via httpd.conf or .htaccess):

    AxAddXSPTaglib AxKit::XSP::Util

=head1 DESCRIPTION

The XSP util: taglib seeks to add a short list of basic utility
functions to the eXtesible Server Pages library. It trivializes the
inclusion of external fragments and adds a few other useful bells and
whistles.

=head1 TAG STRUCTURE

Most of of the tags require some sort of "argument" to be passed (e.g.
C<<util:include-file>> requires the B<name> of the file that is to be
read). Unless otherwise noted, all tags allow you to pass this
information either as an attribute of the current  element or as the
text node of an appropriately named child.

Util.pm  view on Meta::CPAN

    <util:include-file>
    <util:name>foo.xml</util:name>
    </util:include-file>

are valid.

=head1 TAG REFERENCE

=head2 C<<util:include-file>>

Provides a way to include an XML fragment from a local file into the
current parse tree. Requires a B<name> argument. The path may be relative
or absolute.

=head2 C<<util:include-uri>>

Provides a way to include an XML fragment from a (possibly) remote URI.
Requires an B<href> argument.

=head2 C<<util:get-file-contents>>

Provides a way to include a local file B<as plain text>. Requires a
B<name> argument. The path may be relative or absolute.

=head2 C<<util:include-expr>>

Provides a way to include an XML fragment from a scalar variable. Note
that this tag may B<only> pass the required  B<expr> argument as a
child node. Example: 

    <util:include-expr>
    <xsp:expr>$xml_fragment</xsp:expr>
    </util:include-expr>

=head2 C<<util:time>>

Returns a formatted time/date string. Requires a B<format> attribute.
The format is defined using the standard strftime() syntax.

=head1 AUTHOR

Kip Hampton, khampton@totalcinema.com



( run in 1.204 second using v1.01-cache-2.11-cpan-364913b4093 )