コード例 #1
0
        /// <summary>
        /// Get the request message entity from XML.
        /// </summary>
        /// <typeparam name="T">Type of IRequestMessageBase.</typeparam>
        /// <param name="doc">The XDocument.</param>
        /// <returns>Request Message Entity.</returns>
        public static IRequestMessageBase FillEntityWithXml <T>(XDocument doc)
            where T : IRequestMessageBase, new()
        {
            try
            {
                var requestMessage = new T();
                var serializer     = new XmlSerializer(typeof(T));
                using (var reader = doc.CreateReader())
                {
                    requestMessage = (T)serializer.Deserialize(reader);
                }

                return(requestMessage);
            }
            catch (Exception e)
            {
                throw new Exception("Deserialize XDocument failed.", e);
            }
        }
コード例 #2
0
        public static XmlDocument RemoveXmlns(String xml)
        {
            XDocument d = XDocument.Parse(xml);

            d.Root.Descendants().Attributes().Where(x => x.IsNamespaceDeclaration).Remove();

            d.Root.Descendants().Attributes().Where(x => x.Name.Namespace != "").Remove();

            foreach (var elem in d.Descendants())
            {
                elem.Name = elem.Name.LocalName;
            }

            var xmlDocument = new XmlDocument();

            xmlDocument.Load(d.CreateReader());

            return(xmlDocument);
        }
コード例 #3
0
        async Task Xml2Json(IOwinContext context)
        {
            string[] fields = context.Request.Uri.PathAndQuery.Split('/');

            if (fields.Length != 6)
            {
                await context.Response.WriteAsync("xml2json requires github gistId, XSLT, JSON-LD context and JSON-LD framing type");

                context.Response.StatusCode = (int)HttpStatusCode.BadRequest;
                return;
            }

            string gistId            = fields[2];
            string xsltName          = fields[3];
            string jsonLdContextName = fields[4];
            string jsonLdFrameType   = fields[5];

            string xsltText = await LoadMetadata(gistId, xsltName);

            string jsonLdContextText = await LoadMetadata(gistId, jsonLdContextName);

            XDocument original = XDocument.Load(context.Request.Body);

            XDocument styleSheet = XDocument.Parse(xsltText);

            JToken jsonLdContext = JObject.Parse(jsonLdContextText);

            XslCompiledTransform transform = new XslCompiledTransform();

            transform.Load(styleSheet.CreateReader());

            XsltArgumentList arguments = new XsltArgumentList();

            arguments.AddParam("baseAddress", "", "http://example.org/book/");

            IGraph graph = Common.GraphFromXml(original, transform, arguments);

            JObject jsonLd = Common.JsonFromGraph(graph, jsonLdFrameType, jsonLdContext);

            await context.Response.WriteAsync(jsonLd.ToString());

            context.Response.StatusCode = (int)HttpStatusCode.OK;
        }
コード例 #4
0
            private static XmlDocument RemoveXmlns(String xml)
            {
                XDocument doc = XDocument.Parse(xml);

                Debug.Assert(doc.Root != null, "d.Root != null");

                doc.Root.Descendants().Attributes().Where(x => x.IsNamespaceDeclaration).Remove();

                foreach (XElement elem in doc.Descendants())
                {
                    elem.Name = elem.Name.LocalName;
                }

                XmlDocument xmlDocument = new XmlDocument();

                xmlDocument.Load(doc.CreateReader());

                return(xmlDocument);
            }
コード例 #5
0
ファイル: WebUtil.cs プロジェクト: Fedorm/core-master
        /// <summary>
        /// Create a WCF message object that is sent as a response. Write the contents of the XDocument to the response.
        /// </summary>
        /// <param name="document"></param>
        /// <returns></returns>
        internal static Message CreateResponseMessage(XDocument document)
        {
            using (document.CreateReader())
            {
                Message message = Message.CreateMessage(MessageVersion.None, String.Empty, document.CreateReader());

                message.Properties.Add(WebBodyFormatMessageProperty.Name, new WebBodyFormatMessageProperty(WebContentFormat.Xml));

                var property = new HttpResponseMessageProperty {
                    StatusCode = HttpStatusCode.OK
                };

                property.Headers[HttpResponseHeader.ContentType] = FormatterConstants.ApplicationXmlContentType;

                message.Properties.Add(HttpResponseMessageProperty.Name, property);

                return(message);
            }
        }
コード例 #6
0
        public void Load(string path)
        {
            if (string.IsNullOrEmpty(path))
            {
                throw new ApplicationException("Missing File Path");
            }

            XmlSerializerNamespaces ns = new XmlSerializerNamespaces();

            ns.Add(String.Empty, String.Empty);
            XmlSerializer serializer = new XmlSerializer(typeof(T));

            XDocument xDoc = XDocument.Load(path);

            using (XmlReader reader = xDoc.CreateReader())
            {
                Value = (T)serializer.Deserialize(reader);
            }
        }
コード例 #7
0
        /// <summary>
        /// Creates the XML namespace manager.
        /// </summary>
        /// <param name="xDoc">The x document.</param>
        /// <returns></returns>
        private XmlNamespaceManager CreateXmlNamespaceManager(XDocument xDoc)
        {
            if (xDoc == null)
            {
                return(null);
            }

            var reader           = xDoc.CreateReader();
            var root             = xDoc.Root;
            var namespaceManager = new XmlNamespaceManager(reader.NameTable);
            var nsMgr            = new XmlNamespaceManager(reader.NameTable);

            foreach (var xmlNameSpace in this.XmlNameSpaces)
            {
                nsMgr.AddNamespace(xmlNameSpace.Prefix, xmlNameSpace.NameSpace);
            }

            return(nsMgr);
        }
コード例 #8
0
                //[Variation("XmlReader ReadState EndOfFile", Priority = 0)]
                public void ReadState5()
                {
                    XDocument doc = XDocument.Parse("<a/>");
                    XmlReader r   = doc.CreateReader();

                    while (r.Read())
                    {
                    }
                    ;
                    try
                    {
                        r.ReadContentAsInt();
                    }
                    catch (InvalidOperationException) { }
                    if (r.ReadState != ReadState.EndOfFile)
                    {
                        throw new TestFailedException("");
                    }
                }
コード例 #9
0
ファイル: DiagHelper.cs プロジェクト: Fedorm/core-master
        /// <summary>Create and cache the compiled transform if was not already created earlier.</summary>
        private static void ConfigureXslCompiledTransform()
        {
            if (null == _compiledTransform)
            {
                lock (_lockObject)
                {
                    if (null == _compiledTransform)
                    {
                        _compiledTransform = new XslCompiledTransform();

                        XDocument document = XDocument.Parse(diagxslt.diag);
                        using (var readerStream = document.CreateReader())
                        {
                            _compiledTransform.Load(readerStream);
                        }
                    }
                }
            }
        }
コード例 #10
0
ファイル: App.cs プロジェクト: dolani/CodeTorch
        public static App Populate(XDocument doc)
        {
            XmlSerializer serializer = new XmlSerializer(typeof(App));
            XmlReader     reader     = doc.CreateReader();

            reader.MoveToContent();

            App item = null;

            try
            {
                item = (App)serializer.Deserialize(reader);
            }
            catch (Exception ex)
            {
                throw new ApplicationException(String.Format("Error occurred while processing App - {0}", doc.Root.FirstNode.ToString()), ex);
            }
            return(item);
        }
コード例 #11
0
ファイル: ResponseParser.cs プロジェクト: vsbopi/PrtgAPI
        internal static T GetObjectProperties <T>(PrtgResponse response, XmlEngine xmlEngine, ObjectProperty mandatoryProperty)
        {
            var xml  = HtmlParser.Default.GetXml(response);
            var xDoc = new XDocument(xml);

            //If the response does not contain the mandatory property, we are executing as a read only user, and
            //should return null

            var name = HtmlParser.DefaultPropertyPrefix + ObjectPropertyParser.GetObjectPropertyName(mandatoryProperty).TrimEnd('_');

            if (xDoc.Descendants(name).ToList().Count > 0)
            {
                var items = xmlEngine.DeserializeObject <T>(xDoc.CreateReader());

                return(items);
            }

            return(default(T));
        }
コード例 #12
0
        public static Transaction Parse(XDocument xml)
        {
            Transaction transaction = new Transaction();
            Debtor      debtor      = new Debtor();
            Creditor    creditor    = new Creditor();
            XmlReader   reader      = xml.CreateReader();


            XmlDocument doc  = new XmlDocument();
            string      xmls = xml.ToString();

            doc.LoadXml(xmls);
            string json = Newtonsoft.Json.JsonConvert.SerializeXmlNode(doc);

            var parsed = JObject.Parse(json);

            transaction.dateTime = parsed.SelectToken("Document.CstmrCdtTrfInitn.GrpHdr.CreDtTm").Value <DateTime>();
            JToken t = parsed.SelectToken("Document.CstmrCdtTrfInitn.PmtInf.CdtTrfTxInf.Amt.InstdAmt");

            transaction.currency = t.First.First.Value <string>();
            transaction.amount   = t.Last.First.Value <decimal>();
            transaction.EndToEnd = parsed.SelectToken("Document.CstmrCdtTrfInitn.PmtInf.PmtInfId").Value <string>();
            transaction.invoice  = parsed.SelectToken("Document.CstmrCdtTrfInitn.PmtInf.CdtTrfTxInf.RmtInf.Ustrd").Value <string>();

            debtor.name     = parsed.SelectToken("Document.CstmrCdtTrfInitn.PmtInf.Dbtr.Nm").Value <string>();
            debtor.IBAN     = parsed.SelectToken("Document.CstmrCdtTrfInitn.PmtInf.DbtrAcct.Id.IBAN").Value <string>();
            debtor.bankName = parsed.SelectToken("Document.CstmrCdtTrfInitn.PmtInf.DbtrAgt.FinInstnId.BIC").Value <string>();
            //debtor.country = parsed.SelectToken("Document.CstmrCdtTrfInitn.PmtInf.


            creditor.name     = parsed.SelectToken("Document.CstmrCdtTrfInitn.PmtInf.CdtTrfTxInf.Cdtr.Nm").Value <string>();
            creditor.IBAN     = parsed.SelectToken("Document.CstmrCdtTrfInitn.PmtInf.CdtTrfTxInf.CdtrAcct.Id.IBAN").Value <string>();
            creditor.bankName = parsed.SelectToken("Document.CstmrCdtTrfInitn.PmtInf.CdtTrfTxInf.CdtrAgt.FinInstnId.BIC").Value <string>();
            creditor.country  = parsed.SelectToken("Document.CstmrCdtTrfInitn.PmtInf.CdtTrfTxInf.Cdtr.PstlAdr.Ctry").Value <string>();
            creditor.address  = parsed.SelectToken("Document.CstmrCdtTrfInitn.PmtInf.CdtTrfTxInf.Cdtr.PstlAdr.AdrLine").First.Value <string>() + parsed.SelectToken("Document.CstmrCdtTrfInitn.PmtInf.CdtTrfTxInf.Cdtr.PstlAdr.AdrLine").Last.Value <string>();
            creditor.IBAN     = parsed.SelectToken("Document.CstmrCdtTrfInitn.PmtInf.CdtTrfTxInf.CdtrAcct.Id.IBAN").Value <string>();


            transaction.creditor = creditor;
            transaction.debtor   = debtor;

            return(transaction);
        }
コード例 #13
0
 public void TransformXDocument(XDocument inputXml)
 {
     try
     {
         var sb = new StringBuilder();
         using (var writer = XmlWriter.Create(sb))
         {
             _xslCfdiCompilado.Transform(inputXml.CreateReader(ReaderOptions.None), writer);
             writer.Close();
             writer.Flush();
         }
         cadenaOriginal = sb.ToString();
     }
     catch
     {
         //handle the exception your way
         throw;
     }
 }
コード例 #14
0
        public static DataSet GetDataSet(this XDocument data, XDocument schema = null)
        {
            var ds = new DataSet();

            {
                var xmlReader = data.CreateReader(ReaderOptions.None);
                xmlReader.MoveToContent();
                ds.ReadXml(xmlReader);
            }

            if (schema != null)
            {
                var xmlReader = schema.CreateReader(ReaderOptions.None);
                xmlReader.MoveToContent();
                ds.ReadXmlSchema(xmlReader);
            }

            return(ds);
        }
コード例 #15
0
        /// <summary>
        /// Creates a <see cref="XmlNamespaceManager"/> for DMP.
        /// </summary>
        /// <param name="document">
        /// The xml document.
        /// </param>
        /// <returns>
        /// The namespace manager.
        /// </returns>
        private static XmlNamespaceManager CreateXsltNamespaceManager(XDocument document)
        {
            if (document == null)
            {
                throw new ArgumentNullException("document");
            }

            using (var reader = document.CreateReader())
            {
                if (reader.NameTable == null)
                {
                    throw new InvalidOperationException("Could not get a name table from input");
                }

                var requestNamespaceManager = new XmlNamespaceManager(reader.NameTable);
                requestNamespaceManager.AddNamespace("xslt", XsltNamespace);
                return(requestNamespaceManager);
            }
        }
コード例 #16
0
ファイル: HelperMethods.cs プロジェクト: umair-me/ASA-API
        public static string GetIRMark(byte[] Xml)
        {
            string vbLf   = "\n";
            string vbCrLf = "\r\n";
            int    length = Xml.Length;
            // Convert Byte array to string
            string    text = Encoding.UTF8.GetString(Xml, 0, length);
            XDocument xDoc = XDocument.Parse(text, LoadOptions.PreserveWhitespace);

            XNamespace xns  = xDoc.Root.Name.Namespace;
            XElement   body = xDoc.Root.Element(xns + "Body");

            var irmarkelement = from e in body.Descendants()
                                where e.Name.LocalName == "IRmark"
                                select e;

            if (irmarkelement != null)
            {
                irmarkelement.Remove();
            }
            XDocument xdoc = XDocument.Parse(body.ToString(), LoadOptions.PreserveWhitespace);

            var reader = xdoc.CreateReader();

            reader.MoveToContent();
            string strxml = reader.ReadOuterXml();

            // Normalise the document using C14N (Canonicalisation)
            using (Stream stream = ToStream(strxml))
            {
                byte[] Buffer = new byte[stream.Length];
                stream.Read(Buffer, 0, (int)stream.Length);
                text = Encoding.UTF8.GetString(Buffer, 0, (int)stream.Length);
                text = text.Replace("&#xD;", "");
                text = text.Replace(vbCrLf, vbLf);
                text = text.Replace(vbCrLf, vbLf);
                byte[] b         = Encoding.UTF8.GetBytes(text);
                SHA1   SHA       = SHA1.Create();
                byte[] hashbytes = SHA.ComputeHash(b);
                return(Convert.ToBase64String(hashbytes));
            }
        }
コード例 #17
0
        private XDocument SignXml(XDocument xDocument)
        {
            XmlDocument xmlDocument = new XmlDocument();

            using (XmlReader xmlReader = xDocument.CreateReader())
            {
                xmlDocument.Load(xmlReader);
            }

            SignedXml signedXml = new SignedXml(xmlDocument);

            signedXml.SigningKey = _certificate.PrivateKey;

            Reference reference = new Reference();

            reference.Uri = "";

            XmlDsigEnvelopedSignatureTransform env = new XmlDsigEnvelopedSignatureTransform();

            reference.AddTransform(env);

            signedXml.AddReference(reference);
            signedXml.ComputeSignature();

            KeyInfo         keyInfo     = new KeyInfo();
            KeyInfoX509Data keyInfoData = new KeyInfoX509Data(_certificate);

            keyInfo.AddClause(keyInfoData);
            signedXml.KeyInfo = keyInfo;

            XmlElement xmlDigitalSignature = signedXml.GetXml();

            xmlDocument.DocumentElement.AppendChild(xmlDocument.ImportNode(xmlDigitalSignature, true));

            using (var nodeReader = new XmlNodeReader(xmlDocument))
            {
                nodeReader.MoveToContent();
                xDocument = XDocument.Load(nodeReader);
            }

            return(xDocument);
        }
コード例 #18
0
        public void BeforeSendReply(ref Message reply, object correlationState)
        {
            var reqxdoc = correlationState as XDocument;

            if (reply.IsFault) //replaces s:Server with Server in faultcode
            {
                MessageBuffer msgbuf = reply.CreateBufferedCopy(int.MaxValue);
                var           r      = msgbuf.CreateMessage();

                var xdoc = new XDocument();
                using (var wr = xdoc.CreateWriter())
                {
                    r.WriteMessage(wr);
                }

                if (xdoc.Descendants("faultstring").First().Value == "requesterror")
                {
                    var fc = xdoc.Descendants(NameSpaces.xdgws + "FaultCode").First();
                    reqxdoc = XDocument.Parse(fc.Value);
                    var xfault = reqxdoc.Root.Element("Fault");
                    xdoc.Descendants("faultstring").First().Value = xfault.Element("reason").Value;
                    fc.Value = xfault.Element("detail").Value;
                }

                xdoc.Descendants("faultcode").First().Value = "Server";
                using (var reader = xdoc.CreateReader())
                {
                    var rmsg = Message.CreateMessage(reader, int.MaxValue, reply.Version).CreateBufferedCopy(int.MaxValue);
                    reply = rmsg.CreateMessage();
                }
            }

            if (reqxdoc != null)
            {
                var msg = reqxdoc.Descendants(NameSpaces.xdgws + "MessageID").First();
                reqxdoc.Descendants(NameSpaces.xdgws + "Linking").First().Add(new XElement(NameSpaces.xdgws + "RequireNonRepudiationReceipt", msg.Value));
                msg.Value = Guid.NewGuid().ToString("D");

                reply.Headers.Add(new DgwsMessageHeader(new DgwsHeader(reqxdoc.Root.Element(NameSpaces.xdgws + "Header"))));
                reqxdoc.Descendants(NameSpaces.xdgws + "FlowStatus").First().Value = "flow_finalized_succesfully";
            }
        }
コード例 #19
0
        void RefreshRecordingList()
        {
            XDocument requestDoc = new XDocument(
                new XElement("PlaceWareConfCenter", new XAttribute("authUser", Properties.Settings.Default.Username), new XAttribute("authPassword", Config.Password),
                             new XElement("ListRecordingsRequest", new XAttribute("listDeleted", false),
                                          new XElement("TimeIntervalQuery", new XAttribute("fieldName", "startTime"),
                                                       new XElement("TimeInterval", new XAttribute("startTime", "2015-01-01T00:00:00Z"), new XAttribute("endTime", "2016-10-26T00:00:00Z"))),
                                          new XElement("FieldList",
                                                       new XElement("Name", "title"),
                                                       new XElement("Name", "createTime"),
                                                       new XElement("Name", "duration"),
                                                       new XElement("Name", "owner"),
                                                       new XElement("Name", "name"),
                                                       new XElement("Name", "registration"),
                                                       new XElement("Name", "size"),
                                                       new XElement("Name", "startTime"),
                                                       new XElement("Name", "timeZone"),
                                                       new XElement("Name", "reid")))));

            XmlDocument doc = new XmlDocument();

            doc.Load(requestDoc.CreateReader());

            XmlDocument resp = XmlApiClient.PostMessageRequest(doc);

            XmlNodeList list = resp.SelectNodes("//Recording");

            _recordings.Clear();
            foreach (XmlNode node in list)
            {
                Recording recording = new Recording(node);
                _recordings.Add(recording);
            }

            Debug.WriteLine(_recordings.Count.ToString());
            dataGridView1.DataSource = _recordings;

            foreach (DataGridViewColumn column in dataGridView1.Columns)
            {
                dataGridView1.Columns[column.Name].SortMode = DataGridViewColumnSortMode.Automatic;
            }
        }
コード例 #20
0
        public static void Load(XDocument doc)
        {
            XmlSerializer serializer = new XmlSerializer(typeof(EmailConnectionType));
            XmlReader     reader     = doc.CreateReader();

            reader.MoveToContent();

            EmailConnectionType item = null;

            try
            {
                item = (EmailConnectionType)serializer.Deserialize(reader);
            }
            catch (Exception ex)
            {
                throw new ApplicationException(String.Format("Error occurred while processing EmailConnectionType - {0}", doc.Root.FirstNode.ToString()), ex);
            }

            Configuration.GetInstance().EmailConnectionTypes.Add(item);
        }
コード例 #21
0
        public Message CreateXmlResponse(XDocument document)
        {
            if (document == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("document");
            }
            Message message;

            if (document.FirstNode == null)
            {
                message = Message.CreateMessage(MessageVersion.None, (string)null);
            }
            else
            {
                message = Message.CreateMessage(MessageVersion.None, (string)null, document.CreateReader());
            }
            message.Properties.Add(WebBodyFormatMessageProperty.Name, WebBodyFormatMessageProperty.XmlProperty);
            AddContentType(WebOperationContext.DefaultXmlMediaType, this.OutgoingResponse.BindingWriteEncoding);
            return(message);
        }
コード例 #22
0
        public static List <T> DeserializeParamsListOf <T>(string xmlFilename)
        {
            List <T>  result;
            XDocument xdoc = XDocument.Load(xmlFilename);

            try
            {
                System.Xml.Serialization.XmlSerializer serializer =
                    new System.Xml.Serialization.XmlSerializer(typeof(List <T>));

                System.Xml.XmlReader reader = xdoc.CreateReader();

                result = (List <T>)serializer.Deserialize(reader);
                reader.Close();
            }
            finally
            {
            }
            return(result);
        }
        public static bool Validate(XDocument xml, XDocument xsd)
        {
            bool errors = false;

            var shemas = new XmlSchemaSet();

            shemas.Add(null, xsd.CreateReader());

            xml.Validate(shemas, (o, e) =>
            {
                Console.WriteLine("{0}", e.Message);
                errors = true;
            });;

            if (errors == false)
            {
                return(true);
            }
            return(false);
        }
コード例 #24
0
        private static XmlDocument ReadXml(string lang)
        {
            var langDir = AppEnvironment.AppLanguagePath;
            var doc     = new XDocument(new XElement("Resource"));

            var files = Directory.GetFiles(langDir, "*_" + lang + ".xml");

            foreach (var tmp in files.Select(XDocument.Load).Where(tmp => tmp.Root != null))
            {
                doc.Root.Add(tmp.Root.Elements());
            }

            var xmlDoc = new XmlDocument();

            using (var reader = doc.CreateReader())
            {
                xmlDoc.Load(reader);
            }
            return(xmlDoc);
        }
コード例 #25
0
        private void showDesp(string result)
        {
            XmlSerializer serializer = new XmlSerializer(typeof(PatientUserDataContract));

            //   result =   result ;
            XDocument document = XDocument.Parse(result);

            PatientUserDataContract Description = serializer.Deserialize(document.CreateReader()) as PatientUserDataContract;
            // ArrayOfMailDataContract mails = (ArrayOfMailDataContract) serializer.Deserialize(document.CreateReader());

            var app = App.Current as App;

            app.PatientDescription = (PatientUserDataContract)Description;

            textBlock_Name.Text               = "Name : " + Description.UserName;
            textBlock_Age.Text                = "Age : " + Description.Age;
            textBlock_Gender.Text             = "Gender : " + Description.Gender;
            textBlock_AllergyDrugs.Text       = "Allergy Drugs : \n" + Description.Allery;
            textBlock_PatientDescription.Text = "Description : \n" + Description.Description;
        }
コード例 #26
0
        public void DotNetXmlSerializerCanDeserializeXml()
        {
            var xSerializer = new XmlSerializer <TestObject>(new XmlSerializationOptions(shouldSerializeCharAsInt: true));
            var xmlString   = xSerializer.Serialize(this.testObject);

            XDocument  xml = XDocument.Parse(xmlString);
            var        dotNetXmlSerializer = new System.Xml.Serialization.XmlSerializer(typeof(TestObject));
            TestObject actual;

            using (var reader = xml.CreateReader())
            {
                actual = (TestObject)dotNetXmlSerializer.Deserialize(reader);
            }

            Assert.That(actual.Bool, Is.EqualTo(this.testObject.Bool));
            Assert.That(actual.Char, Is.EqualTo(this.testObject.Char));
            Assert.That(actual.Double, Is.EqualTo(this.testObject.Double));
            Assert.That(actual.Int, Is.EqualTo(this.testObject.Int));
            Assert.That(actual.String, Is.EqualTo(this.testObject.String));
        }
コード例 #27
0
        public static void Load(XDocument doc)
        {
            XmlSerializer serializer = new XmlSerializer(typeof(Menu));
            XmlReader     reader     = doc.CreateReader();

            reader.MoveToContent();

            Menu menu = null;

            try
            {
                menu = (Menu)serializer.Deserialize(reader);
            }
            catch (Exception ex)
            {
                throw new ApplicationException(String.Format("Error occurred while processing Menu", doc.Root.FirstNode.ToString()), ex);
            }

            Configuration.GetInstance().Menus.Add(menu);
        }
コード例 #28
0
        public static XDocument Transform(XDocument doc, string fileXslt)
        {
            XDocument xslt = XDocument.Load(fileXslt);  // check Xslt file is valid

            XslCompiledTransform trans = new XslCompiledTransform();

            // XsltArgumentList xsltArg = new XsltArgumentList();
            // xsltArg.AddExtensionObject("urn:script-items", obj);

            trans.Load(fileXslt); //  xslt.CreateReader());

            XDocument outputDoc = new XDocument();

            using (var writer = outputDoc.CreateWriter())
            {
                trans.Transform(doc.CreateReader(), writer);
            }

            return(outputDoc);
        }
コード例 #29
0
        public static XmlDocument CreateCRMListOfChanges_XML(string date)
        {
            var xdoc = new XDocument(
                new XElement("CrmRequest",
                             new XAttribute("ProductName", "CU1"),
                             new XElement("Parameters", new XAttribute("TemplateName", "CU_LEIDListChanges"),
                                          new XElement("Parameter", date, new XAttribute("Name", "@ListType"))),
                             new XElement("Parameters", new XAttribute("TemplateName", "CU_LEIDListChanges"),
                                          new XElement("Parameter", date, new XAttribute("Name", "@DateFrom")))
                             )
                );

            var xmldoc = new XmlDocument();

            using (var xmlReader = xdoc.CreateReader())
            {
                xmldoc.Load(xmlReader);
            }
            return(xmldoc);
        }
コード例 #30
0
ファイル: XmlUtil.cs プロジェクト: plzm/pelazem.xml
        public XDocument Transform(XDocument xdoc, string xsltMarkup)
        {
            bool enableDebug = true;

            var xslt = new XslCompiledTransform(enableDebug);

            var sb = new StringBuilder();

            using (var xwriter = XmlWriter.Create(sb))
            {
                xslt.Load(XmlReader.Create(new StringReader(xsltMarkup)));

                xslt.Transform(xdoc.CreateReader(ReaderOptions.None), xwriter);

                xwriter.Close();
                xwriter.Flush();
            }

            return(XDocument.Parse(sb.ToString()));
        }
コード例 #31
0
ファイル: IXmlLineInfo.cs プロジェクト: Rayislandstyle/corefx
 public void CastToInterface()
 {
     XDocument doc = new XDocument();
     Assert.IsAssignableFrom<IXmlLineInfo>(doc);
     Assert.IsAssignableFrom<IXmlLineInfo>(doc.CreateReader());
 }