Annotation of nsdl/prototypes/metadata_convert.pl, revision 1.3

1.1       harris41    1: use XML::Xalan;
                      2: 
                      3: my $tr = new XML::Xalan::Transformer;
                      4: 
                      5: my $LONCAPA_metadata=(<<END);
                      6: <abstract></abstract>
                      7: <author>Felicia Berryman, MSU HHMI First Year Online Biology</author>
                      8: <copyright>default</copyright>
                      9: <creationdate>1011110523</creationdate>
                     10: <dependencies></dependencies>
                     11: <keywords>biomolecules,practice</keywords>
                     12: <language>seniso</language>
                     13: <lastrevisiondate>1011110523</lastrevisiondate>
                     14: <mime>html</mime>
                     15: <notes></notes>
1.2       harris41   16: <owner>bio\@msu, bio\@msu (Michigan State University), bio\@msu (Michigan State University), bio\@msu (Michigan State University)</owner>
1.1       harris41   17: <subject>Bio Information, Large Biomolecules - Intro, Large Biomolecules - Review</subject>
1.2       harris41   18: <title>Test title</title>
1.1       harris41   19: END
                     20: 
1.2       harris41   21: # ---------------------------------------------------- The 16 major nsdl fields
                     22: # Audience
                     23: # Publisher
                     24: # Contributor
                     25: # Relation
                     26: # Coverage
                     27: # Resource Identifier
                     28: # Creator 
                     29: # Resource Type
                     30: # Date
                     31: # Rights
                     32: # Description
                     33: # Source
                     34: # Format
                     35: # Subject & Keywords
                     36: # Language
                     37: # Title
                     38: # --------------- also need educational recommended fields
                     39: 
                     40: # (there are also other identified cross-walk strategies for 8 other metadata
                     41: #  standards)
                     42: 
1.1       harris41   43: #http://metamanagement.comm.nsdlib.org/overview.html#NSDL
                     44: #http://www.dlib.vt.edu/projects/OAi/marcxml/marcxml.html
                     45: #http://www.openarchives.org/OAI/openarchivesprotocol.html
1.2       harris41   46: # ">
1.3     ! harris41   47: 
1.1       harris41   48: my $NSDL_metadata1=(<<END);
1.2       harris41   49: <?xml version="1.0"?>
1.3     ! harris41   50: <dc xmlns="http://purl.org/dc/elements/1.1/"
        !            51:      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        !            52:      xsi:schemaLocation="http://purl.org/dc/elements/1.1
        !            53:      http://www.openarchives.org/OAI/1.1/dc.xsd">
1.1       harris41   54: <title>The Cornell Law Quarterly</title>
                     55: <date>1915-1916</date>
                     56: <identifier>http://heinonline.org/HeinOnline/show.pl?
                     57:             handle=hein.journals/clqv1%26id=1%26size=4</identifier>
                     58: <rights>Available by Subscription. See http://www.wshein.com</rights>
                     59: </dc>
                     60: END
1.2       harris41   61: open(OUT,'>tmpdc.xml');
                     62: print(OUT <<END);
                     63: $NSDL_metadata1
                     64: END
                     65: close(OUT);
                     66: 
1.1       harris41   67: my $NSDL_metadata2=(<<END);
                     68: <dc:dc xmlns:dc="http://purl.org/dc/elements/1.1/" 
                     69:        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
                     70:        xsi:schemaLocation="http://purl.org/dc/elements/1.1/
                     71:                            http://www.openarchives.org/OAI/1.1/dc.xsd">
                     72: <dc:title>Grassmann's space analysis</dc:title> 
                     73: <dc:creator>Hyde, E. W. (Edward Wyllys)</dc:creator>
                     74: <dc:subject>LCSH:Ausdehnungslehre; LCCN QA205.H99</dc:subject>
                     75: <dc:publisher>J. Wiley &amp; Sons</dc:publisher>
                     76: <dc:date>Created: 1906; Available: 1991</dc:date>
                     77: <dc:type>text</dc:type>
                     78: <dc:identifier>http://resolver.library.cornell.edu/math/1796949</dc:identifier>
                     79: <dc:language>eng</dc:language>
                     80: <dc:rights>Public Domain</dc:rights>
                     81: </dc:dc>
                     82: END
                     83: 
1.2       harris41   84: open(OUT,'>tmploncapa.xml');
                     85: print(OUT <<END);
                     86: <?xml version="1.0"?>
                     87: <loncapa>
                     88: $LONCAPA_metadata
                     89: </loncapa>
                     90: END
                     91: close(OUT);
                     92: 
                     93: # probably also want to protect dc name-space
                     94: open(OUT,'>tmpl2n.xsl');
                     95: print(OUT <<END);
                     96: <?xml version="1.0"?> 
                     97: <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
                     98: <xsl:template match="loncapa">
                     99: <dc>
                    100: <xsl:text>
                    101: </xsl:text>
                    102: <creator>
                    103: <xsl:value-of select="author"/>
                    104: </creator>
                    105: <xsl:text>
                    106: </xsl:text>
                    107: <publisher><xsl:value-of select="owner"/></publisher>
                    108: <xsl:text>
                    109: </xsl:text>
                    110: <title><xsl:value-of select="title"/></title>
                    111: <xsl:text disable-output-escaping="yes">
                    112: &lt;!-- NEED TO IMPLEMENT --&gt;
                    113: &lt;!-- converted from LON-CAPA language tag to Dublin Core language tag --&gt;
                    114: </xsl:text>
                    115: <language><xsl:value-of select="language"/></language>
                    116: <xsl:text disable-output-escaping="yes">
                    117: &lt;!-- NEED TO IMPLEMENT --&gt;
                    118: &lt;!-- converted from LON-CAPA seconds since 1/1/1970 to standard
                    119: calendar values --&gt;
                    120: </xsl:text>
                    121: <date>
                    122: Created: <xsl:value-of select="creationdate"/>;
                    123: Last revised: <xsl:value-of select="lastrevisiondate"/>
                    124: </date>
                    125: <xsl:text disable-output-escaping="yes">
                    126: &lt;!-- NEED TO IMPLEMENT --&gt;
                    127: &lt;!-- allow some sort of mapping to Library of Congress or Dewey Decimal
                    128: standard subject mapping --&gt;
                    129: </xsl:text>
                    130: <subject><xsl:value-of select="subject"/></subject>
                    131: <xsl:text>
                    132: </xsl:text>
                    133: <xsl:text disable-output-escaping="yes">
                    134: &lt;!-- NEED TO IMPLEMENT --&gt;
                    135: </xsl:text>
                    136: <audience>unknown mapping</audience>
                    137: <xsl:text>
                    138: </xsl:text>
                    139: <xsl:text disable-output-escaping="yes">
                    140: &lt;!-- NEED TO IMPLEMENT --&gt;
                    141: </xsl:text>
                    142: <contributor>unknown mapping (coauthors?)</contributor>
                    143: <xsl:text>
                    144: </xsl:text>
                    145: <xsl:text disable-output-escaping="yes">
                    146: &lt;!-- NEED TO IMPLEMENT --&gt;
                    147: </xsl:text>
                    148: <relation>unknown mapping... prerequisite/postrequisite info could go here</relation>
                    149: <xsl:text>
                    150: </xsl:text>
                    151: <xsl:text disable-output-escaping="yes">
                    152: &lt;!-- NEED TO IMPLEMENT --&gt;
                    153: </xsl:text>
                    154: <coverage>unknown mapping</coverage>
                    155: <xsl:text>
                    156: </xsl:text>
                    157: <xsl:text disable-output-escaping="yes">
                    158: &lt;!-- NEED TO IMPLEMENT --&gt;
                    159: </xsl:text>
                    160: <identifier>the gateway url</identifier>
                    161: <xsl:text>
                    162: </xsl:text>
                    163: <xsl:text disable-output-escaping="yes">
                    164: &lt;!-- NEED TO IMPLEMENT --&gt;
                    165: &lt;!-- probably mapping from LON-CAPA mime typing --&gt;
                    166: </xsl:text>
                    167: <resourcetype>n/a</resourcetype>
                    168: <xsl:text disable-output-escaping="yes">
                    169: &lt;!-- NEED TO IMPLEMENT --&gt;
                    170: &lt;!-- probably mapping from LON-CAPA copyright --&gt;
                    171: </xsl:text>
                    172: <rights>n/a</rights>
                    173: <description><xsl:value-of select="abstract"/></description>
                    174: <xsl:text>
                    175: </xsl:text>
                    176: # Source
                    177: <xsl:text disable-output-escaping="yes">
                    178: &lt;!-- NEED TO IMPLEMENT --&gt;
                    179: </xsl:text>
                    180: <format>software and hardware needed</format>
                    181: <xsl:text disable-output-escaping="yes">
                    182: &lt;!-- NEED TO IMPLEMENT --&gt;
                    183: </xsl:text>
                    184: <subjectandkeywords>need to break things into formal "classification" tag to insert keywords</subjectandkeywords>
                    185: <xsl:text>
                    186: </xsl:text>
                    187: </dc>
                    188: </xsl:template>
                    189: </xsl:stylesheet>
                    190: END
                    191: close(OUT);
                    192: 
                    193: # probably also want to protect dc name-space
                    194: open(OUT,'>tmpn2l.xsl');
                    195: print(OUT <<END);
                    196: <?xml version="1.0"?> 
                    197: <xsl:stylesheet xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
                    198: <xsl:template match="/">
                    199: <loncapa>
                    200: <xsl:text>
                    201: </xsl:text>
                    202: <xsl:apply-templates select="/*/dc:*"/>
                    203: </loncapa>
                    204: <xsl:text>
                    205: </xsl:text>
                    206: </xsl:template>
                    207: <xsl:template match="dc:title">
                    208: <title><xsl:value-of select="."/></title>
                    209: <xsl:text>
                    210: </xsl:text>
                    211: </xsl:template>
                    212: <xsl:template match="dc:date">
                    213: <date><xsl:value-of select="."/></date>
                    214: <xsl:text>
                    215: </xsl:text>
                    216: </xsl:template>
                    217: <xsl:template match="dc:rights">
                    218: <copyright><xsl:value-of select="."/></copyright>
                    219: <xsl:text>
                    220: </xsl:text>
                    221: </xsl:template>
                    222: <xsl:template match="dc:identifier">
                    223: <dc:identifier><xsl:value-of select="."/></dc:identifier>
                    224: <xsl:text>
                    225: </xsl:text>
                    226: </xsl:template>
                    227: </xsl:stylesheet>
                    228: END
                    229: close(OUT);
                    230: 
                    231: # ---------------------------------- LON-CAPA to NSDL (Dublic Core PLUS format)
                    232: my $compiled = $tr->compile_stylesheet_file("tmpl2n.xsl");
                    233: my $parsed = $tr->parse_file("tmploncapa.xml");
                    234: my $dest_file="l2n.xml";
                    235: $tr->transform_to_file($parsed, $compiled, $dest_file)
                    236:     or die $tr->errstr;
                    237: 
                    238: # ---------------------------------- NSDL (Dublic Core PLUS format) to LON-CAPA
                    239: my $compiled = $tr->compile_stylesheet_file("tmpn2l.xsl");
                    240: my $parsed = $tr->parse_file("tmpdc.xml");
                    241: my $dest_file="n2l.xml";
                    242: $tr->transform_to_file($parsed, $compiled, $dest_file)
                    243:     or die $tr->errstr;
1.1       harris41  244: 
1.2       harris41  245: # ---------------------------------- test
                    246: my $compiled = $tr->compile_stylesheet_file("test1.xsl");
                    247: my $parsed = $tr->parse_file("test1.xml");
                    248: my $dest_file="test1out.xml";
1.1       harris41  249: $tr->transform_to_file($parsed, $compiled, $dest_file)
                    250:     or die $tr->errstr;

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>