File:  [LON-CAPA] / nsdl / prototypes / metadata_convert.pl
Revision 1.6: download - view: text, annotated - select for diffs
Sun Jul 14 07:38:16 2002 UTC (21 years, 9 months ago) by harris41
Branches: MAIN
CVS tags: HEAD
the full deal (prototyped); all 4 conversions... loncapa to IEEE LOM;
IEEE LOM to loncapa; Dublin Core to loncapa; loncapa to Dublin Core

    1: # metadata_convert.pl
    2: 
    3: # This script prototypes the conversion that should be handled
    4: # by the NSDL-LONCAPA gateway.
    5: 
    6: # Scott Harrison 2002
    7: 
    8: # For nicely viewable documentation, execute the following command:
    9: # ./perldoc metadata_convert.pl
   10: 
   11: # =========================================================== POD documentation
   12: 
   13: =pod
   14: 
   15: =head1 NAME
   16: 
   17: metadata_convert.pl - prototype metadata conversion for NSDL-LONCAPA gateway
   18: 
   19: =head1 SYNOPSIS
   20: 
   21: Usage: perl metadata_convert.pl
   22: 
   23: There is no input to this script.  The output of this script
   24: will describe the success or failure of the metadata conversion that happens.
   25: 
   26: The script is organized into the following sections:
   27: 
   28: =over 4
   29: 
   30: =item POD documentation
   31: 
   32: =item Initial settings for the script
   33: 
   34: =item Defining test XML metadata input
   35: 
   36: =item Define XSL stylesheets
   37: 
   38: =item Define external functions
   39: 
   40: =item Executing transformations
   41: 
   42: =item Various subroutines
   43: 
   44: =back
   45: 
   46: =head1 DESCRIPTION
   47: 
   48: This script converts LON-CAPA metadata into NSDL metadata
   49: and converts NSDL metadata into LON-CAPA metadata.
   50: 
   51: Example metadata strings are included in this prototype
   52: script--they are named by variables such as
   53: I<$LONCAPA_metadata> and I<$NSDL_metadata>.
   54: 
   55: The XML-processing "engine" for the transformation is B<XML::Xalan>
   56: available at http://search.cpan.org/search?dist=XML-Xalan.  This engine
   57: takes in XML files of one DTD type and converts them into XML
   58: files of another DTD type according to stylesheets.
   59: 
   60:  alpha.xml      alpha_to_beta.xsl   beta.xml
   61:  (alpha.dtd)    ---------------->   (beta.dtd)
   62: 
   63: LON-CAPA metadata currently consists of 13 different metadata fields
   64: (with defined datatypes):
   65: abstract, author, copyright, creationdate, dependencies, keywords, language,
   66: lastrevisiondate, mime, notes, owner, subject, and title.
   67: 
   68: For purposes of the gateway implementation, I am defining a qualified LON-CAPA
   69: metadata to consist of additional fields (which can be automatically
   70: generated from information on the LON-CAPA network):
   71: 
   72: "uri", which is both the address and unique identifier of the educational
   73: resource from the standpoint of LON-CAPA.
   74: 
   75: "structure", which is derived from the LON-CAPA MIME type of the file
   76: 
   77: "aggregation", which is derived from the LON-CAPA MIME type of the file
   78: 
   79: "bytesize", the size of the LON-CAPA resource in bytes (octets)
   80: 
   81: "version", which comes from information accessed from the LON-CAPA network
   82: 
   83: "metauri", which comes from the uri (with .meta appended)
   84: 
   85: In the future, more LON-CAPA metadata fields are expected to be added, and
   86: it may also be that several of the fields change, or are removed.
   87: 
   88: The current viewpoint regarding NSDL is to support unqualified dublin
   89: core and IEEE LOM, with IEEE LOM being preferred.  Both are to be
   90: supported (dublin core being the minimal and IEEE LOM being the maximal).
   91: There are 15 unqualified
   92: Dublin Core elements.  For version 6.4 of IEEE LOM (March 4, 2002--this is
   93: the version the gateway approach is based off of) there are 77 IEEE LOM
   94: category names with 58 IEEE LOM fields which correspond to a subset of
   95: the 77 category names.  A complete description of IEEE LOM version 6.4
   96: is available at http://ltsc.ieee.org/doc/wg12/LOM_WD6_4.pdf.  Note that
   97: the 15 Dublin Core elements correspond to a subset of the 58 IEEE LOM fields.
   98: 
   99: A summary (for the sake of brevity, with some details omitted) of how
  100: IEEE LOM and Dublin Core and LON-CAPA interrelate is described below
  101: (column order=LON-CAPA field, IEEE LOM datatype, IEEE LOM field,
  102: and Dublin Core Field).
  103: Note that an asterisk (*) for the LON-CAPA field indicates that a IEEE
  104: LOM field value can probably be generated for
  105: the LON-CAPA to NSDL metadata transformation.  Note that a question mark (?)
  106: indicates that a LOM field value may in the future be generated for
  107: the transformation.  Note that a minus sign (-) indicates that a LOM
  108: field value may not be generated for the transformation in the foreseeable
  109: future (never say absolutely never though).  The mappings below are not
  110: perfectly bidirectional; there are a number of one-to-many and many-to-one
  111: mappings that are involved in the metadata conversion.
  112: 
  113:                       -                1:General
  114:                       -                1.1:General.Identifier
  115:  lc:*                 CharacterString  1.1.1:General.Identifier.Catalog
  116:  lc:uri               CharacterString  1.1.2:General.Identifier.Entry          DC.Identifier
  117:  lc:title             LangString       1.2:General.Title                       DC.Title
  118:  lc:language          CharacterString  1.3:General.Language                    DC.Language
  119:  lc:abstract          LangString       1.4:General.Description                 DC.Description
  120:  lc:keywords          LangString       1.5:General.Keyword                     DC.Subject
  121:  lc:-                 LangString       1.6:General.Coverage                    DC.Coverage
  122:  lc:structure         VocabularyState  1.7:General.Structure
  123:  lc:aggregation       VocabularyEnum   1.8:General.AggregationLevel
  124:                       -                2:LifeCycle
  125:  lc:version           LangString       2.1:LifeCycle.Version
  126:  lc:?                 VocabularyState  2.2:LifeCycle.Status
  127:                       -                2.3:LifeCycle.Contribute
  128:  lc:*                 VocabularyState  2.3.1:LifeCycle.Contribute.Role
  129:  lc:author            CharacterString  2.3.2:LifeCycle.Contribute.Entity       DC.Creator DC.OtherContributor DC.Publisher
  130:  lc:lastrevisiondate  DateTime         2.3.3:LifeCycle.Contribute.Date         DC.Date
  131:                       -                3:MetaMetadata
  132:                       -                3.1:MetaMetadata.Identifier
  133:  lc:*                 CharacterString  3.1.1:MetaMetadata.Identifier.Catalog
  134:  lc:metauri           CharacterString  3.1.2:MetaMetadata.Identifier.Entry
  135:                       -                3.2:MetaMetadata.Contribute
  136:  lc:?                 VocabularyState  3.2.1:MetaMetadata.Contribute.Role
  137:  lc:?                 CharacterString  3.2.2:MetaMetadata.Contribute.Entity
  138:  lc:?                 DateTime         3.2.3:MetaMetadata.Contribute.Date
  139:  lc:*                 CharacterString  3.3:MetaMetadata.MetadataSchema
  140:  lc:*                 CharacterString  3.4:MetaMetadata.Language
  141:                       -                4:Technical
  142:  lc:mime              CharacterString  4.1:Technical.Format                    DC.Format
  143:  lc:bytesize          CharacterString  4.2:Technical.Size
  144:  lc:uri               CharacterString  4.3:Technical.Location
  145:                       -                4.4:Technical.Requirement
  146:                       -                4.4.1:Technical.Requirement.OrComposite
  147:  lc:?                 VocabularyState  4.4.1.1:Technical.Requirement.OrComposite.Type
  148:  lc:?                 VocabularyState  4.4.1.2:Technical.Requirement.OrComposite.Name
  149:  lc:?                 CharacterString  4.4.1.3:Technical.Requirement.OrComposite.MinimumVersion
  150:  lc:?                 CharacterString  4.4.1.4:Technical.Requirement.OrComposite.MaximumVersion
  151:  lc:?                 LangString       4.5:Technical.InstallationRemarks
  152:  lc:*                 LangString       4.6:Technical.OtherPlatformRequirements
  153:  lc:?                 Duration         4.7:Technical.Duration
  154:                       -                5:Educational
  155:  lc:?                 VocabularyState  5.1:Educational.InteractivityType
  156:  lc:?                 VocabularyState  5.2:Educational.LearningResourceType    DC.Type
  157:  lc:?                 VocabularyEnum   5.3:Educational.InteractivityLevel
  158:  lc:?                 VocabularyEnum   5.4:Educational.SemanticDensity
  159:  lc:*                 VocabularyState  5.5:Educational.IntendedEndUserRole
  160:  lc:?                 VocabularyState  5.6:Educational.Context
  161:  lc:?                 LangString       5.7:Educational.TypicalAgeRange
  162:  lc:?                 VocabularyEnum   5.8:Educational.Difficulty
  163:  lc:?                 Duration         5.9:Educational.TypicalLearningTime
  164:  lc:notes             LangString       5.10:Educational.Description
  165:  lc:language          CharacterString  5.11:Educational.Language
  166:                       -                6:Rights
  167:  lc:-                 VocabularyState  6.1:Rights.Cost
  168:  lc:copyright         VocabularyState  6.2:Rights.CopyrightandOtherRestrictions
  169:  lc:owner             LangString       6.3:Rights.Description                  DC.Rights
  170:                       -                7:Relation
  171:  lc:?                 VocabularyState  7.1:Relation.Kind
  172:                       -                7.2:Relation.Resource                   DC.Source
  173:                       -                7.2.1:Relation.Resource.Identifier
  174:  lc:?                 CharacterString  7.2.1.1:Relation.Resource.Identifier.Catalog
  175:  lc:?                 CharacterString  7.2.1.2:Relation.Resource.Identifier.Entry
  176:  lc:?                 LangString       7.2.2:Relation.Resource.Description     DC.Relation
  177:                       -                8:Annotation
  178:  lc:-                 CharacterString  8.1:Annotation.Entity
  179:  lc:-                 DateTime         8.2:Annotation.Date
  180:  lc:-                 LangString       8.3:Annotation.Description
  181:                       -                9:Classification
  182:  lc:?                 VocabularyState  9.1:Classification.Purpose
  183:                       -                9.2:Classification.TaxonPath
  184:  lc:?                 LangString       9.2.1:Classification.TaxonPath.Source
  185:                       -                9.2.2:Classification.TaxonPath.Taxon
  186:  lc:?                 CharacterString  9.2.2.1:Classification.TaxonPath.Taxon.Id
  187:  lc:?                 LangString       9.2.2.2:Classification.TaxonPath.Taxon.Entry
  188:  lc:?                 LangString       9.3:Classification.Description
  189:  lc:?                 LangString       9.4:Classification.Keyword
  190: 
  191: =head1 AUTHOR
  192: 
  193: Scott Harrison, 2002
  194: 
  195: =cut
  196: 
  197: # ============================================= Initial settings for the script
  198: 
  199: use XML::Xalan; # engine for processing XML transformations
  200: use Date::Format;
  201: use Date::Parse;
  202: 
  203: my $tr = new XML::Xalan::Transformer;
  204: 
  205: my $namespace='http://nsdl.lon-capa.org/namespace/ExternalFunction/';
  206: 
  207: # ============================================ Defining test XML metadata input
  208: 
  209: # -------------------------------------- An example metadata entry for LON-CAPA
  210: my $LONCAPA_metadata=(<<END);
  211: <abstract></abstract>
  212: <author>Felicia Berryman, MSU HHMI First Year Online Biology</author>
  213: <copyright>default</copyright>
  214: <creationdate>1011110523</creationdate>
  215: <dependencies></dependencies>
  216: <keywords>biomolecules,practice</keywords>
  217: <language>seniso</language>
  218: <lastrevisiondate>1011110523</lastrevisiondate>
  219: <mime>html</mime>
  220: <notes></notes>
  221: <owner>bio\@msu, bio\@msu (Michigan State University), bio\@msu (Michigan State University), bio\@msu (Michigan State University)</owner>
  222: <subject>Bio Information, Large Biomolecules - Intro, Large Biomolecules - Review</subject>
  223: <title>Test title</title>
  224: END
  225: 
  226: # ---------------------------- An example qualified metadata entry for LON-CAPA
  227: my $LONCAPA_qualified_metadata=(<<END);
  228: <?xml version="1.0"?>
  229: <loncapa xmlns="http://nsdl.lon-capa.org/loncapa/elements/1.1/">
  230: <abstract>This is an example abstract.</abstract>
  231: <author>Felicia Berryman, MSU HHMI First Year Online Biology</author>
  232: <copyright>default</copyright>
  233: <creationdate>1011110523</creationdate>
  234: <dependencies></dependencies>
  235: <keywords>biomolecules,practice</keywords>
  236: <language>seniso</language>
  237: <lastrevisiondate>1011110523</lastrevisiondate>
  238: <mime>html</mime>
  239: <notes></notes>
  240: <owner>bio\@msu, bio\@msu (Michigan State University), bio\@msu (Michigan State University), bio\@msu (Michigan State University)</owner>
  241: <subject>Bio Information, Large Biomolecules - Intro, Large Biomolecules - Review</subject>
  242: <title>Test title</title>
  243: <structure>structure</structure>
  244: <aggregation>aggregation</aggregation>
  245: <bytesize>10000</bytesize>
  246: <version>1</version>
  247: <metauri>http://nsdl.lon-capa.org/msu/bio/dir1/res1.html.meta</metauri>
  248: <uri>http://nsdl.lon-capa.org/msu/bio/dir1/res1.html</uri>
  249: </loncapa>
  250: END
  251: 
  252: my $NSDL_metadata1=(<<END);
  253: <?xml version="1.0"?>
  254: <dc xmlns="http://purl.org/dc/elements/1.1/">
  255: <title>The Cornell Law Quarterly</title>
  256: <date>1915-1916</date>
  257: <identifier>http://heinonline.org/HeinOnline/show.pl?
  258:             handle=hein.journals/clqv1%26id=1%26size=4</identifier>
  259: <rights>Available by Subscription. See http://www.wshein.com</rights>
  260: </dc>
  261: END
  262: 
  263: my $NSDL_metadata2=(<<END);
  264: <dc:dc xmlns:dc="http://purl.org/dc/elements/1.1/">
  265: <dc:title>Grassmann's space analysis</dc:title> 
  266: <dc:creator>Hyde, E. W. (Edward Wyllys)</dc:creator>
  267: <dc:subject>LCSH:Ausdehnungslehre; LCCN QA205.H99</dc:subject>
  268: <dc:publisher>J. Wiley &amp; Sons</dc:publisher>
  269: <dc:date>Created: 1906; Available: 1991</dc:date>
  270: <dc:type>text</dc:type>
  271: <dc:identifier>http://resolver.library.cornell.edu/math/1796949</dc:identifier>
  272: <dc:language>eng</dc:language>
  273: <dc:rights>Public Domain</dc:rights>
  274: </dc:dc>
  275: END
  276: 
  277: open(OUT,'>tmp_dcnsdl.xml');
  278: print(OUT <<END);
  279: $NSDL_metadata2
  280: END
  281: close(OUT);
  282: 
  283: #open(OUT,'>tmp_loncapa.xml');
  284: #print(OUT <<END);
  285: #<?xml version="1.0"?>
  286: #<loncapa>
  287: #$LONCAPA_metadata
  288: #</loncapa>
  289: #END
  290: #close(OUT);
  291: 
  292: open(OUT,'>tmp_loncapa.xml');
  293: print(OUT <<END);
  294: $LONCAPA_qualified_metadata
  295: END
  296: close(OUT);
  297: 
  298: 
  299: my $NSDL_metadata3=(<<END);
  300: <?xml version="1.0"?>
  301: <lom xmlns="http://nsdl.lon-capa.org/lom/elements/6.4/">
  302: 
  303:   <General>
  304:     <Identifier>
  305:      <Catalog>ISBN</Catalog>
  306:      <Entry>1323-143-d123-23</Entry>
  307:     </Identifier>
  308:     <Title>("en","House of Cards")</Title>
  309:     <Language>en</Language>
  310:     <Keyword>("en","Mona Lisa")</Keyword>
  311:   </General>
  312: 
  313:   <LifeCycle>
  314:       <Contribute>
  315:         <Role>Creator</Role>
  316:         <Person>Mary Smith</Person>
  317:         <Date>1998-07-20</Date>
  318:       </Contribute>
  319:   </LifeCycle>
  320: 
  321:   <Meta-metadata>
  322:     <Contribute>
  323:       <Date>1998-07-21</Date>
  324:       <Person>Joe Smith</Person>
  325:       <Organization>ACME Content</Organization>
  326:     </Contribute>
  327:     <Scheme>Base 1.0, IMS, ARIADNE</Scheme>
  328:     <Language>en</Language>
  329:   </Meta-metadata>
  330: 
  331:   <Technical>
  332:     <Format>HTML</Format>
  333:     <Location>http://www.manta.ieee.org/p1484/somewhere</Location>
  334:     <Requirement>
  335:       <OrComposite>
  336:       <Type>operating system</Type>
  337:       <Name>ms-windows</Name>
  338:       </OrComposite>
  339:     </Requirement>
  340:   </Technical>
  341: 
  342:   <Rights>
  343:     <CopyrightandOtherRestrictions>yes</CopyrightandOtherRestrictions>
  344:     <Description>("en","Copyright 2002 by A Big Green Elephant")</Description>
  345:   </Rights>
  346: 
  347:   <Classification>
  348:       <TaxonPath>
  349:         <Source>Standard Architectural Terms</Source>
  350:         <Taxon><Id>321</Id>
  351:                <Entry>("en","Temporary Shelter")</Entry></Taxon>
  352:         <Taxon><Id>322</Id>
  353:                <Entry>("en","A Really Small Tent")</Entry></Taxon>
  354:       </TaxonPath>
  355:   </Classification>
  356: 
  357: </lom>
  358: END
  359: 
  360: open(OUT,'>tmp_lomnsdl.xml');
  361: print(OUT <<END);
  362: $NSDL_metadata3
  363: END
  364: close(OUT);
  365: 
  366: # ====================================================== Define XSL stylesheets
  367: 
  368: # ------------------------------------------------------- dcnsdl_to_loncapa.xsl
  369: open(OUT,'>dcnsdl_to_loncapa.xsl');
  370: print(OUT <<END);
  371: <?xml version="1.0"?> 
  372: <xsl:stylesheet
  373:   xmlns:dc="http://purl.org/dc/elements/1.1/"
  374:   xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
  375:   xmlns:external="$namespace"
  376: >
  377: <xsl:template match="/">
  378: <loncapa:loncapa
  379:  xmlns:loncapa="http://nsdl.lon-capa.org/loncapa/elements/1.1/">
  380: <xsl:text>
  381: </xsl:text>
  382: <xsl:apply-templates select="/*/dc:identifier"/>
  383: <xsl:apply-templates select="/*/dc:title"/>
  384: <xsl:apply-templates select="/*/dc:language"/>
  385: <xsl:apply-templates select="/*/dc:description"/>
  386: <xsl:apply-templates select="/*/dc:subject"/>
  387: <!-- xsl:apply-templates select="/*/dc:coverage"/ -->
  388: <xsl:apply-templates select="/*/dc:creator"/>
  389: <xsl:apply-templates select="/*/dc:publisher"/>
  390: <xsl:apply-templates select="/*/dc:date"/>
  391: <xsl:apply-templates select="/*/dc:format"/>
  392: <!-- xsl:apply-templates select="/*/dc:type"/ -->
  393: <xsl:apply-templates select="/*/dc:rights"/>
  394: <!-- xsl:apply-templates select="/*/dc:source"/ -->
  395: <!-- xsl:apply-templates select="/*/dc:relation"/ -->
  396: </loncapa:loncapa>
  397: <xsl:text>
  398: </xsl:text>
  399: </xsl:template>
  400: <xsl:template match="dc:identifier">
  401: <uri>
  402:          <xsl:choose>
  403:            <xsl:when 
  404:          test="function-available('external:dcnsdl_identifier_to_loncapa_uri')"
  405:              >
  406:              <xsl:value-of select=
  407:                                "external:dcnsdl_identifier_to_loncapa_uri(.)"/>
  408:            </xsl:when>
  409:            <xsl:otherwise>
  410:          Function external:dcnsdl_identifier_to_loncapa_uri() is not available!
  411:            </xsl:otherwise>
  412:          </xsl:choose>
  413: </uri>
  414: <xsl:text>
  415: </xsl:text>
  416: </xsl:template>
  417: <xsl:template match="dc:title">
  418: <title>
  419:          <xsl:choose>
  420:            <xsl:when
  421:             test="function-available('external:dcnsdl_title_to_loncapa_title')"
  422:              >
  423:              <xsl:value-of select="external:dcnsdl_title_to_loncapa_title(.)"/>
  424:            </xsl:when>
  425:            <xsl:otherwise>
  426:             Function external:dcnsdl_title_to_loncapa_title() is not available!
  427:            </xsl:otherwise>
  428:          </xsl:choose>
  429: </title>
  430: <xsl:text>
  431: </xsl:text>
  432: </xsl:template>
  433: <xsl:template match="dc:language">
  434: <language>
  435:          <xsl:choose>
  436:            <xsl:when
  437:       test="function-available('external:dcnsdl_language_to_loncapa_language')"
  438:              >
  439:              <xsl:value-of select=
  440:                             "external:dcnsdl_language_to_loncapa_language(.)"/>
  441:            </xsl:when>
  442:            <xsl:otherwise>
  443:       Function external:dcnsdl_language_to_loncapa_language() is not available!
  444:            </xsl:otherwise>
  445:          </xsl:choose>
  446: </language>
  447: <xsl:text>
  448: </xsl:text>
  449: </xsl:template>
  450: <xsl:template match="dc:description">
  451: <abstract>
  452:          <xsl:choose>
  453:            <xsl:when
  454:    test="function-available('external:dcnsdl_description_to_loncapa_abstract')"
  455:              >
  456:              <xsl:value-of select=
  457:                          "external:dcnsdl_description_to_loncapa_abstract(.)"/>
  458:            </xsl:when>
  459:            <xsl:otherwise>
  460:    Function external:dcnsdl_description_to_loncapa_abstract() is not available!
  461:            </xsl:otherwise>
  462:          </xsl:choose>
  463: </abstract>
  464: <xsl:text>
  465: </xsl:text>
  466: </xsl:template>
  467: <xsl:template match="dc:subject">
  468: <subject>
  469:          <xsl:choose>
  470:            <xsl:when
  471:         test="function-available('external:dcnsdl_subject_to_loncapa_subject')"
  472:              >
  473:              <xsl:value-of select=
  474:                               "external:dcnsdl_subject_to_loncapa_subject(.)"/>
  475:            </xsl:when>
  476:            <xsl:otherwise>
  477:         Function external:dcnsdl_subject_to_loncapa_subject() is not available!
  478:            </xsl:otherwise>
  479:          </xsl:choose>
  480: </subject>
  481: <xsl:text>
  482: </xsl:text>
  483: </xsl:template>
  484: <xsl:template match="dc:creator">
  485: <author>
  486:          <xsl:choose>
  487:            <xsl:when
  488:         test="function-available('external:dcnsdl_creator_to_loncapa_author')"
  489:              >
  490:              <xsl:value-of select=
  491:                                "external:dcnsdl_creator_to_loncapa_author(.)"/>
  492:            </xsl:when>
  493:            <xsl:otherwise>
  494:          Function external:dcnsdl_creator_to_loncapa_author() is not available!
  495:            </xsl:otherwise>
  496:          </xsl:choose>
  497: </author>
  498: <xsl:text>
  499: </xsl:text>
  500: </xsl:template>
  501: <xsl:template match="dc:publisher">
  502: <owner>
  503:          <xsl:choose>
  504:            <xsl:when
  505:         test="function-available('external:dcnsdl_publisher_to_loncapa_owner')"
  506:              >
  507:              <xsl:value-of select=
  508:                               "external:dcnsdl_publisher_to_loncapa_owner(.)"/>
  509:            </xsl:when>
  510:            <xsl:otherwise>
  511:         Function external:dcnsdl_publisher_to_loncapa_owner() is not available!
  512:            </xsl:otherwise>
  513:          </xsl:choose>
  514: </owner>
  515: <xsl:text>
  516: </xsl:text>
  517: </xsl:template>
  518: <xsl:template match="dc:date">
  519: <lastrevisiondate>
  520:          <xsl:choose>
  521:            <xsl:when
  522:   test="function-available('external:dcnsdl_date_to_loncapa_lastrevisiondate')"
  523:              >
  524:              <xsl:value-of select=
  525:                         "external:dcnsdl_date_to_loncapa_lastrevisiondate(.)"/>
  526:            </xsl:when>
  527:            <xsl:otherwise>
  528:   Function external:dcnsdl_date_to_loncapa_lastrevisiondate() is not available!
  529:            </xsl:otherwise>
  530:          </xsl:choose>
  531: </lastrevisiondate>
  532: <xsl:text>
  533: </xsl:text>
  534: </xsl:template>
  535: <xsl:template match="dc:format">
  536: <mime>
  537:          <xsl:choose>
  538:            <xsl:when
  539:             test="function-available('external:dcnsdl_format_to_loncapa_mime')"
  540:              >
  541:              <xsl:value-of select=
  542:                                   "external:dcnsdl_format_to_loncapa_mime(.)"/>
  543:            </xsl:when>
  544:            <xsl:otherwise>
  545:             Function external:dcnsdl_format_to_loncapa_mime() is not available!
  546:            </xsl:otherwise>
  547:          </xsl:choose>
  548: </mime>
  549: <xsl:text>
  550: </xsl:text>
  551: </xsl:template>
  552: <xsl:template match="dc:rights">
  553: <copyright>
  554:          <xsl:choose>
  555:            <xsl:when
  556:        test="function-available('external:dcnsdl_rights_to_loncapa_copyright')"
  557:              >
  558:              <xsl:value-of select=
  559:                              "external:dcnsdl_rights_to_loncapa_copyright(.)"/>
  560:            </xsl:when>
  561:            <xsl:otherwise>
  562:        Function external:dcnsdl_rights_to_loncapa_copyright() is not available!
  563:            </xsl:otherwise>
  564:          </xsl:choose>
  565: </copyright>
  566: <xsl:text>
  567: </xsl:text>
  568: </xsl:template>
  569: </xsl:stylesheet>
  570: END
  571: close(OUT);
  572: 
  573: # ------------------------------------------------------- loncapa_to_dcnsdl.xsl
  574: open(OUT,'>loncapa_to_dcnsdl.xsl');
  575: print(OUT <<END);
  576: <?xml version="1.0"?> 
  577: <xsl:stylesheet
  578:   xmlns:loncapa="http://nsdl.lon-capa.org/loncapa/elements/1.1/"
  579:   xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
  580:   xmlns:external="$namespace"
  581: >
  582: <xsl:template match="/">
  583: <dc:dc xmlns:dc="http://purl.org/dc/elements/1.1/">
  584: <xsl:text>
  585: </xsl:text>
  586: <!-- xsl:apply-templates select="/*/loncapa:*"/ -->
  587: <xsl:apply-templates select="/*/loncapa:title"/>
  588: <xsl:apply-templates select="/*/loncapa:author"/>
  589: <xsl:apply-templates select="/*/loncapa:owner"/>
  590: <xsl:apply-templates select="/*/loncapa:subject"/>
  591: <xsl:apply-templates select="/*/loncapa:abstract"/>
  592: <xsl:apply-templates select="/*/loncapa:lastrevisiondate"/>
  593: <xsl:apply-templates select="/*/loncapa:mime"/>
  594: <xsl:apply-templates select="/*/loncapa:uri"/>
  595: <xsl:apply-templates select="/*/loncapa:language"/>
  596: <xsl:apply-templates select="/*/loncapa:copyright"/>
  597: <dc:relation>[unknown]</dc:relation>
  598: <xsl:text>
  599: </xsl:text>
  600: <dc:source>[unknown]</dc:source>
  601: <xsl:text>
  602: </xsl:text>
  603: <dc:coverage>[unknown]</dc:coverage>
  604: <xsl:text>
  605: </xsl:text>
  606: <xsl:apply-templates select="/*/loncapa:copyright"/>
  607: </dc:dc>
  608: <xsl:text>
  609: </xsl:text>
  610: </xsl:template>
  611: <xsl:template match="loncapa:title">
  612: <dc:title>
  613:          <xsl:choose>
  614:            <xsl:when
  615:                  test=
  616:                  "function-available('external:loncapa_title_to_dcnsdl_title')"
  617:              >
  618:              <xsl:value-of select="external:loncapa_title_to_dcnsdl_title(.)"/>
  619:            </xsl:when>
  620:            <xsl:otherwise>
  621:             Function external:loncapa_title_to_dcnsdl_title() is not available!
  622:            </xsl:otherwise>
  623:          </xsl:choose>
  624: </dc:title>
  625: <xsl:text>
  626: </xsl:text>
  627: </xsl:template>
  628: <xsl:template match="loncapa:author">
  629: <dc:contributor>
  630:          <xsl:choose>
  631:            <xsl:when
  632:                  test=
  633:           "function-available('external:loncapa_author_to_dcnsdl_contributor')"
  634:              >
  635:              <xsl:value-of
  636:                     select="external:loncapa_author_to_dcnsdl_contributor(.)"/>
  637:            </xsl:when>
  638:            <xsl:otherwise>
  639:      Function external:loncapa_author_to_dcnsdl_contributor() is not available!
  640:            </xsl:otherwise>
  641:          </xsl:choose>
  642: </dc:contributor>
  643: <xsl:text>
  644: </xsl:text>
  645: <dc:creator>
  646:          <xsl:choose>
  647:            <xsl:when
  648:                  test=
  649:               "function-available('external:loncapa_author_to_dcnsdl_creator')"
  650:              >
  651:              <xsl:value-of
  652:                         select="external:loncapa_author_to_dcnsdl_creator(.)"/>
  653:            </xsl:when>
  654:            <xsl:otherwise>
  655:          Function external:loncapa_author_to_dcnsdl_creator() is not available!
  656:            </xsl:otherwise>
  657:          </xsl:choose>
  658: </dc:creator>
  659: <xsl:text>
  660: </xsl:text>
  661: </xsl:template>
  662: <xsl:template match="loncapa:owner">
  663: <dc:publisher>
  664:          <xsl:choose>
  665:            <xsl:when
  666:                  test=
  667:              "function-available('external:loncapa_owner_to_dcnsdl_publisher')"
  668:              >
  669:              <xsl:value-of
  670:                        select="external:loncapa_owner_to_dcnsdl_publisher(.)"/>
  671:            </xsl:when>
  672:            <xsl:otherwise>
  673:         Function external:loncapa_owner_to_dcnsdl_publisher() is not available!
  674:            </xsl:otherwise>
  675:          </xsl:choose>
  676: </dc:publisher>
  677: <xsl:text>
  678: </xsl:text>
  679: </xsl:template>
  680: <xsl:template match="loncapa:subject">
  681: <dc:subject>
  682:          <xsl:choose>
  683:            <xsl:when
  684:                  test=
  685:              "function-available('external:loncapa_subject_to_dcnsdl_subject')"
  686:              >
  687:            <xsl:value-of
  688:                        select="external:loncapa_subject_to_dcnsdl_subject(.)"/>
  689:            </xsl:when>
  690:            <xsl:otherwise>
  691:         Function external:loncapa_subject_to_dcnsdl_subject() is not available!
  692:            </xsl:otherwise>
  693:          </xsl:choose>
  694: </dc:subject>
  695: <xsl:text>
  696: </xsl:text>
  697: </xsl:template>
  698: <xsl:template match="loncapa:abstract">
  699: <dc:description>
  700:          <xsl:choose>
  701:            <xsl:when
  702:                  test=
  703:         "function-available('external:loncapa_abstract_to_dcnsdl_description')"
  704:              >
  705:              <xsl:value-of
  706:                   select="external:loncapa_abstract_to_dcnsdl_description(.)"/>
  707:            </xsl:when>
  708:            <xsl:otherwise>
  709:    Function external:loncapa_abstract_to_dcnsdl_description() is not available!
  710:            </xsl:otherwise>
  711:          </xsl:choose>
  712: </dc:description>
  713: <xsl:text>
  714: </xsl:text>
  715: </xsl:template>
  716: <xsl:template match="loncapa:lastrevisiondate">
  717: <date>
  718:          <xsl:choose>
  719:            <xsl:when
  720:                  test=
  721:        "function-available('external:loncapa_lastrevisiondate_to_dcnsdl_date')"
  722:              >
  723:              <xsl:value-of select=
  724:                         "external:loncapa_lastrevisiondate_to_dcnsdl_date(.)"/>
  725:            </xsl:when>
  726:            <xsl:otherwise>
  727:   Function external:loncapa_lastrevisiondate_to_dcnsdl_date() is not available!
  728:            </xsl:otherwise>
  729:          </xsl:choose>
  730: </date>
  731: <xsl:text>
  732: </xsl:text>
  733: </xsl:template>
  734: <xsl:template match="loncapa:mime">
  735: <dc:type>
  736:          <xsl:choose>
  737:            <xsl:when
  738:                  test=
  739:                    "function-available('external:loncapa_mime_to_dcnsdl_type')"
  740:              >
  741:              <xsl:value-of select="external:loncapa_mime_to_dcnsdl_type(.)"/>
  742:            </xsl:when>
  743:            <xsl:otherwise>
  744:               Function external:loncapa_mime_to_dcnsdl_type() is not available!
  745:            </xsl:otherwise>
  746:          </xsl:choose>
  747: </dc:type>
  748: <xsl:text>
  749: </xsl:text>
  750: <dc:format>
  751:          <xsl:choose>
  752:            <xsl:when
  753:                  test=
  754:                  "function-available('external:loncapa_mime_to_dcnsdl_format')"
  755:              >
  756:              <xsl:value-of select="external:loncapa_mime_to_dcnsdl_format(.)"/>
  757:            </xsl:when>
  758:            <xsl:otherwise>
  759:             Function external:loncapa_mime_to_dcnsdl_format() is not available!
  760:            </xsl:otherwise>
  761:          </xsl:choose>
  762: </dc:format>
  763: <xsl:text>
  764: </xsl:text>
  765: </xsl:template>
  766: <xsl:template match="loncapa:uri">
  767: <dc:identifier>
  768:          <xsl:choose>
  769:            <xsl:when
  770:                  test=
  771:               "function-available('external:loncapa_uri_to_dcnsdl_identifier')"
  772:              >
  773:              <xsl:value-of select=
  774:                                "external:loncapa_uri_to_dcnsdl_identifier(.)"/>
  775:            </xsl:when>
  776:            <xsl:otherwise>
  777:          Function external:loncapa_uri_to_dcnsdl_identifier() is not available!
  778:            </xsl:otherwise>
  779:          </xsl:choose>
  780: </dc:identifier>
  781: <xsl:text>
  782: </xsl:text>
  783: </xsl:template>
  784: <xsl:template match="loncapa:language">
  785: <dc:language>
  786:          <xsl:choose>
  787:            <xsl:when
  788:                  test=
  789:            "function-available('external:loncapa_language_to_dcnsdl_language')"
  790:              >
  791:              <xsl:value-of select=
  792:                             "external:loncapa_language_to_dcnsdl_language(.)"/>
  793:            </xsl:when>
  794:            <xsl:otherwise>
  795:       Function external:loncapa_language_to_dcnsdl_language() is not available!
  796:            </xsl:otherwise>
  797:          </xsl:choose>
  798: </dc:language>
  799: <xsl:text>
  800: </xsl:text>
  801: </xsl:template>
  802: <xsl:template match="loncapa:copyright">
  803: <dc:rights>
  804:          <xsl:choose>
  805:            <xsl:when
  806:                  test=
  807:             "function-available('external:loncapa_copyright_to_dcnsdl_rights')"
  808:              >
  809:              <xsl:value-of select=
  810:                             "external:loncapa_copyright_to_dcnsdl_rights(.)"/>
  811:            </xsl:when>
  812:            <xsl:otherwise>
  813:        Function external:loncapa_copyright_to_dcnsdl_rights() is not available!
  814:            </xsl:otherwise>
  815:          </xsl:choose>
  816: </dc:rights>
  817: <xsl:text>
  818: </xsl:text>
  819: </xsl:template>
  820: </xsl:stylesheet>
  821: END
  822: close(OUT);
  823: 
  824: # ------------------------------------------------------ lomnsdl_to_loncapa.xsl
  825: open(OUT,'>lomnsdl_to_loncapa.xsl');
  826: print(OUT <<END);
  827: <?xml version="1.0"?> 
  828: <xsl:stylesheet
  829:   xmlns:lom="http://nsdl.lon-capa.org/lom/elements/6.4/"
  830:   xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
  831:   xmlns:external="$namespace"
  832: >
  833: <xsl:template match="/">
  834: <loncapa:loncapa
  835:  xmlns:loncapa="http://nsdl.lon-capa.org/loncapa/elements/1.1/">
  836: <xsl:text>
  837: </xsl:text>
  838: <xsl:apply-templates select="/*/lom:General/lom:Identifier"/>
  839: <xsl:apply-templates select="/*/lom:General/lom:Title"/>
  840: <xsl:apply-templates select="/*/lom:General/lom:Language"/>
  841: <xsl:apply-templates select="/*/lom:General/lom:Description"/>
  842: <xsl:apply-templates select="/*/lom:General/lom:Keyword"/>
  843: <xsl:apply-templates select="/*/lom:LifeCycle/lom:Contribute"/>
  844: <xsl:apply-templates select="/*/lom:Technical/lom:Format"/>
  845: <xsl:apply-templates select="/*/lom:Technical/lom:Size"/>
  846: <xsl:apply-templates select="/*/lom:Educational/lom:Description"/>
  847: <xsl:apply-templates select="/*/lom:Rights/lom:CopyrightandOtherRestrictions"/>
  848: <xsl:apply-templates select="/*/lom:Rights/lom:Description"/>
  849: </loncapa:loncapa>
  850: </xsl:template>
  851: <xsl:template match="lom:General/lom:Identifier">
  852: <uri>http://nsdl.lon-capa.org/gateres/<xsl:value-of select="lom:Catalog"/>/<xsl:value-of select="lom:Entry"/>
  853: </uri>
  854: <xsl:text>
  855: </xsl:text>
  856: </xsl:template>
  857: <xsl:template match="lom:General/lom:Title">
  858: <title>
  859:          <xsl:choose>
  860:            <xsl:when 
  861:     test="function-available('external:lomnsdl_GeneralTitle_to_loncapa_title')"
  862:              >
  863:              <xsl:value-of select=
  864:                           "external:lomnsdl_GeneralTitle_to_loncapa_title(.)"/>
  865:            </xsl:when>
  866:            <xsl:otherwise>
  867:     Function external:lomnsdl_GeneralTitle_to_loncapa_title() is not available!
  868:            </xsl:otherwise>
  869:          </xsl:choose>
  870: </title>
  871: <xsl:text>
  872: </xsl:text>
  873: </xsl:template>
  874: <xsl:template match="lom:General/lom:Language">
  875: <language>
  876:          <xsl:choose>
  877:            <xsl:when
  878:                  test=
  879:    "function-available('external:lomnsdl_GeneralLanguage_to_loncapa_language')"
  880:              >
  881:              <xsl:value-of select=
  882:                     "external:lomnsdl_GeneralLanguage_to_loncapa_language(.)"/>
  883:            </xsl:when>
  884:            <xsl:otherwise>
  885: Function external:lomnsdl_GeneralLanguage_to_loncapa_language() is not
  886: available!
  887:            </xsl:otherwise>
  888:          </xsl:choose>
  889: </language>
  890: <xsl:text>
  891: </xsl:text>
  892: </xsl:template>
  893: <xsl:template match="lom:General/lom:Keyword">
  894: <keywords>
  895:          <xsl:choose>
  896:            <xsl:when
  897:                  test=
  898:     "function-available('external:lomnsdl_GeneralKeyword_to_loncapa_keywords')"
  899:              >
  900:              <xsl:value-of select=
  901:                      "external:lomnsdl_GeneralKeyword_to_loncapa_keywords(.)"/>
  902:            </xsl:when>
  903:            <xsl:otherwise>
  904: Function external:lomnsdl_GeneralKeyword_to_loncapa_keywords() is not
  905: available!
  906:            </xsl:otherwise>
  907:          </xsl:choose>
  908: </keywords>
  909: <xsl:text>
  910: </xsl:text>
  911: </xsl:template>
  912: <xsl:template match="lom:LifeCycle/lom:Contribute">
  913:          <xsl:choose>
  914:            <xsl:when
  915:                test="function-available('external:lomnsdl_LifeCycleContribute_prepare_converter_INFO')"
  916:              >
  917:              <xsl:value-of select=
  918:         "external:lomnsdl_LifeCycleContribute_prepare_converter_INFO(.)"/>
  919:            </xsl:when>
  920:            <xsl:otherwise>
  921: Function external:lomnsdl_LifeCycleContribute_prepare_converter_INFO()
  922: is not available!
  923:            </xsl:otherwise>
  924:          </xsl:choose>
  925: <xsl:apply-templates select="/*/lom:LifeCycle/lom:Contribute/lom:Role"/>
  926: <xsl:apply-templates select="/*/lom:LifeCycle/lom:Contribute/lom:Entity"/>
  927: <xsl:apply-templates select="/*/lom:LifeCycle/lom:Contribute/lom:Date"/>
  928:          <xsl:choose>
  929:            <xsl:when
  930:                test="function-available('external:converter_INFO_to_loncapa_lastrevisiondate')"
  931:              >
  932:              <xsl:value-of select=
  933:         "external:converter_INFO_to_loncapa_lastrevisiondate(.)"/>
  934:            </xsl:when>
  935:            <xsl:otherwise>
  936: Function external:converter_INFO_to_loncapa_lastrevisiondate()
  937: is not available!
  938:            </xsl:otherwise>
  939:          </xsl:choose>
  940:          <xsl:choose>
  941:            <xsl:when
  942:                test="function-available('external:converter_INFO_to_loncapa_creationdate')"
  943:              >
  944:              <xsl:value-of select=
  945:         "external:converter_INFO_to_loncapa_creationdate(.)"/>
  946:            </xsl:when>
  947:            <xsl:otherwise>
  948: Function external:converter_INFO_to_loncapa_creationdate()
  949: is not available!
  950:            </xsl:otherwise>
  951:          </xsl:choose>
  952:          <xsl:choose>
  953:            <xsl:when
  954:                test="function-available('external:converter_INFO_to_loncapa_author')"
  955:              >
  956:              <xsl:value-of select=
  957:         "external:converter_INFO_to_loncapa_author(.)"/>
  958:            </xsl:when>
  959:            <xsl:otherwise>
  960: Function external:converter_INFO_to_loncapa_author()
  961: is not available!
  962:            </xsl:otherwise>
  963:          </xsl:choose>
  964:          <xsl:choose>
  965:            <xsl:when
  966:                test="function-available('external:converter_INFO_to_loncapa_owner')"
  967:              >
  968:              <xsl:value-of select=
  969:         "external:converter_INFO_to_loncapa_owner(.)"/>
  970:            </xsl:when>
  971:            <xsl:otherwise>
  972: Function external:converter_INFO_to_loncapa_owner()
  973: is not available!
  974:            </xsl:otherwise>
  975:          </xsl:choose>
  976: </xsl:template>
  977: <xsl:template match="lom:LifeCycle/lom:Contribute/lom:Role">
  978:          <xsl:choose>
  979:            <xsl:when
  980:                test="function-available('external:lomnsdl_LifeCycleContributeRole_to_converter_INFO')"
  981:              >
  982:              <xsl:value-of select=
  983:               "external:lomnsdl_LifeCycleContributeRole_to_converter_INFO(.)"/>
  984:            </xsl:when>
  985:            <xsl:otherwise>
  986: Function external:lomnsdl_LifeCycleContributeRole_to_converter_INFO() is not
  987: available!
  988:            </xsl:otherwise>
  989:          </xsl:choose>
  990: </xsl:template>
  991: <xsl:template match="lom:LifeCycle/lom:Contribute/lom:Entry">
  992:          <xsl:choose>
  993:            <xsl:when
  994:                test="function-available('external:lomnsdl_LifeCycleContributeEntry_to_converter_INFO')"
  995:              >
  996:              <xsl:value-of select=
  997:              "external:lomnsdl_LifeCycleContributeEntry_to_converter_INFO(.)"/>
  998:            </xsl:when>
  999:            <xsl:otherwise>
 1000: Function external:lomnsdl_LifeCycleContributeEntry_to_converter_INFO() is not
 1001: available!
 1002:            </xsl:otherwise>
 1003:          </xsl:choose>
 1004: </xsl:template>
 1005: <xsl:template match="lom:LifeCycle/lom:Contribute/lom:Date">
 1006:          <xsl:choose>
 1007:            <xsl:when
 1008:                test="function-available('external:lomnsdl_LifeCycleContributeDate_to_converter_INFO')"
 1009:              >
 1010:              <xsl:value-of select=
 1011:               "external:lomnsdl_LifeCycleContributeDate_to_converter_INFO(.)"/>
 1012:            </xsl:when>
 1013:            <xsl:otherwise>
 1014: Function external:lomnsdl_LifeCycleContributeDate_to_converter_INFO() is not
 1015: available!
 1016:            </xsl:otherwise>
 1017:          </xsl:choose>
 1018: </xsl:template>
 1019: <xsl:template match="lom:Technical/lom:Format">
 1020: <mime>
 1021:          <xsl:choose>
 1022:            <xsl:when
 1023:   test="function-available('external:lomnsdl_TechnicalFormat_to_loncapa_mime')"
 1024:              >
 1025:              <xsl:value-of select=
 1026:                         "external:lomnsdl_TechnicalFormat_to_loncapa_mime(.)"/>
 1027:            </xsl:when>
 1028:            <xsl:otherwise>
 1029:   Function external:lomnsdl_TechnicalFormat_to_loncapa_mime() is not available!
 1030:            </xsl:otherwise>
 1031:          </xsl:choose>
 1032: </mime>
 1033: <xsl:text>
 1034: </xsl:text>
 1035: </xsl:template>
 1036: <xsl:template match="lom:Technical/lom:Size">
 1037: <bytesize>
 1038:          <xsl:choose>
 1039:            <xsl:when
 1040: test="function-available('external:lomnsdl_TechnicalSize_to_loncapa_bytesize')"
 1041:              >
 1042:              <xsl:value-of select=
 1043:                   "external:lomnsdl_TechnicalSize_to_loncapa_bytesize(.)"/>
 1044:            </xsl:when>
 1045:            <xsl:otherwise>
 1046: Function external:lomnsdl_TechnicalSize_to_loncapa_bytesize() is not available!
 1047:            </xsl:otherwise>
 1048:          </xsl:choose>
 1049: </bytesize>
 1050: <xsl:text>
 1051: </xsl:text>
 1052: </xsl:template>
 1053: <xsl:template match="lom:Educational/lom:Description">
 1054: <notes>
 1055:          <xsl:choose>
 1056:            <xsl:when
 1057:   test="function-available('external:lomnsdl_EducationalDescription_to_loncapa_notes')"
 1058:              >
 1059:              <xsl:value-of select=
 1060:                         "external:lomnsdl_EducationalDescription_to_loncapa_notes(.)"/>
 1061:            </xsl:when>
 1062:            <xsl:otherwise>
 1063: Function external:lomnsdl_EducationalDescription_to_loncapa_notes() is not
 1064: available!
 1065:            </xsl:otherwise>
 1066:          </xsl:choose>
 1067: </notes>
 1068: <xsl:text>
 1069: </xsl:text>
 1070: </xsl:template>
 1071: <xsl:template match="lom:Rights">
 1072:          <xsl:choose>
 1073:            <xsl:when
 1074:                test="function-available('external:lomnsdl_Rights_prepare_converter_INFO')"
 1075:              >
 1076:              <xsl:value-of select=
 1077:         "external:lomnsdl_Rights_prepare_converter_INFO(.)"/>
 1078:            </xsl:when>
 1079:            <xsl:otherwise>
 1080:     Function external:lomnsdl_Rights_prepare_converter_INFO() is not available!
 1081:            </xsl:otherwise>
 1082:          </xsl:choose>
 1083: <xsl:apply-templates select="/*/lom:Rights/lom:CopyrightandOtherRestrictions"/>
 1084: <xsl:apply-templates select="/*/lom:Rights/lom:Description"/>
 1085:          <xsl:choose>
 1086:            <xsl:when
 1087:                test=
 1088:            "function-available('external:converter_INFO_to_loncapa_copyright')"
 1089:              >
 1090:              <xsl:value-of select=
 1091:         "external:converter_INFO_to_loncapa_copyright(.)"/>
 1092:            </xsl:when>
 1093:            <xsl:otherwise>
 1094: Function external:converter_INFO_to_loncapa_copyright() is not available!
 1095:            </xsl:otherwise>
 1096:          </xsl:choose>
 1097: </xsl:template>
 1098: <xsl:template match="lom:Rights/lom:CopyrightandOtherRestrictions">
 1099:          <xsl:choose>
 1100:            <xsl:when
 1101:             test="function-available('external:lomnsdl_RightsCopyrightandOtherRestrictions_to_converter_INFO')"
 1102:              >
 1103:              <xsl:value-of select=
 1104:   "external:lomnsdl_RightsCopyrightandOtherRestrictions_to_converter_INFO(.)"/>
 1105:            </xsl:when>
 1106:            <xsl:otherwise>
 1107: Function
 1108: external:lomnsdl_RightsCopyrightandOtherRestrictions_to_converter_INFO()
 1109: is not available!
 1110:            </xsl:otherwise>
 1111:          </xsl:choose>
 1112: </xsl:template>
 1113: <xsl:template match="lom:Rights/lom:Description">
 1114:          <xsl:choose>
 1115:            <xsl:when
 1116:             test="function-available('external:lomnsdl_RightsDescription_to_converter_INFO')"
 1117:              >
 1118:              <xsl:value-of select=
 1119:   "external:lomnsdl_RightsDescription_to_converter_INFO(.)"/>
 1120:            </xsl:when>
 1121:            <xsl:otherwise>
 1122: Function external:lomnsdl_RightsDescription_to_converter_INFO() is not
 1123: available!
 1124:            </xsl:otherwise>
 1125:          </xsl:choose>
 1126: </xsl:template>
 1127: </xsl:stylesheet>
 1128: END
 1129: 
 1130: # ------------------------------------------------------ loncapa_to_lomnsdl.xsl
 1131: open(OUT,'>loncapa_to_lomnsdl.xsl');
 1132: print(OUT <<END);
 1133: <?xml version="1.0"?> 
 1134: <xsl:stylesheet
 1135:   xmlns:loncapa="http://nsdl.lon-capa.org/loncapa/elements/1.1/"
 1136:   xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
 1137:   xmlns:external="$namespace"
 1138: >
 1139: <xsl:template match="/">
 1140: <!-- These values are stored in memory (converter_INFO) -->
 1141: <xsl:apply-templates select="/*/loncapa:language"/>
 1142: <xsl:apply-templates select="/*/loncapa:author"/>
 1143: <xsl:apply-templates select="/*/loncapa:lastrevisiondate"/>
 1144: <xsl:apply-templates select="/*/loncapa:metauri"/>
 1145: <xsl:apply-templates select="/*/loncapa:copyright"/>
 1146: <xsl:apply-templates select="/*/loncapa:owner"/>
 1147: <lom:lom xmlns:lom="http://nsdl.lon-capa.org/lom/elements/6.4/">
 1148: <xsl:text>
 1149: </xsl:text>
 1150: <General>
 1151:  <Identifier>
 1152:   <Catalog>LON</Catalog>
 1153:          <xsl:choose>
 1154:            <xsl:when
 1155:                  test=
 1156:          "function-available('external:converter_INFO_to_lomnsdl_GeneralIdentifierEntry')"
 1157:              >
 1158:      <xsl:value-of select="external:converter_INFO_to_lomnsdl_GeneralIdentifierEntry(.)"/>
 1159:            </xsl:when>
 1160:            <xsl:otherwise>
 1161: Function external:converter_INFO_to_lomnsdl_GeneralIdentifierEntry() is not
 1162: available!
 1163:            </xsl:otherwise>
 1164:          </xsl:choose>
 1165:  </Identifier>
 1166:  <xsl:apply-templates select="/*/loncapa:title"/>
 1167:          <xsl:choose>
 1168:            <xsl:when
 1169:                  test=
 1170:          "function-available('external:converter_INFO_to_lomnsdl_GeneralLanguage')"
 1171:              >
 1172:      <xsl:value-of select="external:converter_INFO_to_lomnsdl_GeneralLanguage(.)"/>
 1173:            </xsl:when>
 1174:            <xsl:otherwise>
 1175:     Function external:converter_INFO_to_lomnsdl_GeneralLanguage() is not available!
 1176:            </xsl:otherwise>
 1177:          </xsl:choose>
 1178:  <xsl:apply-templates select="/*/loncapa:abstract"/>
 1179:  <xsl:apply-templates select="/*/loncapa:keywords"/>
 1180:  <xsl:apply-templates select="/*/loncapa:structure"/>
 1181:  <xsl:apply-templates select="/*/loncapa:aggregation"/>
 1182: </General>
 1183: 
 1184: <LifeCycle>
 1185:  <xsl:apply-templates select="/*/loncapa:version"/>
 1186:  <Contribute>
 1187:  <Role>author</Role>
 1188:  <Entity>
 1189:          <xsl:choose>
 1190:            <xsl:when
 1191:                  test=
 1192:       "function-available('external:converter_INFO_to_lomnsdl_LifeCycleContributeEntity')"
 1193:              >
 1194:      <xsl:value-of select="external:converter_INFO_to_lomnsdl_LifeCycleContributeEntity(.)"/>
 1195:            </xsl:when>
 1196:            <xsl:otherwise>
 1197:     Function external:converter_INFO_to_lomnsdl_LifeCycleContributeEntity() is not available!
 1198:            </xsl:otherwise>
 1199:          </xsl:choose>
 1200:  </Entity>
 1201:  <Date>
 1202:          <xsl:choose>
 1203:            <xsl:when
 1204:                  test=
 1205:          "function-available('external:converter_INFO_to_lomnsdl_LifeCycleContributeDate')"
 1206:              >
 1207:      <xsl:value-of select="external:converter_INFO_to_lomnsdl_LifeCycleContributeDate(.)"/>
 1208:            </xsl:when>
 1209:            <xsl:otherwise>
 1210:     Function external:converter_INFO_to_lomnsdl_LifeCycleContributeDate() is not available!
 1211:            </xsl:otherwise>
 1212:          </xsl:choose>
 1213:  </Date>
 1214:  </Contribute>
 1215: </LifeCycle>
 1216: 
 1217: <MetaMetadata>
 1218:          <xsl:choose>
 1219:            <xsl:when
 1220:                  test=
 1221:         "function-available('external:converter_INFO_to_lomnsdl_MetaMetadata')"
 1222:              >
 1223:     <xsl:value-of select="external:converter_INFO_to_lomnsdl_MetaMetadata(.)"/>
 1224:            </xsl:when>
 1225:            <xsl:otherwise>
 1226:    Function external:converter_INFO_to_lomnsdl_MetaMetadata() is not available!
 1227:            </xsl:otherwise>
 1228:          </xsl:choose>
 1229: </MetaMetadata>
 1230: 
 1231: <Technical>
 1232:  <xsl:apply-templates select="/*/loncapa:mime"/>
 1233:  <xsl:apply-templates select="/*/loncapa:bytesize"/>
 1234:  <Location>
 1235:          <xsl:choose>
 1236:            <xsl:when
 1237:                  test=
 1238:    "function-available('external:converter_INFO_to_lomnsdl_TechnicalLocation')"
 1239:              >
 1240:              <xsl:value-of 
 1241:              select="external:converter_INFO_to_lomnsdl_TechnicalLocation(.)"/>
 1242:            </xsl:when>
 1243:            <xsl:otherwise>
 1244:    Function external:converter_INFO_to_lomnsdl_TechnicalLocation() is not
 1245: available!
 1246:            </xsl:otherwise>
 1247:          </xsl:choose>
 1248:  </Location>
 1249:  <Requirement>
 1250:          <xsl:choose>
 1251:            <xsl:when
 1252:                  test=
 1253: "function-available('external:converter_INFO_to_lomnsdl_TechnicalRequirement')"
 1254:              >
 1255:              <xsl:value-of 
 1256:           select="external:converter_INFO_to_lomnsdl_TechnicalRequirement(.)"/>
 1257:            </xsl:when>
 1258:            <xsl:otherwise>
 1259:    Function external:converter_INFO_to_lomnsdl_TechnicalRequirement() is not
 1260: available!
 1261:            </xsl:otherwise>
 1262:          </xsl:choose>
 1263:  </Requirement>
 1264: </Technical>
 1265: 
 1266: <Educational>
 1267:  <xsl:apply-templates select="/*/loncapa:notes"/>
 1268:  <Language>
 1269:          <xsl:choose>
 1270:            <xsl:when
 1271:                  test=
 1272: "function-available('external:converter_INFO_to_lomnsdl_EducationalLanguage')"
 1273:              >
 1274:              <xsl:value-of 
 1275:           select="external:converter_INFO_to_lomnsdl_EducationalLanguage(.)"/>
 1276:            </xsl:when>
 1277:            <xsl:otherwise>
 1278:    Function external:converter_INFO_to_lomnsdl_EducationalLanguage() is not
 1279: available!
 1280:            </xsl:otherwise>
 1281:          </xsl:choose>
 1282:  </Language>
 1283: </Educational>
 1284: 
 1285: <Rights>
 1286:  <CopyrightandOtherRestrictions>yes</CopyrightandOtherRestrictions>
 1287:  <Description>
 1288:          <xsl:choose>
 1289:            <xsl:when
 1290:                  test=
 1291: "function-available('external:converter_INFO_to_lomnsdl_RightsDescription')"
 1292:              >
 1293:              <xsl:value-of 
 1294:           select="external:converter_INFO_to_lomnsdl_RightsDescription(.)"/>
 1295:            </xsl:when>
 1296:            <xsl:otherwise>
 1297:          Function external:converter_INFO_to_lomnsdl_RightsDescription() is not
 1298: available!
 1299:            </xsl:otherwise>
 1300:          </xsl:choose>
 1301:  </Description>
 1302: </Rights>
 1303: <xsl:text>
 1304: </xsl:text>
 1305: 
 1306: </lom:lom>
 1307: </xsl:template>
 1308: <xsl:template match="loncapa:title">
 1309: <Title>
 1310:          <xsl:choose>
 1311:            <xsl:when
 1312:                  test=
 1313:          "function-available('external:loncapa_title_to_lomnsdl_GeneralTitle')"
 1314:              >
 1315:      <xsl:value-of select="external:loncapa_title_to_lomnsdl_GeneralTitle(.)"/>
 1316:            </xsl:when>
 1317:            <xsl:otherwise>
 1318:     Function external:loncapa_title_to_lomnsdl_GeneralTitle() is not available!
 1319:            </xsl:otherwise>
 1320:          </xsl:choose>
 1321: </Title>
 1322: <xsl:text>
 1323: </xsl:text>
 1324: </xsl:template>
 1325: <xsl:template match="loncapa:abstract">
 1326: <Description>
 1327:          <xsl:choose>
 1328:            <xsl:when
 1329:                  test=
 1330: "function-available('external:loncapa_abstract_to_lomnsdl_GeneralDescription')"
 1331:              >
 1332:      <xsl:value-of select=
 1333:                  "external:loncapa_abstract_to_lomnsdl_GeneralDescription(.)"/>
 1334:            </xsl:when>
 1335:            <xsl:otherwise>
 1336:     Function external:loncapa_abstract_to_lomnsdl_GeneralDescription() is not
 1337: available!
 1338:            </xsl:otherwise>
 1339:          </xsl:choose>
 1340: </Description>
 1341: <xsl:text>
 1342: </xsl:text>
 1343: </xsl:template>
 1344: <xsl:template match="loncapa:keywords">
 1345: <Keyword>
 1346:          <xsl:choose>
 1347:            <xsl:when
 1348:                  test=
 1349: "function-available('external:loncapa_keywords_to_lomnsdl_GeneralKeyword')"
 1350:              >
 1351:      <xsl:value-of select=
 1352:                  "external:loncapa_keywords_to_lomnsdl_GeneralKeyword(.)"/>
 1353:            </xsl:when>
 1354:            <xsl:otherwise>
 1355:     Function external:loncapa_keywords_to_lomnsdl_GeneralKeyword() is not
 1356: available!
 1357:            </xsl:otherwise>
 1358:          </xsl:choose>
 1359: </Keyword>
 1360: <xsl:text>
 1361: </xsl:text>
 1362: </xsl:template>
 1363: <xsl:template match="loncapa:structure">
 1364: <Structure>
 1365:          <xsl:choose>
 1366:            <xsl:when
 1367:                  test=
 1368: "function-available('external:loncapa_structure_to_lomnsdl_GeneralStructure')"
 1369:              >
 1370:      <xsl:value-of select=
 1371:                   "external:loncapa_structure_to_lomnsdl_GeneralStructure(.)"/>
 1372:            </xsl:when>
 1373:            <xsl:otherwise>
 1374:     Function external:loncapa_structure_to_lomnsdl_GeneralStructure() is not
 1375: available!
 1376:            </xsl:otherwise>
 1377:          </xsl:choose>
 1378: </Structure>
 1379: <xsl:text>
 1380: </xsl:text>
 1381: </xsl:template>
 1382: <xsl:template match="loncapa:aggregation">
 1383: <AggregationLevel>
 1384:          <xsl:choose>
 1385:            <xsl:when
 1386:                  test=
 1387: "function-available('external:loncapa_aggregation_to_lomnsdl_GeneralAggregationLevel')"
 1388:              >
 1389:      <xsl:value-of select=
 1390:          "external:loncapa_aggregation_to_lomnsdl_GeneralAggregationLevel(.)"/>
 1391:            </xsl:when>
 1392:            <xsl:otherwise>
 1393: Function external:loncapa_aggregation_to_lomnsdl_GeneralAggregationLevel() is
 1394: not available!
 1395:            </xsl:otherwise>
 1396:          </xsl:choose>
 1397: </AggregationLevel>
 1398: <xsl:text>
 1399: </xsl:text>
 1400: </xsl:template>
 1401: <xsl:template match="loncapa:version">
 1402: <Version>
 1403:          <xsl:choose>
 1404:            <xsl:when
 1405:                  test=
 1406: "function-available('external:loncapa_version_to_lomnsdl_LifeCycleVersion')"
 1407:              >
 1408:      <xsl:value-of select=
 1409:          "external:loncapa_version_to_lomnsdl_LifeCycleVersion(.)"/>
 1410:            </xsl:when>
 1411:            <xsl:otherwise>
 1412: Function external:loncapa_version_to_lomnsdl_LifeCycleVersion() is
 1413: not available!
 1414:            </xsl:otherwise>
 1415:          </xsl:choose>
 1416: </Version>
 1417: <xsl:text>
 1418: </xsl:text>
 1419: </xsl:template>
 1420: <xsl:template match="loncapa:mime">
 1421: <Format>
 1422:          <xsl:choose>
 1423:            <xsl:when
 1424:                  test=
 1425: "function-available('external:loncapa_mime_to_lomnsdl_TechnicalFormat')"
 1426:              >
 1427:      <xsl:value-of select=
 1428:          "external:loncapa_mime_to_lomnsdl_TechnicalFormat(.)"/>
 1429:            </xsl:when>
 1430:            <xsl:otherwise>
 1431: Function external:loncapa_mime_to_lomnsdl_TechnicalFormat() is not available!
 1432:            </xsl:otherwise>
 1433:          </xsl:choose>
 1434: </Format>
 1435: <xsl:text>
 1436: </xsl:text>
 1437: </xsl:template>
 1438: <xsl:template match="loncapa:bytesize">
 1439: <Size>
 1440:          <xsl:choose>
 1441:            <xsl:when
 1442:                  test=
 1443: "function-available('external:loncapa_bytesize_to_lomnsdl_TechnicalSize')"
 1444:              >
 1445:      <xsl:value-of select=
 1446:          "external:loncapa_bytesize_to_lomnsdl_TechnicalSize(.)"/>
 1447:            </xsl:when>
 1448:            <xsl:otherwise>
 1449: Function external:loncapa_bytesize_to_lomnsdl_TechnicalSize() is
 1450: not available!
 1451:            </xsl:otherwise>
 1452:          </xsl:choose>
 1453: </Size>
 1454: <xsl:text>
 1455: </xsl:text>
 1456: </xsl:template>
 1457: <xsl:template match="loncapa:notes">
 1458: <Description>
 1459:          <xsl:choose>
 1460:            <xsl:when
 1461:                  test=
 1462: "function-available('external:loncapa_notes_to_lomnsdl_EducationalDescription')"
 1463:              >
 1464:      <xsl:value-of select=
 1465:          "external:loncapa_notes_to_lomnsdl_EducationalDescription(.)"/>
 1466:            </xsl:when>
 1467:            <xsl:otherwise>
 1468: Function external:loncapa_notes_to_lomnsdl_EducationalDescription() is
 1469: not available!
 1470:            </xsl:otherwise>
 1471:          </xsl:choose>
 1472: </Description>
 1473: <xsl:text>
 1474: </xsl:text>
 1475: </xsl:template>
 1476: <xsl:template match="loncapa:language">
 1477:          <xsl:choose>
 1478:            <xsl:when
 1479:                  test=
 1480:           "function-available('external:loncapa_language_to_converter_INFO')"
 1481:              >
 1482:              <xsl:value-of select=
 1483:                            "external:loncapa_language_to_converter_INFO(.)"/>
 1484:            </xsl:when>
 1485:            <xsl:otherwise>
 1486:      Function external:loncapa_language_to_converter_INFO() is not available!
 1487:            </xsl:otherwise>
 1488:          </xsl:choose>
 1489: </xsl:template>
 1490: <xsl:template match="loncapa:author">
 1491:          <xsl:choose>
 1492:            <xsl:when
 1493:                  test=
 1494:          "function-available('external:loncapa_author_to_converter_INFO')"
 1495:              >
 1496:              <xsl:value-of
 1497:                     select="external:loncapa_author_to_converter_INFO(.)"/>
 1498:            </xsl:when>
 1499:            <xsl:otherwise>
 1500:          Function external:loncapa_author_to_converter_INFO() is not available!
 1501:            </xsl:otherwise>
 1502:          </xsl:choose>
 1503: </xsl:template>
 1504: <xsl:template match="loncapa:lastrevisiondate">
 1505:          <xsl:choose>
 1506:            <xsl:when
 1507:                  test=
 1508:     "function-available('external:loncapa_lastrevisiondate_to_converter_INFO')"
 1509:              >
 1510:              <xsl:value-of
 1511:               select="external:loncapa_lastrevisiondate_to_converter_INFO(.)"/>
 1512:            </xsl:when>
 1513:            <xsl:otherwise>
 1514:           Function external:loncapa_lastrevisiondate_to_converter_INFO() is not
 1515: available!
 1516:            </xsl:otherwise>
 1517:          </xsl:choose>
 1518: </xsl:template>
 1519: <xsl:template match="loncapa:metauri">
 1520:          <xsl:choose>
 1521:            <xsl:when
 1522:                  test=
 1523:     "function-available('external:loncapa_metauri_to_converter_INFO')"
 1524:              >
 1525:              <xsl:value-of
 1526:               select="external:loncapa_metauri_to_converter_INFO(.)"/>
 1527:            </xsl:when>
 1528:            <xsl:otherwise>
 1529:           Function external:loncapa_metauri_to_converter_INFO() is not
 1530: available!
 1531:            </xsl:otherwise>
 1532:          </xsl:choose>
 1533: </xsl:template>
 1534: <xsl:template match="loncapa:copyright">
 1535:          <xsl:choose>
 1536:            <xsl:when
 1537:                  test=
 1538:     "function-available('external:loncapa_copyright_to_converter_INFO')"
 1539:              >
 1540:              <xsl:value-of
 1541:               select="external:loncapa_copyright_to_converter_INFO(.)"/>
 1542:            </xsl:when>
 1543:            <xsl:otherwise>
 1544:           Function external:loncapa_copyright_to_converter_INFO() is not
 1545: available!
 1546:            </xsl:otherwise>
 1547:          </xsl:choose>
 1548: </xsl:template>
 1549: <xsl:template match="loncapa:owner">
 1550:          <xsl:choose>
 1551:            <xsl:when
 1552:                  test=
 1553:     "function-available('external:loncapa_owner_to_converter_INFO')"
 1554:              >
 1555:              <xsl:value-of
 1556:               select="external:loncapa_owner_to_converter_INFO(.)"/>
 1557:            </xsl:when>
 1558:            <xsl:otherwise>
 1559:           Function external:loncapa_owner_to_converter_INFO() is not
 1560: available!
 1561:            </xsl:otherwise>
 1562:          </xsl:choose>
 1563: </xsl:template>
 1564: </xsl:stylesheet>
 1565: END
 1566: 
 1567: # ----------------------------------------------------- loncapa_to_lomnsdl.xsl2
 1568: open(OUT,'>loncapa_to_lomnsdl.xsl2');
 1569: print(OUT <<END);
 1570: <?xml version="1.0"?> 
 1571: <xsl:stylesheet
 1572:   xmlns:loncapa="http://nsdl.lon-capa.org/loncapa/elements/1.1/"
 1573:   xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
 1574:   xmlns:external="$namespace"
 1575: >
 1576: <xsl:template match="/">
 1577: <lom:lom xmlns:lom="http://nsdl.lon-capa.org/lom/elements/6.4/">
 1578: <xsl:text>
 1579: </xsl:text>
 1580: <!-- These values are stored in memory (converter_INFO) -->
 1581: <xsl:apply-templates select="/*/loncapa:language"/>
 1582: <xsl:apply-templates select="/*/loncapa:author"/>
 1583: <xsl:apply-templates select="/*/loncapa:lastrevisiondate"/>
 1584: <xsl:apply-templates select="/*/loncapa:metauri"/>
 1585: <xsl:apply-templates select="/*/loncapa:copyright"/>
 1586: <xsl:apply-templates select="/*/loncapa:owner"/>
 1587: 
 1588: <General>
 1589:  <Identifier>
 1590:   <Catalog>LON</Catalog>
 1591:   <Entry><!-- call mem --></Entry>
 1592:  </Identifier>
 1593:  <xsl:apply-templates select="/*/loncapa:title"/>
 1594:          <xsl:choose>
 1595:            <xsl:when
 1596:                  test=
 1597:          "function-available('external:converter_INFO_to_lomnsdl_GeneralLanguage')"
 1598:              >
 1599:      <xsl:value-of select="external:converter_INFO_to_lomnsdl_GeneralLanguage(.)"/>
 1600:            </xsl:when>
 1601:            <xsl:otherwise>
 1602:     Function external:converter_INFO_to_lomnsdl_GeneralLanguage() is not available!
 1603:            </xsl:otherwise>
 1604:          </xsl:choose>
 1605:  <xsl:apply-templates select="/*/loncapa:abstract"/>
 1606:  <xsl:apply-templates select="/*/loncapa:keywords"/>
 1607:  <xsl:apply-templates select="/*/loncapa:structure"/>
 1608:  <xsl:apply-templates select="/*/loncapa:aggregation"/>
 1609: </General>
 1610: 
 1611: <LifeCycle>
 1612:  <xsl:apply-templates select="/*/loncapa:version"/>
 1613:  <Contribute>
 1614:  <Role>Creator</Role>
 1615:  <Entity>
 1616:          <xsl:choose>
 1617:            <xsl:when
 1618:                  test=
 1619:       "function-available('external:converter_INFO_to_lomnsdl_LifeCycleContributeEntity')"
 1620:              >
 1621:      <xsl:value-of select="external:converter_INFO_to_lomnsdl_LifeCycleContributeEntity(.)"/>
 1622:            </xsl:when>
 1623:            <xsl:otherwise>
 1624:     Function external:converter_INFO_to_lomnsdl_LifeCycleContributeEntity() is not available!
 1625:            </xsl:otherwise>
 1626:          </xsl:choose>
 1627:  </Entity>
 1628:  <Date>
 1629:          <xsl:choose>
 1630:            <xsl:when
 1631:                  test=
 1632:          "function-available('external:converter_INFO_to_lomnsdl_LifeCycleContributeDate')"
 1633:              >
 1634:      <xsl:value-of select="external:converter_INFO_to_lomnsdl_LifeCycleContributeDate(.)"/>
 1635:            </xsl:when>
 1636:            <xsl:otherwise>
 1637:     Function external:converter_INFO_to_lomnsdl_LifeCycleContributeDate() is not available!
 1638:            </xsl:otherwise>
 1639:          </xsl:choose>
 1640:  </Date>
 1641:  </Contribute>
 1642: </LifeCycle>
 1643: 
 1644: <MetaMetadata>
 1645:          <xsl:choose>
 1646:            <xsl:when
 1647:                  test=
 1648:         "function-available('external:converter_INFO_to_lomnsdl_MetaMetadata')"
 1649:              >
 1650:     <xsl:value-of select="external:converter_INFO_to_lomnsdl_MetaMetadata(.)"/>
 1651:            </xsl:when>
 1652:            <xsl:otherwise>
 1653:    Function external:converter_INFO_to_lomnsdl_MetaMetadata() is not available!
 1654:            </xsl:otherwise>
 1655:          </xsl:choose>
 1656: </MetaMetadata>
 1657: 
 1658: <Technical>
 1659:  <xsl:apply-templates select="/*/loncapa:mime"/>
 1660:  <xsl:apply-templates select="/*/loncapa:bytesize"/>
 1661:  <Location>
 1662:          <xsl:choose>
 1663:            <xsl:when
 1664:                  test=
 1665:    "function-available('external:converter_INFO_to_lomnsdl_TechnicalLocation')"
 1666:              >
 1667:              <xsl:value-of 
 1668:              select="external:converter_INFO_to_lomnsdl_TechnicalLocation(.)"/>
 1669:            </xsl:when>
 1670:            <xsl:otherwise>
 1671:    Function external:converter_INFO_to_lomnsdl_TechnicalLocation() is not
 1672: available!
 1673:            </xsl:otherwise>
 1674:          </xsl:choose>
 1675:  </Location>
 1676:  <Requirement>
 1677:          <xsl:choose>
 1678:            <xsl:when
 1679:                  test=
 1680: "function-available('external:converter_INFO_to_lomnsdl_TechnicalRequirement')"
 1681:              >
 1682:              <xsl:value-of 
 1683:           select="external:converter_INFO_to_lomnsdl_TechnicalRequirement(.)"/>
 1684:            </xsl:when>
 1685:            <xsl:otherwise>
 1686:    Function external:converter_INFO_to_lomnsdl_TechnicalRequirement() is not
 1687: available!
 1688:            </xsl:otherwise>
 1689:          </xsl:choose>
 1690:  </Requirement>
 1691: </Technical>
 1692: 
 1693: <Educational>
 1694:  <xsl:apply-templates select="/*/loncapa:notes"/>
 1695:  <Language>
 1696:          <xsl:choose>
 1697:            <xsl:when
 1698:                  test=
 1699: "function-available('external:converter_INFO_to_lomnsdl_EducationalLanguage')"
 1700:              >
 1701:              <xsl:value-of 
 1702:           select="external:converter_INFO_to_lomnsdl_EducationalLanguage(.)"/>
 1703:            </xsl:when>
 1704:            <xsl:otherwise>
 1705:    Function external:converter_INFO_to_lomnsdl_EducationalLanguage() is not
 1706: available!
 1707:            </xsl:otherwise>
 1708:          </xsl:choose>
 1709:  </Language>
 1710: </Educational>
 1711: 
 1712: <Rights>
 1713:  <CopyrightandOtherRestrictions>yes</CopyrightandOtherRestrictions>
 1714:  <Description>
 1715:          <xsl:choose>
 1716:            <xsl:when
 1717:                  test=
 1718: "function-available('external:converter_INFO_to_lomnsdl_RightsDescription')"
 1719:              >
 1720:              <xsl:value-of 
 1721:           select="external:converter_INFO_to_lomnsdl_RightsDescription(.)"/>
 1722:            </xsl:when>
 1723:            <xsl:otherwise>
 1724:          Function external:converter_INFO_to_lomnsdl_RightsDescription() is not
 1725: available!
 1726:            </xsl:otherwise>
 1727:          </xsl:choose>
 1728:  </Description>
 1729: </Rights>
 1730: <xsl:text>
 1731: </xsl:text>
 1732: </lom:lom>
 1733: <xsl:text>
 1734: </xsl:text>
 1735: </xsl:template>
 1736: 
 1737: <xsl:template match="loncapa:title">
 1738: <Title>
 1739:          <xsl:choose>
 1740:            <xsl:when
 1741:                  test=
 1742:          "function-available('external:loncapa_title_to_lomnsdl_GeneralTitle')"
 1743:              >
 1744:      <xsl:value-of select="external:loncapa_title_to_lomnsdl_GeneralTitle(.)"/>
 1745:            </xsl:when>
 1746:            <xsl:otherwise>
 1747:     Function external:loncapa_title_to_lomnsdl_GeneralTitle() is not available!
 1748:            </xsl:otherwise>
 1749:          </xsl:choose>
 1750: </Title>
 1751: <xsl:text>
 1752: </xsl:text>
 1753: </xsl:template>
 1754: 
 1755: <xsl:template match="loncapa:abstract">
 1756: <Description>
 1757:          <xsl:choose>
 1758:            <xsl:when
 1759:                  test=
 1760: "function-available('external:loncapa_abstract_to_lomnsdl_GeneralDescription')"
 1761:              >
 1762:              <xsl:value-of
 1763:            select="external:loncapa_abstract_to_lomsdl_GeneralDescription(.)"/>
 1764:            </xsl:when>
 1765:            <xsl:otherwise>
 1766:    Function external:loncapa_abstract_to_lomnsdl_GeneralDescription() is not available!
 1767:            </xsl:otherwise>
 1768:          </xsl:choose>
 1769: </Description>
 1770: <xsl:text>
 1771: </xsl:text>
 1772: </xsl:template>
 1773: 
 1774: <xsl:template match="loncapa:keywords">
 1775: <Keyword>
 1776:          <xsl:choose>
 1777:            <xsl:when
 1778:                  test=
 1779: "function-available('external:loncapa_keywords_to_lomnsdl_GeneralKeyword')"
 1780:              >
 1781:              <xsl:value-of
 1782:            select="external:loncapa_keywords_to_lomsdl_GeneralKeyword(.)"/>
 1783:            </xsl:when>
 1784:            <xsl:otherwise>
 1785:    Function external:loncapa_keywords_to_lomnsdl_GeneralKeyword() is not available!
 1786:            </xsl:otherwise>
 1787:          </xsl:choose>
 1788: </Keyword>
 1789: <xsl:text>
 1790: </xsl:text>
 1791: </xsl:template>
 1792: 
 1793: <xsl:template match="loncapa:structure">
 1794: <Structure>
 1795:          <xsl:choose>
 1796:            <xsl:when
 1797:                  test=
 1798: "function-available('external:loncapa_structure_to_lomnsdl_GeneralStructure')"
 1799:              >
 1800:              <xsl:value-of
 1801:            select="external:loncapa_structure_to_lomsdl_GeneralStructure(.)"/>
 1802:            </xsl:when>
 1803:            <xsl:otherwise>
 1804:    Function external:loncapa_structure_to_lomnsdl_GeneralStructure() is not
 1805:    available!
 1806:            </xsl:otherwise>
 1807:          </xsl:choose>
 1808: </Structure>
 1809: <xsl:text>
 1810: </xsl:text>
 1811: </xsl:template>
 1812: 
 1813: <xsl:template match="loncapa:aggregation">
 1814: <AggregationLevel>
 1815:          <xsl:choose>
 1816:            <xsl:when
 1817:                  test=
 1818: "function-available('external:loncapa_aggregation_to_lomnsdl_GeneralAggregationLevel')"
 1819:              >
 1820:              <xsl:value-of
 1821:            select="external:loncapa_aggregation_to_lomsdl_GeneralAggregationLevel(.)"/>
 1822:            </xsl:when>
 1823:            <xsl:otherwise>
 1824:    Function external:loncapa_aggregation_to_lomnsdl_GeneralAggregationLevel()
 1825:    is not available!
 1826:            </xsl:otherwise>
 1827:          </xsl:choose>
 1828: </AggregationLevel>
 1829: <xsl:text>
 1830: </xsl:text>
 1831: </xsl:template>
 1832: 
 1833: <xsl:template match="loncapa:version">
 1834: <Version>
 1835:          <xsl:choose>
 1836:            <xsl:when
 1837:                  test=
 1838:    "function-available('external:loncapa_version_to_lomnsdl_LifeCycleVersion')"
 1839:              >
 1840:              <xsl:value-of
 1841:               select="external:loncapa_version_to_lomsdl_LifeCycleVersion(.)"/>
 1842:            </xsl:when>
 1843:            <xsl:otherwise>
 1844:         Function external:loncapa_version_to_lomnsdl_LifeCycleVersion() is not
 1845:         available!
 1846:            </xsl:otherwise>
 1847:          </xsl:choose>
 1848: </Version>
 1849: <xsl:text>
 1850: </xsl:text>
 1851: </xsl:template>
 1852: 
 1853: <xsl:template match="loncapa:mime">
 1854: <Format>
 1855:          <xsl:choose>
 1856:            <xsl:when
 1857:                  test=
 1858:    "function-available('external:loncapa_mime_to_lomnsdl_Format')"
 1859:              >
 1860:              <xsl:value-of
 1861:                     select="external:loncapa_mime_to_lomsdl_Format(.)"/>
 1862:            </xsl:when>
 1863:            <xsl:otherwise>
 1864:     Function external:loncapa_mime_to_lomnsdl_Format() is not available!
 1865:            </xsl:otherwise>
 1866:          </xsl:choose>
 1867: </Format>
 1868: <xsl:text>
 1869: </xsl:text>
 1870: </xsl:template>
 1871: 
 1872: <xsl:template match="loncapa:bytesize">
 1873: <Size>
 1874:          <xsl:choose>
 1875:            <xsl:when
 1876:                  test=
 1877:    "function-available('external:loncapa_mime_to_lomnsdl_TechnicalSize')"
 1878:              >
 1879:              <xsl:value-of
 1880:                     select="external:loncapa_mime_to_lomsdl_TechnicalSize(.)"/>
 1881:            </xsl:when>
 1882:            <xsl:otherwise>
 1883:     Function external:loncapa_mime_to_lomnsdl_TechnicalSize() is not available!
 1884:            </xsl:otherwise>
 1885:          </xsl:choose>
 1886: </Size>
 1887: <xsl:text>
 1888: </xsl:text>
 1889: </xsl:template>
 1890: 
 1891: <xsl:template match="loncapa:author">
 1892: <dc:contributor>
 1893:          <xsl:choose>
 1894:            <xsl:when
 1895:                  test=
 1896:           "function-available('external:loncapa_author_to_lomnsdl_contributor')"
 1897:              >
 1898:              <xsl:value-of
 1899:                     select="external:loncapa_author_to_dcnsdl_contributor(.)"/>
 1900:            </xsl:when>
 1901:            <xsl:otherwise>
 1902:      Function external:loncapa_author_to_dcnsdl_contributor() is not available!
 1903:            </xsl:otherwise>
 1904:          </xsl:choose>
 1905: </dc:contributor>
 1906: <xsl:text>
 1907: </xsl:text>
 1908: <dc:creator>
 1909:          <xsl:choose>
 1910:            <xsl:when
 1911:                  test=
 1912:               "function-available('external:loncapa_author_to_dcnsdl_creator')"
 1913:              >
 1914:              <xsl:value-of
 1915:                         select="external:loncapa_author_to_dcnsdl_creator(.)"/>
 1916:            </xsl:when>
 1917:            <xsl:otherwise>
 1918:          Function external:loncapa_author_to_dcnsdl_creator() is not available!
 1919:            </xsl:otherwise>
 1920:          </xsl:choose>
 1921: </dc:creator>
 1922: <xsl:text>
 1923: </xsl:text>
 1924: </xsl:template>
 1925: <xsl:template match="loncapa:owner">
 1926: <dc:publisher>
 1927:          <xsl:choose>
 1928:            <xsl:when
 1929:                  test=
 1930:              "function-available('external:loncapa_owner_to_dcnsdl_publisher')"
 1931:              >
 1932:              <xsl:value-of
 1933:                        select="external:loncapa_owner_to_dcnsdl_publisher(.)"/>
 1934:            </xsl:when>
 1935:            <xsl:otherwise>
 1936:         Function external:loncapa_owner_to_dcnsdl_publisher() is not available!
 1937:            </xsl:otherwise>
 1938:          </xsl:choose>
 1939: </dc:publisher>
 1940: <xsl:text>
 1941: </xsl:text>
 1942: </xsl:template>
 1943: <xsl:template match="loncapa:subject">
 1944: <dc:subject>
 1945:          <xsl:choose>
 1946:            <xsl:when
 1947:                  test=
 1948:              "function-available('external:loncapa_subject_to_dcnsdl_subject')"
 1949:              >
 1950:            <xsl:value-of
 1951:                        select="external:loncapa_subject_to_dcnsdl_subject(.)"/>
 1952:            </xsl:when>
 1953:            <xsl:otherwise>
 1954:         Function external:loncapa_subject_to_dcnsdl_subject() is not available!
 1955:            </xsl:otherwise>
 1956:          </xsl:choose>
 1957: </dc:subject>
 1958: <xsl:text>
 1959: </xsl:text>
 1960: </xsl:template>
 1961: <xsl:template match="loncapa:lastrevisiondate">
 1962: <dc:date>
 1963:          <xsl:choose>
 1964:            <xsl:when
 1965:                  test=
 1966:        "function-available('external:loncapa_lastrevisiondate_to_dcnsdl_date')"
 1967:              >
 1968:              <xsl:value-of select=
 1969:                         "external:loncapa_lastrevisiondate_to_dcnsdl_date(.)"/>
 1970:            </xsl:when>
 1971:            <xsl:otherwise>
 1972:   Function external:loncapa_lastrevisiondate_to_dcnsdl_date() is not available!
 1973:            </xsl:otherwise>
 1974:          </xsl:choose>
 1975: </dc:date>
 1976: <xsl:text>
 1977: </xsl:text>
 1978: </xsl:template>
 1979: <xsl:template match="loncapa:mime">
 1980: <dc:type>
 1981:          <xsl:choose>
 1982:            <xsl:when
 1983:                  test=
 1984:                    "function-available('external:loncapa_mime_to_dcnsdl_type')"
 1985:              >
 1986:              <xsl:value-of select="external:loncapa_mime_to_dcnsdl_type(.)"/>
 1987:            </xsl:when>
 1988:            <xsl:otherwise>
 1989:               Function external:loncapa_mime_to_dcnsdl_type() is not available!
 1990:            </xsl:otherwise>
 1991:          </xsl:choose>
 1992: </dc:type>
 1993: <xsl:text>
 1994: </xsl:text>
 1995: <dc:format>
 1996:          <xsl:choose>
 1997:            <xsl:when
 1998:                  test=
 1999:                  "function-available('external:loncapa_mime_to_dcnsdl_format')"
 2000:              >
 2001:              <xsl:value-of select="external:loncapa_mime_to_dcnsdl_format(.)"/>
 2002:            </xsl:when>
 2003:            <xsl:otherwise>
 2004:             Function external:loncapa_mime_to_dcnsdl_format() is not available!
 2005:            </xsl:otherwise>
 2006:          </xsl:choose>
 2007: </dc:format>
 2008: <xsl:text>
 2009: </xsl:text>
 2010: </xsl:template>
 2011: <xsl:template match="loncapa:uri">
 2012: <dc:identifier>
 2013:          <xsl:choose>
 2014:            <xsl:when
 2015:                  test=
 2016:               "function-available('external:loncapa_uri_to_dcnsdl_identifier')"
 2017:              >
 2018:              <xsl:value-of select=
 2019:                                "external:loncapa_uri_to_dcnsdl_identifier(.)"/>
 2020:            </xsl:when>
 2021:            <xsl:otherwise>
 2022:          Function external:loncapa_uri_to_dcnsdl_identifier() is not available!
 2023:            </xsl:otherwise>
 2024:          </xsl:choose>
 2025: </dc:identifier>
 2026: <xsl:text>
 2027: </xsl:text>
 2028: </xsl:template>
 2029: <xsl:template match="loncapa:language">
 2030: <dc:language>
 2031:          <xsl:choose>
 2032:            <xsl:when
 2033:                  test=
 2034:            "function-available('external:loncapa_language_to_dcnsdl_language')"
 2035:              >
 2036:              <xsl:value-of select=
 2037:                             "external:loncapa_language_to_dcnsdl_language(.)"/>
 2038:            </xsl:when>
 2039:            <xsl:otherwise>
 2040:       Function external:loncapa_language_to_dcnsdl_language() is not available!
 2041:            </xsl:otherwise>
 2042:          </xsl:choose>
 2043: </dc:language>
 2044: <xsl:text>
 2045: </xsl:text>
 2046: </xsl:template>
 2047: <xsl:template match="loncapa:copyright">
 2048: <dc:rights>
 2049:          <xsl:choose>
 2050:            <xsl:when
 2051:                  test=
 2052:             "function-available('external:loncapa_copyright_to_dcnsdl_rights')"
 2053:              >
 2054:              <xsl:value-of select=
 2055:                             "external:loncapa_copyright_to_dcnsdl_rights(.)"/>
 2056:            </xsl:when>
 2057:            <xsl:otherwise>
 2058:        Function external:loncapa_copyright_to_dcnsdl_rights() is not available!
 2059:            </xsl:otherwise>
 2060:          </xsl:choose>
 2061: </dc:rights>
 2062: <xsl:text>
 2063: </xsl:text>
 2064: </xsl:template>
 2065: </xsl:stylesheet>
 2066: END
 2067: close(OUT);
 2068: 
 2069: # =================================================== Define external functions
 2070: 
 2071: my $func = sub {
 2072:     my $text = shift;
 2073:     return uc($text);
 2074: };
 2075: 
 2076: my %ci=(
 2077:   'lomnsdl_LifeCycleContributeRole' => '',
 2078:   'lomnsdl_LifeCycleContributeEntity' => '',
 2079:   'lomnsdl_LifeCycleContributeDate' => '',
 2080:   'lomnsdl_LifeCycleContributeAuthor' => '',
 2081:   'lomnsdl_LifeCycleContributeLastAuthorDate' => '',
 2082:   'lomnsdl_TechnicalLocation' => '',
 2083:   'lomnsdl_RightsCopyrightandOtherRestrictions' => '',
 2084:   'lomnsdl_RightsDescription' => '',
 2085:   'loncapa_uri' => '',
 2086:   'loncapa_language' => '',
 2087:   'loncapa_author' => '',
 2088:   'loncapa_lastrevisiondate' => '',
 2089:   'loncapa_metauri' => '',
 2090:   'loncapa_copyright' => '',
 2091:   'loncapa_owner' => '',
 2092: );
 2093: 
 2094: my %xslfunctions=(
 2095: 
 2096: loncapa_title_to_dcnsdl_title => sub
 2097:  { my $text=shift; return $text; },
 2098: loncapa_author_to_dcnsdl_contributor => sub
 2099:  { my $text=shift; return ''; }, # This is where co-authors should be someday.
 2100: loncapa_author_to_dcnsdl_creator => sub
 2101:  { my $text=shift; return $text; },
 2102: loncapa_owner_to_dcnsdl_publisher => sub
 2103:  { my $text=shift; return $text; },
 2104: loncapa_subject_to_dcnsdl_subject => sub
 2105:  { my $text=shift; return $text; },
 2106: loncapa_abstract_to_dcnsdl_description => sub
 2107:  { my $text=shift; return $text; },
 2108: loncapa_lastrevisiondate_to_dcnsdl_date => sub
 2109:  { my $text=shift; return &loncapa_to_rfc_Date($text); },
 2110: loncapa_mime_to_dcnsdl_type => sub
 2111:  { my $text=shift; return "[unofficial: $text]"; }, # unclear conversion
 2112: loncapa_mime_to_dcnsdl_format => sub
 2113:  { my $text=shift; return "[unofficial: $text]"; }, # for now, mime suffices
 2114: loncapa_uri_to_dcnsdl_identifier => sub
 2115:  { my $text=shift; return 'LONCAPA:'.$text; }, # URI or gateway URL here?
 2116: loncapa_language_to_dcnsdl_language => sub
 2117:  { my $text=shift; return loncapa_to_ISO_language_convert($text); },
 2118: loncapa_copyright_to_dcnsdl_rights => sub
 2119:  { my $text=shift; return 'LONCAPA:'.$text; },
 2120: 
 2121: dcnsdl_title_to_loncapa_title => sub
 2122:  { my $text=shift; return $text; },
 2123: #dcnsdl_contributor_to_loncapa_author => sub    <--- contributor should go
 2124: # { my $text=shift; return "[notdefined: $text]"; },  <--- somewhere someday
 2125: dcnsdl_creator_to_loncapa_author => sub
 2126:  { my $text=shift; return $text; }, # should maybe have contributor as well?
 2127: dcnsdl_publisher_to_loncapa_owner => sub
 2128:  { my $text=shift; return $text; }, # assume publisher is owner
 2129: dcnsdl_subject_to_loncapa_subject => sub
 2130:  { my $text=shift; return $text; }, # DC, however, includes keywords in subject
 2131: dcnsdl_description_to_loncapa_abstract => sub
 2132:  { my $text=shift; return $text; },
 2133: dcnsdl_date_to_loncapa_lastrevisiondate => sub
 2134:  { my $text=shift; return &rfc_to_loncapa_Date($text); },
 2135: dcnsdl_type_to_loncapa_mime => sub
 2136:  { my $text=shift; return "[notdefined: $text]"; },
 2137: dcnsdl_format_to_loncapa_mime => sub
 2138:  { my $text=shift; return "[notdefined: $text]"; },
 2139: dcnsdl_identifier_to_loncapa_uri => sub
 2140:  { my $text=shift; return build_gateway_uri_pointer($text); }, # build pointer
 2141: dcnsdl_language_to_loncapa_language => sub
 2142:  { my $text=shift; return ISO_to_loncapa_language_convert($text); },
 2143: dcnsdl_rights_to_loncapa_copyright => sub
 2144:  { my $text=shift; return $text; },
 2145: 
 2146: lomnsdl_LifeCycleContribute_prepare_converter_INFO => sub
 2147:  {
 2148:    if ($ci{'lomnsdl_LifeCycleContributeRole'} eq 'author') {
 2149:      $ci{'lomnsdl_LifeCycleContributeAuthor'}.=
 2150:         $ci{'lomnsdl_LifeCycleContributeEntity'};
 2151:      $ci{'lomnsdl_LifeCycleContributeLastAuthorDate'}=
 2152:         $ci{'lomnsdl_LifeCycleContributeDate'};
 2153:    }
 2154:    $ci{'lomnsdl_LifeCycleContributeRole'}='';
 2155:    $ci{'lomnsdl_LifeCycleContributeEntity'}='';
 2156:    $ci{'lomnsdl_LifeCycleContributeDate'}='';
 2157:  },
 2158: lomnsdl_GeneralIdentifier_to_loncapa_uri => sub
 2159:  { my $text=shift; return build_gateway_uri_pointer($text); }, # build pointer
 2160: lomnsdl_GeneralTitle_to_loncapa_title => sub
 2161:  { my $text=shift; return $text; },
 2162: lomnsdl_GeneralLanguage_to_loncapa_language => sub
 2163:  { my $text=shift; return ISO_to_loncapa_language_convert($text); },
 2164: lomnsdl_GeneralDescription_to_loncapa_abstract => sub
 2165:  { my $text=shift; return $text; },
 2166: lomnsdl_GeneralKeyword_to_loncapa_keywords => sub
 2167:  { my $text=shift; return $text; },
 2168: lomnsdl_GeneralStructure_to_loncapa_structure => sub
 2169:  { my $text=shift; return "[unofficial: $text]"; },
 2170: lomnsdl_GeneralAggregationLevel_to_loncapa_aggregation => sub
 2171:  { my $text=shift; return "[unofficial: $text]"; },
 2172: lomnsdl_LifeCycleVersion_to_loncapa_version => sub
 2173:  { my $text=shift; return $text; },
 2174: lomnsdl_LifeCycleContributeRole_to_converter_INFO => sub
 2175:  { my $text=shift; $ci{'LifeCycleContributeRole'}=$text; return ''; },
 2176: lomnsdl_LifeCycleContributeEntity_to_converter_INFO => sub
 2177:  { my $text=shift; $ci{'LifeCycleContributeEntity'}=$text; return ''; },
 2178: lomnsdl_LifeCycleContributeDate_to_converter_INFO => sub
 2179:  { my $text=shift; $ci{'LifeCycleContributeDate'}; return ''; },
 2180: converter_INFO_to_loncapa_author => sub
 2181:  { return $ci{'lomnsdl_LifeCycleContributeAuthor'}; },
 2182: converter_INFO_to_loncapa_owner => sub
 2183:  { return $ci{'lomnsdl_RightsDescription'}; },
 2184: converter_INFO_to_loncapa_lastrevisiondate => sub
 2185:  { my $text=shift; return $ci{'lomnsdl_LifeCycleContributeLastAuthorDate'}; },
 2186: converter_INFO_to_loncapa_creationdate => sub
 2187:  { return ''; },
 2188: lomnsdl_MetaMetadataIdentifierCatalog_to_converterINFO => sub
 2189:  { my $text=shift; return "[notdefined: $text]"; },
 2190: lomnsdl_MetaMetadataIdentifierEntry_to_converterINFO => sub
 2191:  { my $text=shift; return "[notdefined: $text]"; },
 2192: lomnsdl_TechnicalFormat_to_loncapa_mime => sub
 2193:  { my $text=shift; return mimeIANA_to_mimeSuffix($text); },
 2194: lomnsdl_TechnicalSize_to_loncapa_bytesize => sub
 2195:  { my $text=shift; return $text; },
 2196: lomnsdl_Technical_prepare_converter_INFO => sub
 2197:  { $ci{'lomnsdl_TechnicalLocation'}=''; },
 2198: lomnsdl_TechnicalLocation_to_converter_INFO => sub
 2199:  { my $text=shift; return '';}, # need to store techloc with uri in server
 2200: lomnsdl_EducationalDescription_to_loncapa_notes => sub
 2201:  { my $text=shift; return $text; },
 2202: lomnsdl_Rights_prepare_converter_INFO => sub
 2203:  { $ci{'RightsCopyrightandOtherRestrictions'}='';
 2204:    $ci{'RightsDescription'}='';
 2205:  },
 2206: lomnsdl_RightsCopyrightandOtherRestrictions_to_converter_INFO => sub
 2207:  { my $text=shift; $ci{'RightsCopyrightandOtherRestrictions'}=$text;
 2208:    return ''; },
 2209: lomnsdl_RightsDescription_to_converter_INFO => sub
 2210:  { my $text=shift; $ci{'RightsDescription'}=$text; return ''; },
 2211: converter_INFO_to_loncapa_copyright => sub
 2212:  { if ($ci{'RightsCopyrightandOtherRestrictions'} eq 'yes') {
 2213:      return $ci{'RightsDescription'};
 2214:    }
 2215:    else {
 2216:      return '';
 2217:    }
 2218:  },
 2219: loncapa_uri_to_converter_INFO => sub
 2220:  { my $text=shift; $ci{'loncapa_uri'}=$text; return ''; },
 2221: converter_INFO_to_lomnsdl_GeneralIdentifier => sub
 2222:  { return $ci{'loncapa_uri'}; },
 2223: loncapa_title_to_lomnsdl_GeneralTitle => sub
 2224:  { my $text=shift; return $text; },
 2225: loncapa_language_to_converter_INFO => sub
 2226:  { my $text=shift; $ci{'loncapa_language'}=$text; return ''; },
 2227: converter_INFO_to_lomnsdl_GeneralLanguage => sub
 2228:  { return loncapa_to_ISO_language_convert($ci{'loncapa_language'}); },
 2229: loncapa_abstract_to_lomnsdl_GeneralDescription => sub
 2230:  { my $text=shift; return $text; },
 2231: loncapa_keywords_to_lomnsdl_GeneralKeyword => sub
 2232:  { my $text=shift; return $text; },
 2233: loncapa_structure_to_lomnsdl_GeneralStructure => sub
 2234:  { my $text=shift; return "[unofficial: $text]"; },
 2235: loncapa_aggregation_to_lomnsdl_GeneralAggregationLevel => sub
 2236:  { my $text=shift; return "[unofficial: $text]"; },
 2237: loncapa_version_to_lomnsdl_LifeCycleVersion => sub
 2238:  { my $text=shift; return $text; },
 2239: loncapa_author_to_converter_INFO => sub
 2240:  { my $text=shift; $ci{'loncapa_author'}=$text; return ''; },
 2241: loncapa_lastrevisiondate_to_converter_INFO => sub
 2242:  { my $text=shift; $ci{'loncapa_lastrevisiondate'}=$text; return ''; },
 2243: converter_INFO_to_lomnsdl_LifeCycleContributeEntity => sub
 2244:  { return $ci{'loncapa_author'}; },
 2245: converter_INFO_to_lomnsdl_LifeCycleContributeDate => sub
 2246:  { return $ci{'loncapa_lastrevisiondate'}; },
 2247: loncapa_metauri_to_converter_INFO => sub
 2248:  { my $text=shift; return "[notdefined: $text]";},
 2249: converter_INFO_to_lomnsdl_MetaMetadata => sub
 2250:  { my $text=shift; return "[notdefined: $text]"; },
 2251: loncapa_mime_to_lomnsdl_TechnicalFormat => sub
 2252:  { my $text=shift; return mimeSuffix_to_mimeIANA($text); },
 2253: loncapa_bytesize_to_lomnsdl_TechnicalSize => sub
 2254:  { my $text=shift; return $text; },
 2255: converter_INFO_to_lomnsdl_TechnicalLocation => sub
 2256:  { my $text=shift; return "[notdefined: $text]"; },
 2257: converter_INFO_to_lomnsdl_TechnicalRequirement => sub
 2258:  { my $text=shift; return "[notdefined: $text]"; },
 2259: converter_INFO_to_lomnsdl_TechnicalInstallationRemarks => sub
 2260:  { my $text=shift; return "[notdefined: $text]"; },
 2261: loncapa_notes_to_lomnsdl_EducationalDescription => sub
 2262:  { my $text=shift; return $text; },
 2263: converter_INFO_to_lomnsdl_EducationalLanguage => sub
 2264:  { my $text=shift; return "[notdefined: $text]"; },
 2265: loncapa_copyright_to_converter_INFO => sub
 2266:  { my $text=shift; return "[notdefined: $text]"; },
 2267: loncapa_owner_to_converter_INFO => sub
 2268:  { my $text=shift; return "[notdefined: $text]"; },
 2269: converter_INFO_to_lomnsdl_RightsDescription => sub
 2270:  { my $text=shift; return "[notdefined: $text]"; },
 2271: 
 2272: );
 2273: 
 2274: foreach my $fname (keys %xslfunctions) {
 2275:   $tr->install_function($namespace,$fname,$xslfunctions{$fname});
 2276: }
 2277: 
 2278: # =================================================== Executing transformations
 2279: 
 2280: my $compiled; my $parsed; my $dest_file;
 2281: 
 2282: # ---------------------------------- LON-CAPA to NSDL (Dublic Core format)
 2283: &query('LON-CAPA to NSDL (Dublic Core format)');
 2284: $compiled = $tr->compile_stylesheet_file("loncapa_to_dcnsdl.xsl");
 2285: $parsed = $tr->parse_file("tmp_loncapa.xml");
 2286: $dest_file="loncapa_to_dcnsdl.xml";
 2287: $tr->transform_to_file($parsed, $compiled, $dest_file)
 2288:     or die $tr->errstr;
 2289: 
 2290: # ---------------------------------- NSDL (Dublic Core format) to LON-CAPA
 2291: &query('NSDL (Dublic Core format) to LON-CAPA');
 2292: $compiled = $tr->compile_stylesheet_file('dcnsdl_to_loncapa.xsl');
 2293: $parsed = $tr->parse_file("tmp_dcnsdl.xml");
 2294: $dest_file="dcnsdl_to_loncapa.xml";
 2295: $tr->transform_to_file($parsed, $compiled, $dest_file)
 2296:     or die $tr->errstr;
 2297: 
 2298: # ---------------------------------- LON-CAPA to NSDL (IEEE LOM format)
 2299: &query('LON-CAPA to NSDL (IEEE LOM format)');
 2300: $compiled = $tr->compile_stylesheet_file("loncapa_to_lomnsdl.xsl");
 2301: $parsed = $tr->parse_file("tmp_loncapa.xml");
 2302: $dest_file="loncapa_to_lomnsdl.xml";
 2303: $tr->transform_to_file($parsed, $compiled, $dest_file)
 2304:     or die $tr->errstr;
 2305: 
 2306: # ---------------------------------- NSDL (IEEE LOM format) to LON-CAPA
 2307: &query('NSDL (IEEE LOM format) to LON-CAPA');
 2308: $compiled = $tr->compile_stylesheet_file('lomnsdl_to_loncapa.xsl');
 2309: $parsed = $tr->parse_file("tmp_lomnsdl.xml");
 2310: $dest_file="lomnsdl_to_loncapa.xml";
 2311: $tr->transform_to_file($parsed, $compiled, $dest_file)
 2312:     or die $tr->errstr;
 2313: 
 2314: # ========================================================= Various subroutines
 2315: 
 2316: sub query {
 2317:     my ($prompt)=@_;
 2318:     print $prompt."\n";
 2319: #    my $a=<>;
 2320:     return;
 2321: }
 2322: 
 2323: sub build_gateway_uri_pointer {
 2324:     my ($string)=@_;
 2325:     return 'longatewayptr://'.$string;
 2326: }
 2327: 
 2328: sub loncapa_to_rfc_Date {
 2329:     my ($val)=@_;
 2330:     my $responseDate=Date::Format::time2str("%Y-%m-%dT%T%z",$val);
 2331:     $responseDate=~s/(..)$/\:$1/;
 2332:     return $responseDate;
 2333: }
 2334: 
 2335: sub rfc_to_loncapa_Date {
 2336:     my ($date)=@_;
 2337:     $date=~s/\:(..)$/$1/;
 2338:     $time = Date::Parse::str2time($date);
 2339:     return $time;
 2340: }
 2341: 
 2342: sub loncapa_to_ISO_language_convert {
 2343:     my ($loncapa_language)=@_;
 2344:     my %lhash=(
 2345: 	       'notset' => '  ', # Not set
 2346: 	       'notxxx' => '  ', # Not applicable
 2347: 	       'sariso' => 'AR', # Arabic - ISO
 2348: 	       'sarwin' => 'AR', # Arabic - Windows
 2349: 	       'scsiso' => 'CS', # Czech - ISO
 2350: 	       'scswin' => 'CS', # Czech - Windows
 2351: 	       'sdaiso' => 'DA', # Danish
 2352: 	       'sgeiso' => 'DE', # German
 2353: 	       'sgriso' => 'EL', # Greek - ISO
 2354: 	       'sgrwin' => 'EL', # Greek - Windows
 2355: 	       'seniso' => 'EN', # English
 2356: 	       'sspiso' => 'ES', # Spanish
 2357: 	       'setiso' => 'ET', # Estonian - ISO
 2358: 	       'setwin' => 'ET', # Estonian - Windows
 2359: 	       'sfiiso' => 'FI', # Finnish
 2360: 	       'sfriso' => 'FR', # French
 2361: 	       'scriso' => 'HR', # Croatian - ISO
 2362: 	       'scrwin' => 'HR', # Croatian - Windows
 2363: 	       'shuiso' => 'HU', # Hungarian - ISO
 2364: 	       'shuwin' => 'HU', # Hungarian - Windows
 2365: 	       'sisiso' => 'IS', # Icelandic
 2366: 	       'sitiso' => 'IT', # Italian
 2367: 	       'shebiso' => 'HE', # Hebrew - ISO
 2368: 	       'shebwin' => 'HE', # Hebrew - Windows
 2369: 	       'sjasjis' => 'JA', # Japanese - SJIS
 2370: 	       'sjaeuc' => 'JA', # Japanese - EUC
 2371: 	       'skoeuc' => 'KO', # Korean
 2372: 	       'sltiso' => 'LT', # Lithuanian - ISO
 2373: 	       'sltwin' => 'LT', # Lithuanian - Windows
 2374: 	       'slviso' => 'LV', # Latvian - ISO
 2375: 	       'slvwin' => 'LV', # Latvian - Windows
 2376: 	       'sduiso' => 'NL', # Dutch
 2377: 	       'snoiso' => 'NO', # Norwegian
 2378: 	       'spliso' => 'PL', # Polish - ISO
 2379: 	       'splwin' => 'PL', # Polish - Windows
 2380: 	       'sptiso' => 'PT', # Portuguese
 2381: 	       'sroiso' => 'RO', # Romanian - ISO
 2382: 	       'srowin' => 'RO', # Romanian - Windows
 2383: 	       'sruiso' => 'RU', # Russian - ISO
 2384: 	       'sruwin' => 'RU', # Russian - Windows
 2385: 	       'srukoi' => 'RU', # Russian - KOI
 2386: 	       'sskiso' => 'SK', # Slovak - ISO
 2387: 	       'sskwin' => 'SK', # Slovak - Windows
 2388: 	       'ssliso' => 'SL', # Slovenian - ISO
 2389: 	       'sslwin' => 'SL', # Slovenian - Windows
 2390: 	       'ssviso' => 'SV', # Swedish
 2391: 	       'striso' => 'TR', # Turkish - ISO
 2392: 	       'strwin' => 'TR', # Turkish - Windows
 2393: 	       'schbig5' => 'ZH', # Chinese - BIG5
 2394: 	       'scheuc' => 'ZH', Chinese - GB
 2395: 	       );
 2396:     my $iso_language=$lhash{$loncapa_language};
 2397:     return $iso_language;
 2398: }
 2399: 
 2400: sub mimeIANA_to_mimeSuffix {
 2401:     my ($text)=@_;
 2402:     return "[unofficial: $text]";
 2403: }
 2404: 
 2405: sub mimeSuffix_to_mimeIANA {
 2406:     my ($text)=@_;
 2407:     return "[unofficial: $text]";
 2408: }
 2409: 
 2410: sub ISO_to_loncapa_language_convert {
 2411:     my ($iso_language)=@_;
 2412:     my %lhash=(
 2413: 	       '  ' => 'notset', # Not set
 2414: 	       'AR' => 'sariso', # Arabic - ISO
 2415: 	       'CS' => 'scsiso', # Czech - ISO
 2416: 	       'DA' => 'sdaiso', # Danish
 2417: 	       'DE' => 'sgeiso', # German
 2418: 	       'EL' => 'sgriso', # Greek - ISO
 2419: 	       'EN' => 'seniso', # English
 2420: 	       'ES' => 'sspiso', # Spanish
 2421: 	       'ET' => 'setiso', # Estonian - ISO
 2422: 	       'FI' => 'sfiiso', # Finnish
 2423: 	       'FR' => 'sfriso', # French
 2424: 	       'HR' => 'scriso', # Croatian - ISO
 2425: 	       'HU' => 'shuiso', # Hungarian - ISO
 2426: 	       'IS' => 'sisiso', # Icelandic
 2427: 	       'IT' => 'sitiso', # Italian
 2428: 	       'HE' => 'shebiso', # Hebrew - ISO
 2429: 	       'JA' => 'sjasjis', # Japanese - SJIS
 2430: 	       'KO' => 'skoeuc', # Korean
 2431: 	       'LT' => 'sltiso', # Lithuanian - ISO
 2432: 	       'LV' => 'slviso', # Latvian - ISO
 2433: 	       'NL' => 'sduiso', # Dutch
 2434: 	       'NO' => 'snoiso', # Norwegian
 2435: 	       'PL' => 'spliso', # Polish - ISO
 2436: 	       'PT' => 'sptiso', # Portuguese
 2437: 	       'RO' => 'sroiso', # Romanian - ISO
 2438: 	       'RU' => 'sruiso', # Russian - ISO
 2439: 	       'RU' => 'srukoi', # Russian - KOI
 2440: 	       'SK' => 'sskiso', # Slovak - ISO
 2441: 	       'SL' => 'ssliso', # Slovenian - ISO
 2442: 	       'SV' => 'ssviso', # Swedish
 2443: 	       'TR' => 'striso', # Turkish - ISO
 2444: 	       'ZH' => 'schbig5', # Chinese - BIG5
 2445: 	       );
 2446:     my $loncapa_language=$lhash{uc($iso_language)};
 2447:     if (!length($loncapa_language)) {$loncapa_language='notset';}
 2448:     return $loncapa_language;
 2449: }
 2450: 

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