A simple implementation of the UK Gemini 2.2 metadata standard.
Exemple #1
0
        public XDocument Create(Guid id, Metadata m)
        {
            // see http://data.gov.uk/sites/default/files/UK%20GEMINI%20Encoding%20Guidance%201.4.pdf

            return new XDocument(
                new XElement(gmd + "MD_Metadata",
                    new XAttribute(XNamespace.Xmlns + "gmd", gmd.NamespaceName),
                    new XAttribute(XNamespace.Xmlns + "gco", gco.NamespaceName),
                    new XAttribute(XNamespace.Xmlns + "gml", gml.NamespaceName),
                    MakeFileIdentifier(id),
                    MakeDatasetLanguage(m), // continually confused with MetadataLanguage
                    MakeResourceType(m),
                    MakeMetadataPointOfContact(m),
                    MakeMetadataDate(m),
                    new XElement(gmd + "identificationInfo",
                        new XElement(gmd + "MD_DataIdentification",
                            new XAttribute("id", "_" + id),
                            new XElement(gmd + "citation",
                                new XElement(gmd + "CI_Citation",
                                    MakeTitle(m),
                                    MakeDatasetReferenceDate(m),
                                    MakeUniqueResourceIdentifier(id))),
                            MakeAbstract(m),
                            MakeResponsibleOrganisation(m),
                            MakeKeywords(m),
                            MakeLimitationsOnPublicAccessAndUseConstraints(m), // think ienum will actually work
                            MakeDatasetLanguage(m),
                            MakeTopicCategory(m),
                            new XElement(gmd + "extent",
                                new XElement(gmd + "EX_Extent",
                                    MakeBoundingBox(m),
                                    MakeTemporalExtent(m))))),
                    new XElement(gmd + "distributionInfo",
                        new XElement(gmd + "MD_Distribution",
                            MakeDataFormat(m),
                            MakeResourceLocator(m, id))),
                    MakeLineage(m)));
        }
Exemple #2
0
 XElement MakeTitle(Metadata metadata)
 {
     return new XElement(gmd + "title",
         new XElement(gco + "CharacterString", metadata.Title));
 }
Exemple #3
0
 XElement MakeTemporalExtent(Metadata metadata)
 {
     return new XElement(gmd + "temporalElement",
         new XElement(gmd + "EX_TemporalExtent",
             new XElement(gmd + "extent",
                 new XElement(gml + "TimePeriod",
                     new XAttribute(gml + "id", "t1"),
                     new XElement(gml + "beginPosition", metadata.TemporalExtent.Begin),
                     new XElement(gml + "endPosition", metadata.TemporalExtent.End)))));
 }
Exemple #4
0
 XElement MakeResponsibleOrganisation(Metadata metadata)
 {
     return new XElement(gmd + "pointOfContact",
         Shared.MakeResponsiblePartyNode(metadata.ResponsibleOrganisation));
 }
Exemple #5
0
 XElement MakeResourceType(Metadata metadata)
 {
     return new XElement(gmd + "hierarchyLevel",
         new XElement(gmd + "MD_ScopeCode",
             new XAttribute("codeList", "http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/codelist/gmxCodelists.xml#MD_ScopeCode"),
             new XAttribute("codeListValue", metadata.ResourceType),
                 metadata.ResourceType));
 }
Exemple #6
0
        XElement MakeResourceLocator(Metadata metadata, Guid id)
        {
            string fileName = WebificationUtility.ToUrlFriendlyString(Path.GetFileName(metadata.ResourceLocator));
            // but this doesn't work so well when the resource locator contains the guid like this
            // http://data.jncc.gov.uk/data/d4ddd363-97eb-4ef6-9b8b-6f019f434103-ProcessedImages.zip
            // so remove the proceeding guid
            if (fileName.IsNotBlank() && fileName.StartsWith(id + "-"))
                fileName = fileName.Replace(id + "-", String.Empty);

            return new XElement(gmd + "transferOptions",
                new XElement(gmd + "MD_DigitalTransferOptions",
                    new XElement(gmd + "onLine",
                        new XElement(gmd + "CI_OnlineResource",
                            new XElement(gmd + "linkage",
                                new XElement(gmd + "URL", metadata.ResourceLocator)),
                            new XElement(gmd + "name",
                                new XElement(gco + "CharacterString", fileName))))));
        }
Exemple #7
0
 XElement MakeMetadataPointOfContact(Metadata metadata)
 {
     return new XElement(gmd + "contact",
         Shared.MakeResponsiblePartyNode(metadata.MetadataPointOfContact));
 }
Exemple #8
0
 XElement MakeBoundingBox(Metadata metadata)
 {
     if (metadata.BoundingBox == null)
     {
         return null;
     }
     return new XElement(gmd + "geographicElement",
         new XElement(gmd + "EX_GeographicBoundingBox",
             new XElement(gmd + "westBoundLongitude",
                 new XElement(gco + "Decimal", metadata.BoundingBox.West)),
             new XElement(gmd + "eastBoundLongitude",
                 new XElement(gco + "Decimal", metadata.BoundingBox.East)),
             new XElement(gmd + "southBoundLatitude",
                 new XElement(gco + "Decimal", metadata.BoundingBox.South)),
             new XElement(gmd + "northBoundLatitude",
                 new XElement(gco + "Decimal", metadata.BoundingBox.North))));
 }
Exemple #9
0
 XElement MakeLineage(Metadata metadata)
 {
     return new XElement(gmd + "dataQualityInfo",
         new XElement(gmd + "DQ_DataQuality",
             new XElement(gmd + "scope",
                 new XElement(gmd + "DQ_Scope",
                     new XElement(gmd + "level",
                         new XElement(gmd + "MD_ScopeCode",
                             new XAttribute("codeList", "http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/codelist/gmxCodelists.xml#MD_ScopeCode"),
                             new XAttribute("codeListValue", "dataset"))))),
             new XElement(gmd + "lineage",
                 new XElement(gmd + "LI_Lineage",
                     new XElement(gmd + "statement",
                         new XElement(gco + "CharacterString", metadata.Lineage))))));
 }
Exemple #10
0
 XElement MakeLimitationsOnPublicAccessAndUseConstraints(Metadata metadata)
 {
     return new XElement(gmd + "resourceConstraints",
         new XElement(gmd + "MD_LegalConstraints",
             new XElement(gmd + "useLimitation",
                 new XElement(gco + "CharacterString", metadata.UseConstraints)),
             new XElement(gmd + "accessConstraints",
                 new XElement(gmd + "MD_RestrictionCode",
                     new XAttribute("codeList", "http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/codelist/gmxCodelists.xml#MD_RestrictionCode"),
                     new XAttribute("codeListValue", "otherRestrictions"),
                     "otherRestrictions")),
             new XElement(gmd + "otherConstraints",
                 new XElement(gco + "CharacterString", metadata.LimitationsOnPublicAccess))
             ));
 }
Exemple #11
0
        XElement MakeKeywords(Metadata metadata)
        {
            return new XElement(gmd + "descriptiveKeywords",
                new XElement(gmd + "MD_Keywords",
                    from keyword in metadata.Keywords
                    select new XElement(gmd + "keyword",
                        new XElement(gco + "CharacterString", keyword.Value))));

            // String vocab = metadata.Keywords.FirstOrDefault().Vocab;
            // a half implemented attempt to encode the vocab along with keywords
                        /*, new XElement(gmd + "thesaurusName",
                new XElement(gmd + "CI_Citation",
                    new XElement(gmd + "title",
                        new XElement(gco + "CharacterString", vocab)),
                        new XElement(gmd+"date",
                            new XElement(gmd+"CI_Date",
                                new XElement(gmd+"date",
                                    new XElement(gco + "Date", metadata.DatasetReferenceDate)),
                                    new XElement(gmd+"dateType",
                                        new XElement(gmd + "CI_DateTypeCode",
                            new XAttribute("codeList", "http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/codelist/gmxCodelists.xml#CI_DateTypeCode"),
                            new XAttribute("codeListValue", "publication")))))))));*/

            // writing massiviely nested iso compatible xml documents by hand, bleurgh
        }
Exemple #12
0
 XElement MakeDatasetReferenceDate(Metadata metadata)
 {
     return new XElement(gmd + "date",
         new XElement(gmd + "CI_Date",
             new XElement(gmd + "date",
                 new XElement(gco + "Date", metadata.DatasetReferenceDate)),
             new XElement(gmd + "dateType",
                 new XElement(gmd + "CI_DateTypeCode",
                     new XAttribute("codeList", "http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/codelist/gmxCodelists.xml#CI_DateTypeCode"),
                     new XAttribute("codeListValue", "publication"),
                     metadata.DatasetReferenceDate))));
 }
Exemple #13
0
        XElement MakeDatasetLanguage(Metadata metadata)
        {
            // this is required unfortunately by ISO19115 but not Gemini - default to eng

            return new XElement(gmd + "language",
                new XElement(gmd + "LanguageCode",
                    new XAttribute("codeList", "http://www.loc.gov/standards/iso639-2/php/code_list.php"),
                    new XAttribute("codeListValue", "eng"),
                    "eng"));
        }
Exemple #14
0
 XElement MakeDataFormat(Metadata metadata)
 {
     return new XElement(gmd + "distributionFormat",
         new XElement(gmd + "MD_Format",
             new XElement(gmd + "name",
                 new XElement(gco + "CharacterString", metadata.DataFormat)),
             new XElement(gmd + "version",
                 new XElement(gco + "CharacterString", "Unknown"))));
     // not supporting versions for data format
 }
Exemple #15
0
 XElement MakeTopicCategory(Metadata metadata)
 {
     return new XElement(gmd + "topicCategory",
         new XElement(gmd + "MD_TopicCategoryCode", metadata.TopicCategory));
 }
Exemple #16
0
 XElement MakeMetadataDate(Metadata metadata)
 {
     return new XElement(gmd + "dateStamp",
         new XElement(gco + "Date", metadata.MetadataDate.ToString("yyyy-MM-dd")));
 }
Exemple #17
0
 XElement MakeAbstract(Metadata metadata)
 {
     return new XElement(gmd + "abstract",
         new XElement(gco + "CharacterString", metadata.Abstract));
 }