[LON-CAPA-cvs] cvs: nsdl /prototypes metadata_convert.pl

harris41 lon-capa-cvs@mail.lon-capa.org
Sat, 11 May 2002 23:22:49 -0000


harris41		Sat May 11 19:22:49 2002 EDT

  Modified files:              
    /nsdl/prototypes	metadata_convert.pl 
  Log:
  function handling example
  
  
Index: nsdl/prototypes/metadata_convert.pl
diff -u nsdl/prototypes/metadata_convert.pl:1.3 nsdl/prototypes/metadata_convert.pl:1.4
--- nsdl/prototypes/metadata_convert.pl:1.3	Sat May 11 17:04:27 2002
+++ nsdl/prototypes/metadata_convert.pl	Sat May 11 19:22:49 2002
@@ -45,6 +45,15 @@
 #http://www.openarchives.org/OAI/openarchivesprotocol.html
 # ">
 
+my $namespace='http://ExternalFunction/';
+my $func = sub {
+    my $text = shift;
+    return uc($text);
+};
+
+$tr->install_function($namespace, 'plain-text', $func);
+
+
 my $NSDL_metadata1=(<<END);
 <?xml version="1.0"?>
 <dc xmlns="http://purl.org/dc/elements/1.1/"
@@ -194,7 +203,10 @@
 open(OUT,'>tmpn2l.xsl');
 print(OUT <<END);
 <?xml version="1.0"?> 
-<xsl:stylesheet xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
+<xsl:stylesheet
+  xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
+  xmlns:external="$namespace"
+>
 <xsl:template match="/">
 <loncapa>
 <xsl:text>
@@ -205,7 +217,16 @@
 </xsl:text>
 </xsl:template>
 <xsl:template match="dc:title">
-<title><xsl:value-of select="."/></title>
+<title>
+         <xsl:choose>
+           <xsl:when test="function-available('external:plain-text')">
+             <xsl:value-of select="external:plain-text(.)"/>
+           </xsl:when>
+           <xsl:otherwise>
+             Function external:plain-text() is not available!
+           </xsl:otherwise>
+         </xsl:choose>
+</title>
 <xsl:text>
 </xsl:text>
 </xsl:template>