Difference between revisions of "API:EPrints/XSLT"

From EPrints Documentation
Jump to: navigation, search
 
Line 8: Line 8:
 
'''EPrints::XSLT''' - utilities for XSLT processing
 
'''EPrints::XSLT''' - utilities for XSLT processing
  
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
 
<!-- Edit below this comment -->
 
<!-- Edit below this comment -->
  
  
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
</div>
 
 
<!-- Pod2Wiki=head_synopsis -->
 
<!-- Pod2Wiki=head_synopsis -->
 
==SYNOPSIS==
 
==SYNOPSIS==
  my $xslt = EPrints::XSLT-&gt;new(
+
<source lang="perl">my $xslt = EPrints::XSLT->new(
    repository =&gt; $repository,
+
repository => $repository,
    stylesheet =&gt; $stylesheet,
+
stylesheet => $stylesheet,
  );
+
);
 
+
 
  my $result = $xslt-&gt;transform( $doc );
+
my $result = $xslt->transform( $doc );
  print $xslt-&gt;output_as_bytes( $result );
+
print $xslt->output_as_bytes( $result );</source>
 
+
 
 
Using ept functions:
 
Using ept functions:
  
  &lt;xsl:value-of select="ept:value('title')" /&gt;
+
<source lang="perl"><xsl:value-of select="ept:value('title')" />
  &lt;xsl:copy-of select="ept:render_value('title')" /&gt;
+
<xsl:copy-of select="ept:render_value('title')" /></source>
 
+
 
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
 
<!-- Edit below this comment -->
 
<!-- Edit below this comment -->
  
  
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
</div>
 
 
<!-- 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.
  
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
 
<!-- Edit below this comment -->
 
<!-- Edit below this comment -->
  
  
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
</div>
 
 
<!-- Pod2Wiki=head_methods -->
 
<!-- Pod2Wiki=head_methods -->
 
==METHODS==
 
==METHODS==
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
+
<!-- Pod2Wiki=head_new -->
<span style='display:none'>User Comments</span>
+
===new===
<!-- Edit below this comment -->
 
 
 
  
<!-- Pod2Wiki= -->
+
<source lang="perl">$xslt = EPrints::XSLT->new( repository => $repo, ... )
</div>
 
<!-- Pod2Wiki=item_new -->
 
===new===
 
  
$xslt = EPrints::XSLT-&gt;new( repository =&gt; $repo, ... )
+
</source>
 
Options:
 
Options:
  
  repository
+
<pre>  repository
 
   stylesheet
 
   stylesheet
 
   dataobj
 
   dataobj
 
   dataobjs
 
   dataobjs
 
   opts
 
   opts
   error_cb
+
   error_cb</pre>
 
+
 
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
 
<!-- Edit below this comment -->
 
<!-- Edit below this comment -->
  
  
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
</div>
+
<!-- Pod2Wiki=head_transform -->
<!-- Pod2Wiki=item_transform -->
 
 
===transform===
 
===transform===
  
$result = $xslt-&gt;transform( $doc [, @parameters ] )
+
<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.
  
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
 
<!-- Edit below this comment -->
 
<!-- Edit below this comment -->
  
  
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
</div>
+
<!-- Pod2Wiki=head_output_as_bytes -->
<!-- Pod2Wiki=item_output_as_bytes -->
 
 
===output_as_bytes===
 
===output_as_bytes===
  
$bytes = $xslt-&gt;output_as_bytes( $result )
+
<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}}.
  
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
 
<!-- Edit below this comment -->
 
<!-- Edit below this comment -->
  
  
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
</div>
 
 
<!-- Pod2Wiki=head_ept_functions -->
 
<!-- Pod2Wiki=head_ept_functions -->
 
==EPT FUNCTIONS==
 
==EPT FUNCTIONS==
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
+
* ept:citation( [ STYLE [, OPTIONS ] ] )
<span style='display:none'>User Comments</span>
+
: Returns the citation of style STYLE (or "default") for the current item.
<!-- Edit below this comment -->
 
 
 
 
 
<!-- Pod2Wiki= -->
 
</div>
 
<!-- Pod2Wiki=item_citation -->
 
===ept:citation( [ STYLE [, OPTIONS ] ] )===
 
 
 
Returns the citation of style STYLE (or "default") for the current item.
 
 
 
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
<!-- Edit below this comment -->
 
 
 
 
 
<!-- Pod2Wiki= -->
 
</div>
 
<!-- Pod2Wiki=item_config -->
 
===ept:config( KEY1 [, KEY2 [, ... ] ] )===
 
  
Returns the repository configuration value.
+
* ept:config( KEY1 [, KEY2 [, ... ] ] )
 +
: Returns the repository configuration value.
  
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
+
* ept:documents()
<span style='display:none'>User Comments</span>
+
: Returns a list of the current item's documents (errors if current item is not an eprint).
<!-- Edit below this comment -->
 
  
 +
* ept:icon( [ OPTIONS ] )
 +
: Returns a link to a document with icon.
  
<!-- Pod2Wiki= -->
+
: Options:
</div>
 
<!-- Pod2Wiki=item_documents -->
 
===ept:documents()===
 
  
Returns a list of the current item's documents (errors if current item is not an eprint).
+
<pre> HoverPreview
 
 
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
<!-- Edit below this comment -->
 
 
 
 
 
<!-- Pod2Wiki= -->
 
</div>
 
<!-- Pod2Wiki=item_icon -->
 
===ept:icon( [ OPTIONS ] )===
 
 
 
Returns a link to a document with icon.
 
 
 
Options:
 
 
 
  HoverPreview
 
 
   noHoverPreview
 
   noHoverPreview
 
   NewWindow
 
   NewWindow
   noNewWindow
+
   noNewWindow</pre>
 
 
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
<!-- Edit below this comment -->
 
 
 
  
<!-- Pod2Wiki= -->
+
* ept:one_of( NEEDLE [, HAYSTACK ] )
</div>
+
: Returns true if NEEDLE is in HAYSTACK based on string equality.
<!-- Pod2Wiki=item_one_of -->
 
===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.
  
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
+
* ept:phrase( PHRASEID )
<span style='display:none'>User Comments</span>
+
: Returns the HTML phrase for PHRASEID.
<!-- Edit below this comment -->
 
  
 +
* ept:render_value( FIELDID [, OPTIONS ] )
 +
: Returns the rendered value of FIELDID for the current item.
  
<!-- Pod2Wiki= -->
+
* ept:url( [ STAFF ] )
</div>
+
: Returns the URL of the current item (or control page if STAFF is true).
<!-- Pod2Wiki=item_param -->
 
===ept:param( KEY )===
 
  
Returns the value of the parameter KEY e.g. in plugin arguments.
+
* ept:value( FIELDID )
 +
: Returns the value of FIELDID for the current item.
  
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
 
<!-- Edit below this comment -->
 
<!-- Edit below this comment -->
  
  
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
</div>
+
<!-- Pod2Wiki=head_copyright -->
<!-- Pod2Wiki=item_phrase -->
+
==COPYRIGHT==
===ept:phrase( PHRASEID )===
+
Copyright 2000-2011 University of Southampton.
 
 
Returns the HTML phrase for PHRASEID.
 
  
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
+
This file is part of EPrints http://www.eprints.org/.
<span style='display:none'>User Comments</span>
 
<!-- Edit below this comment -->
 
  
 +
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.
  
<!-- Pod2Wiki= -->
+
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.
</div>
 
<!-- Pod2Wiki=item_render_value -->
 
===ept:render_value( FIELDID [, OPTIONS ] )===
 
  
Returns the rendered value of FIELDID for the current item.
+
You should have received a copy of the GNU Lesser General Public License along with EPrints.  If not, see http://www.gnu.org/licenses/.
  
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
 
<!-- Edit below this comment -->
 
<!-- Edit below this comment -->
  
  
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
</div>
+
<!-- Pod2Wiki=_postamble_ -->
<!-- Pod2Wiki=item_url -->
 
===ept:url( [ STAFF ] )===
 
 
 
Returns the URL of the current item (or control page if STAFF is true).
 
 
 
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
 
<!-- Edit below this comment -->
 
<!-- Edit below this comment -->
 
 
<!-- Pod2Wiki= -->
 
</div>
 
<!-- Pod2Wiki=item_value -->
 
===ept:value( FIELDID )===
 
 
Returns the value of FIELDID for the current item.
 
 
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
<!-- Edit below this comment -->
 
 
 
<!-- Pod2Wiki= -->
 
</div>
 
<!-- Pod2Wiki=head_copyright -->
 
==COPYRIGHT==
 
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
<!-- Edit below this comment -->
 
 
 
<!-- Pod2Wiki= -->
 
</div>
 
<!-- Pod2Wiki=_postamble_ --><!-- 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


API: Core API

Latest Source Code (3.4, 3.3) | Revision Log | Before editing this page please read Pod2Wiki


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/.