Difference between revisions of "API:EPrints/XSLT"
Line 8: | Line 8: | ||
'''EPrints::XSLT''' - utilities for XSLT processing | '''EPrints::XSLT''' - utilities for XSLT processing | ||
− | |||
− | |||
<!-- Edit below this comment --> | <!-- Edit below this comment --> | ||
<!-- Pod2Wiki= --> | <!-- Pod2Wiki= --> | ||
− | |||
<!-- Pod2Wiki=head_synopsis --> | <!-- Pod2Wiki=head_synopsis --> | ||
==SYNOPSIS== | ==SYNOPSIS== | ||
− | + | <source lang="perl">my $xslt = EPrints::XSLT->new( | |
− | + | repository => $repository, | |
− | + | stylesheet => $stylesheet, | |
− | + | ); | |
− | + | ||
− | + | my $result = $xslt->transform( $doc ); | |
− | + | print $xslt->output_as_bytes( $result );</source> | |
− | + | ||
Using ept functions: | Using ept functions: | ||
− | + | <source lang="perl"><xsl:value-of select="ept:value('title')" /> | |
− | + | <xsl:copy-of select="ept:render_value('title')" /></source> | |
− | + | ||
− | |||
− | |||
<!-- Edit below this comment --> | <!-- Edit below this comment --> | ||
<!-- Pod2Wiki= --> | <!-- Pod2Wiki= --> | ||
− | |||
<!-- Pod2Wiki=head_description --> | <!-- Pod2Wiki=head_description --> | ||
==DESCRIPTION== | ==DESCRIPTION== | ||
Line 43: | Line 37: | ||
For the correct context to be set for 'ept:' functions this module '''must''' be used for every transform. | For the correct context to be set for 'ept:' functions this module '''must''' be used for every transform. | ||
− | |||
− | |||
<!-- Edit below this comment --> | <!-- Edit below this comment --> | ||
<!-- Pod2Wiki= --> | <!-- Pod2Wiki= --> | ||
− | |||
<!-- Pod2Wiki=head_methods --> | <!-- Pod2Wiki=head_methods --> | ||
==METHODS== | ==METHODS== | ||
− | < | + | <!-- Pod2Wiki=head_new --> |
− | + | ===new=== | |
− | |||
− | |||
− | < | + | <source lang="perl">$xslt = EPrints::XSLT->new( repository => $repo, ... ) |
− | |||
− | |||
− | |||
− | + | </source> | |
Options: | Options: | ||
− | + | <pre> repository | |
stylesheet | stylesheet | ||
dataobj | dataobj | ||
dataobjs | dataobjs | ||
opts | opts | ||
− | error_cb | + | error_cb</pre> |
− | + | ||
− | < | ||
− | |||
<!-- Edit below this comment --> | <!-- Edit below this comment --> | ||
<!-- Pod2Wiki= --> | <!-- Pod2Wiki= --> | ||
− | + | <!-- Pod2Wiki=head_transform --> | |
− | <!-- Pod2Wiki= | ||
===transform=== | ===transform=== | ||
− | + | <source lang="perl">$result = $xslt->transform( $doc [, @parameters ] ) | |
+ | |||
+ | </source> | ||
Transforms $doc with the given stylesheet. @parameters is an optional list of key-value pairs to pass to the stylesheet. | Transforms $doc with the given stylesheet. @parameters is an optional list of key-value pairs to pass to the stylesheet. | ||
− | |||
− | |||
<!-- Edit below this comment --> | <!-- Edit below this comment --> | ||
<!-- Pod2Wiki= --> | <!-- Pod2Wiki= --> | ||
− | + | <!-- Pod2Wiki=head_output_as_bytes --> | |
− | <!-- Pod2Wiki= | ||
===output_as_bytes=== | ===output_as_bytes=== | ||
− | + | <source lang="perl">$bytes = $xslt->output_as_bytes( $result ) | |
+ | |||
+ | </source> | ||
See {{API:PodLink|file=XML/LibXSLT|package_name=XML::LibXSLT|section=output_as_bytes|text=XML::LibXSLT/output_as_bytes}}. | See {{API:PodLink|file=XML/LibXSLT|package_name=XML::LibXSLT|section=output_as_bytes|text=XML::LibXSLT/output_as_bytes}}. | ||
− | |||
− | |||
<!-- Edit below this comment --> | <!-- Edit below this comment --> | ||
<!-- Pod2Wiki= --> | <!-- Pod2Wiki= --> | ||
− | |||
<!-- Pod2Wiki=head_ept_functions --> | <!-- Pod2Wiki=head_ept_functions --> | ||
==EPT FUNCTIONS== | ==EPT FUNCTIONS== | ||
− | + | * ept:citation( [ STYLE [, OPTIONS ] ] ) | |
− | + | : Returns the citation of style STYLE (or "default") for the current item. | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | Returns the citation of style STYLE (or "default") for the current item. | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | Returns the repository configuration value. | + | * ept:config( KEY1 [, KEY2 [, ... ] ] ) |
+ | : Returns the repository configuration value. | ||
− | + | * ept:documents() | |
− | + | : Returns a list of the current item's documents (errors if current item is not an eprint). | |
− | |||
+ | * ept:icon( [ OPTIONS ] ) | ||
+ | : Returns a link to a document with icon. | ||
− | + | : Options: | |
− | |||
− | |||
− | |||
− | + | <pre> HoverPreview | |
− | |||
− | < | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
noHoverPreview | noHoverPreview | ||
NewWindow | NewWindow | ||
− | noNewWindow | + | noNewWindow</pre> |
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | * ept:one_of( NEEDLE [, HAYSTACK ] ) | |
− | + | : Returns true if NEEDLE is in HAYSTACK based on string equality. | |
− | |||
− | |||
− | Returns | + | * ept:param( KEY ) |
+ | : Returns the value of the parameter KEY e.g. in plugin arguments. | ||
− | + | * ept:phrase( PHRASEID ) | |
− | + | : Returns the HTML phrase for PHRASEID. | |
− | |||
+ | * ept:render_value( FIELDID [, OPTIONS ] ) | ||
+ | : Returns the rendered value of FIELDID for the current item. | ||
− | + | * ept:url( [ STAFF ] ) | |
− | + | : Returns the URL of the current item (or control page if STAFF is true). | |
− | |||
− | |||
− | Returns the value of the | + | * ept:value( FIELDID ) |
+ | : Returns the value of FIELDID for the current item. | ||
− | |||
− | |||
<!-- Edit below this comment --> | <!-- Edit below this comment --> | ||
<!-- Pod2Wiki= --> | <!-- Pod2Wiki= --> | ||
− | + | <!-- Pod2Wiki=head_copyright --> | |
− | <!-- Pod2Wiki= | + | ==COPYRIGHT== |
− | == | + | Copyright 2000-2011 University of Southampton. |
− | |||
− | |||
− | + | This file is part of EPrints http://www.eprints.org/. | |
− | |||
− | |||
+ | EPrints is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. | ||
− | + | EPrints is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. | |
− | |||
− | |||
− | |||
− | + | You should have received a copy of the GNU Lesser General Public License along with EPrints. If not, see http://www.gnu.org/licenses/. | |
− | |||
− | |||
<!-- Edit below this comment --> | <!-- Edit below this comment --> | ||
<!-- Pod2Wiki= --> | <!-- Pod2Wiki= --> | ||
− | + | <!-- Pod2Wiki=_postamble_ --> | |
− | <!-- Pod2Wiki= | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
<!-- Edit below this comment --> | <!-- Edit below this comment --> | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− |
Latest revision as of 09:56, 22 January 2013
EPrints 3 Reference: Directory Structure - Metadata Fields - Repository Configuration - XML Config Files - XML Export Format - EPrints data structure - Core API - Data Objects
Latest Source Code (3.4, 3.3) | Revision Log | Before editing this page please read Pod2Wiki
Contents
NAME
EPrints::XSLT - utilities for XSLT processing
SYNOPSIS
my $xslt = EPrints::XSLT->new(
repository => $repository,
stylesheet => $stylesheet,
);
my $result = $xslt->transform( $doc );
print $xslt->output_as_bytes( $result );
Using ept functions:
<xsl:value-of select="ept:value('title')" />
<xsl:copy-of select="ept:render_value('title')" />
DESCRIPTION
Because XSLT requires very careful treatment this module should probably be only used by internal code.
For the correct context to be set for 'ept:' functions this module must be used for every transform.
METHODS
new
$xslt = EPrints::XSLT->new( repository => $repo, ... )
Options:
repository stylesheet dataobj dataobjs opts error_cb
transform
$result = $xslt->transform( $doc [, @parameters ] )
Transforms $doc with the given stylesheet. @parameters is an optional list of key-value pairs to pass to the stylesheet.
output_as_bytes
$bytes = $xslt->output_as_bytes( $result )
See XML::LibXSLT/output_as_bytes.
EPT FUNCTIONS
- ept:citation( [ STYLE [, OPTIONS ] ] )
- Returns the citation of style STYLE (or "default") for the current item.
- ept:config( KEY1 [, KEY2 [, ... ] ] )
- Returns the repository configuration value.
- ept:documents()
- Returns a list of the current item's documents (errors if current item is not an eprint).
- ept:icon( [ OPTIONS ] )
- Returns a link to a document with icon.
- Options:
HoverPreview noHoverPreview NewWindow noNewWindow
- ept:one_of( NEEDLE [, HAYSTACK ] )
- Returns true if NEEDLE is in HAYSTACK based on string equality.
- ept:param( KEY )
- Returns the value of the parameter KEY e.g. in plugin arguments.
- ept:phrase( PHRASEID )
- Returns the HTML phrase for PHRASEID.
- ept:render_value( FIELDID [, OPTIONS ] )
- Returns the rendered value of FIELDID for the current item.
- ept:url( [ STAFF ] )
- Returns the URL of the current item (or control page if STAFF is true).
- ept:value( FIELDID )
- Returns the value of FIELDID for the current item.
COPYRIGHT
Copyright 2000-2011 University of Southampton.
This file is part of EPrints http://www.eprints.org/.
EPrints is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
EPrints is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with EPrints. If not, see http://www.gnu.org/licenses/.