public ITypedElement getXmlNode(string xml, FhirXmlParsingSettings settings = null, TypedElementSettings tnSettings = null)
        {
            settings = settings ?? FhirXmlParsingSettings.CreateDefault();
            settings.PermissiveParsing = false;

            return(XmlParsingHelpers.ParseToTypedElement(xml, new PocoStructureDefinitionSummaryProvider(), settings, tnSettings));
        }
예제 #2
0
 private static void convertResourceNav(string inputFile, string outputFile, IStructureDefinitionSummaryProvider provider)
 {
     //TODO: call validation after reading
     if (inputFile.Contains("expansions.") || inputFile.Contains("profiles-resources") || inputFile.Contains("profiles-others") || inputFile.Contains("valuesets."))
     {
         return;
     }
     if (inputFile.EndsWith(".xml"))
     {
         var xml  = File.ReadAllText(inputFile);
         var nav  = XmlParsingHelpers.ParseToTypedElement(xml, provider);
         var json = nav.ToJson();
         File.WriteAllText(outputFile, json);
     }
     else
     {
         var json = File.ReadAllText(inputFile);
         var nav  = JsonParsingHelpers.ParseToTypedElement(json, provider,
                                                           settings: new FhirJsonParsingSettings {
             AllowJsonComments = true
         });
         var xml = nav.ToXml();
         File.WriteAllText(outputFile, xml);
     }
 }
예제 #3
0
        private void testSubtree(ITypedElement navXml, ITypedElement navJson, ITypedElement navPoco)
        {
            assertAreNavsEqual(navXml, navJson, navPoco);

            var navRtXml = JsonParsingHelpers.ParseToTypedElement(navXml.ToJson(), navXml.InstanceType,
                                                                  new PocoStructureDefinitionSummaryProvider(), navXml.Name);
            var navRtJson = navJson.ToPoco().ToTypedElement(navJson.Name);
            var navRtPoco = XmlParsingHelpers.ParseToTypedElement(navPoco.ToXml(), navPoco.InstanceType,
                                                                  new PocoStructureDefinitionSummaryProvider());

            assertAreNavsEqual(navRtXml, navRtJson, navRtPoco);
        }
        public void PingpongXml()
        {
            var tp = File.ReadAllText(Path.Combine("TestData", "fp-test-patient.xml"));
            // will allow whitespace and comments to come through
            var navXml = XmlParsingHelpers.ParseToTypedElement(tp, new PocoStructureDefinitionSummaryProvider());
            var json   = navXml.ToJson();

            var navJson = JsonParsingHelpers.ParseToTypedElement(json, new PocoStructureDefinitionSummaryProvider());
            var xml     = navJson.ToXml();

            XmlAssert.AreSame("fp-test-patient.xml", tp, xml, ignoreSchemaLocation: true);
        }
        public void PingpongJson()
        {
            var tp = File.ReadAllText(@"TestData\fp-test-patient.json");
            // will allow whitespace and comments to come through
            var navJson = JsonParsingHelpers.ParseToTypedElement(tp, new PocoStructureDefinitionSummaryProvider());
            var xml     = navJson.ToXml();

            var navXml = XmlParsingHelpers.ParseToTypedElement(xml, new PocoStructureDefinitionSummaryProvider());
            var json   = navXml.ToJson();

            JsonAssert.AreSame(tp, json);
        }
예제 #6
0
        public void SummaryCountUsingStructureDefinitionSummaryProvider()
        {
            var tpXml = File.ReadAllText(Path.Combine("TestData", "mask-text.xml"));

            var nav    = new ScopedNode(getXmlNodeSDSP(tpXml));
            var masker = MaskingNode.ForCount(nav);

            var maskedChildren = masker.Descendants().Count();

            Assert.AreEqual(maskedChildren, 2);

            ITypedElement getXmlNodeSDSP(string xml, FhirXmlParsingSettings s = null) =>
            XmlParsingHelpers.ParseToTypedElement(xml, new StructureDefinitionSummaryProvider(ZipSource.CreateValidationSource()), s);
        }
        public void PingpongJson()
        {
            var tp = File.ReadAllText(Path.Combine("TestData", "fp-test-patient.json"));
            // will allow whitespace and comments to come through
            var navJson = JsonParsingHelpers.ParseToTypedElement(tp, new PocoStructureDefinitionSummaryProvider());
            var xml     = navJson.ToXml();

            var navXml = XmlParsingHelpers.ParseToTypedElement(xml, new PocoStructureDefinitionSummaryProvider());
            var json   = navXml.ToJson();

            List <string> errors = new List <string>();

            JsonAssert.AreSame(@"TestData\fp-test-patient.json", tp, json, errors);
            Console.WriteLine(String.Join("\r\n", errors));
            Assert.AreEqual(0, errors.Count, "Errors were encountered comparing converted content");
        }
예제 #8
0
 private static void convertResourceNav(string inputFile, string outputFile, IStructureDefinitionSummaryProvider provider)
 {
     if (inputFile.EndsWith(".xml"))
     {
         var xml = File.ReadAllText(inputFile);
         var nav = XmlParsingHelpers.ParseToTypedElement(xml, provider, new FhirXmlParsingSettings {
             PermissiveParsing = true
         });
         var json = nav.ToJson();
         File.WriteAllText(outputFile, json);
     }
     else
     {
         var json = File.ReadAllText(inputFile);
         var nav  = JsonParsingHelpers.ParseToTypedElement(json, provider,
                                                           settings: new FhirJsonParsingSettings {
             AllowJsonComments = true, PermissiveParsing = true
         });
         var xml = nav.ToXml();
         File.WriteAllText(outputFile, xml);
     }
 }
예제 #9
0
 public ITypedElement getXmlNode(string xml, FhirXmlParsingSettings s = null) =>
 XmlParsingHelpers.ParseToTypedElement(xml, new PocoStructureDefinitionSummaryProvider(), s);
 public void RoundtripXml()
 {
     ParseDemoPatient.RoundtripXml(reader => XmlParsingHelpers.ParseToTypedElement(reader, new PocoStructureDefinitionSummaryProvider()));
 }