Inheritance: IXmlEncoder
コード例 #1
0
        public void should_have_correct_root_element()
        {
            var metadata = Library.Blank();
            var xml = new XmlEncoder().Create(Guid.NewGuid(), metadata);

            string root = XName.Get("MD_Metadata", "http://www.isotc211.org/2005/gmd").ToString();
            xml.Should().HaveRoot(root);
        }
コード例 #2
0
ファイル: DownloadController.cs プロジェクト: jncc/topcat
        public HttpResponseMessage Get(Guid id)
        {
            var record = db.Load<Record>(id);

            var xml = new XmlEncoder().Create(record.Id, record.Gemini);
            var result = new HttpResponseMessage(HttpStatusCode.OK) { Content = new StringContent(xml.ToString()) };

            result.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment")
            {
                FileName = "topcat-record-" + record.Id.ToString().ToLower() + ".xml"
            };
            result.Content.Headers.ContentType = new MediaTypeHeaderValue("application/xml");

            return result;
        }
コード例 #3
0
        public void should_be_valid_gemini()
        {
            // without this we get an error message 417
            // http://stackoverflow.com/questions/566437/http-post-returns-the-error-417-expectation-failed-c
            ServicePointManager.Expect100Continue = false;

            // start with the example document
            Metadata metadata = Library.Example();

            // ...encode it into xml
            XDocument doc = new XmlEncoder().Create(new Guid("b97aac01-5e5d-4209-b626-514e40245bc1"), metadata);

            // ...validate it with the CEH validator
            ValidationResultSet result = new Validator().Validate(doc);

            // IGNORE MEDIN VALIDATION ERRORS
            result.Results.Single(r => r.Validation.StartsWith("GEMINI2"))
                .Valid
                .Should().BeTrue();
        }