//[Variation(Priority = 0, Desc = "Write and valIdate XDocumentType")] public void writer_5() { string expectedXml = "<!DOCTYPE root PUBLIC \"\" \"\"[<!ELEMENT root ANY>]>"; var doc = new XDocumentType("root", "", "", "<!ELEMENT root ANY>"); TestToStringAndXml(doc, expectedXml); var ws = new XmlWriterSettings(); ws.ConformanceLevel = ConformanceLevel.Document; ws.OmitXmlDeclaration = true; // Set to true when FileIO is ok ws.CloseOutput = false; // Use a file to replace this when FileIO is ok var m = new MemoryStream(); using (XmlWriter wr = XmlWriter.Create(m, ws)) { doc.WriteTo(wr); } m.Position = 0; using (TextReader r = new StreamReader(m)) { string actualXml = r.ReadToEnd(); TestLog.Compare(expectedXml, actualXml, "XDocumentType writeTo method failed"); } }
public static XObject Update(this XDocumentType node, string name, string publicId = null, string systemId = null, string internalSubset = null) { CheckNullReference(node); CheckArgumentNull(name, "name"); return(new XDocumentType(name, publicId, systemId, internalSubset)); }
internal static IXmlNode WrapNode(XObject node) { XDocument xDocument = node as XDocument; XDocument xDocument1 = xDocument; if (xDocument != null) { return(new XDocumentWrapper(xDocument1)); } XElement xElement = node as XElement; XElement xElement1 = xElement; if (xElement != null) { return(new XElementWrapper(xElement1)); } XContainer xContainer = node as XContainer; XContainer xContainer1 = xContainer; if (xContainer != null) { return(new XContainerWrapper(xContainer1)); } XProcessingInstruction xProcessingInstruction = node as XProcessingInstruction; XProcessingInstruction xProcessingInstruction1 = xProcessingInstruction; if (xProcessingInstruction != null) { return(new XProcessingInstructionWrapper(xProcessingInstruction1)); } XText xText = node as XText; XText xText1 = xText; if (xText != null) { return(new XTextWrapper(xText1)); } XComment xComment = node as XComment; XComment xComment1 = xComment; if (xComment != null) { return(new XCommentWrapper(xComment1)); } XAttribute xAttribute = node as XAttribute; XAttribute xAttribute1 = xAttribute; if (xAttribute != null) { return(new XAttributeWrapper(xAttribute1)); } XDocumentType xDocumentType = node as XDocumentType; XDocumentType xDocumentType1 = xDocumentType; if (xDocumentType != null) { return(new Class4(xDocumentType1)); } return(new XObjectWrapper(node)); }
public override XDocument ToXml(string graphName, ref IList <IDataObject> dataObjects) { try { XDocumentType docType = new XDocumentType( "html", "-//W3C//DTD XHTML 1.0 Strict//EN", "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd", null); XDocument doc = new XDocument(); doc.AddFirst(docType); if (dataObjects.Count == 1) { XElement html = CreateHtmlListView(graphName, dataObjects[0]); doc.Add(html); } else { XElement html = CreateHtmlTableView(graphName, ref dataObjects); doc.Add(html); } return(doc); } catch (Exception e) { _logger.Error("Error creating HTML content: " + e); throw e; } }
static void Main(string[] args) { XDeclaration myDeclaration = new XDeclaration("1.0", "utf-8", "yes"); XDocumentType myDocType = new XDocumentType("FruitList", null, null, null); // create XElements XElement myNameElement = new XElement("Name", "Orange"); XElement mySizeElement = new XElement("Size", "Large"); // create my root element XElement myRootElement = new XElement("Fruit", myNameElement, mySizeElement); // create the XML document XDocument myDoc = new XDocument( myDeclaration, myDocType, myRootElement); // print out the XElement object Console.WriteLine(myDoc); // wait for input before exiting Console.WriteLine("Press enter to finish"); Console.ReadLine(); }
public void ToXml(Stream stm) { XDocumentType docType = new XDocumentType("plist", "-//Apple//DTD PLIST 1.0//EN", "http://www.apple.com/DTDs/PropertyList-1.0.dtd", null); XDocument doc = new XDocument(docType); XElement root = new XElement("plist"); root.Add(new XAttribute("version", "1.0")); doc.Add(root); AppendToXml(root); if (doc.DocumentType != null) { doc.DocumentType.InternalSubset = null; } XmlWriterSettings xws = new XmlWriterSettings(); xws.OmitXmlDeclaration = false; xws.NewLineHandling = NewLineHandling.None; xws.Indent = true; xws.Encoding = new System.Text.UTF8Encoding(false); xws.ConformanceLevel = ConformanceLevel.Document; using (XmlWriter writer = XmlWriter.Create(stm, xws)) { doc.Save(writer); } }
public void Save(string fileName) { string internalSubset = null; XDeclaration declaration = new XDeclaration("1.0", "UTF-8", null); XDocumentType docType = new XDocumentType("plist", PUBLIC_ID, STRING_ID, internalSubset); XmlWriterSettings settings = new XmlWriterSettings { Encoding = new System.Text.UTF8Encoding(false), ConformanceLevel = ConformanceLevel.Document, Indent = true, IndentChars = "\t", NewLineChars = "\n", NewLineHandling = NewLineHandling.None }; XElement plistNode = new XElement(TYPE_PLIST, ParseDictForSave(this)); plistNode.SetAttributeValue("version", "1.0"); XDocument file = new XDocument(declaration, docType); file.Add(plistNode); XmlWriter xmlwriter = XmlWriter.Create(fileName, settings); file.Save(xmlwriter); xmlwriter.Close(); }
public string TransformDOcument() { string theHTML = string.Empty; var xDocType = new XDocumentType("html", null, null, null); var xDocument = new XDocument(xDocType); var xElem = new XElement("html"); xDocument.Add(xElem); var settings = new XmlWriterSettings { OmitXmlDeclaration = true, Indent = true, IndentChars = "\t" }; using (var writer = XmlWriter.Create(@"C:\Users\wolf\Desktop\test.html", settings)) { xDocument.WriteTo(writer); } using (var ms = new MemoryStream()) { using (var docMS = new XmlTextWriter(ms, new UTF8Encoding(false)) { Formatting = Formatting.Indented }) { xDocument.WriteTo(docMS); return(Encoding.UTF8.GetString(ms.ToArray())); } } }
internal override bool DeepEquals(XNode node) { XDocumentType other = node as XDocumentType; return(other != null && _name == other._name && _publicId == other._publicId && _systemId == other.SystemId && _internalSubset == other._internalSubset); }
public void DocumentType(string[] docType1, string[] docType2, bool checkHashCode) { var dtd1 = new XDocumentType(docType1[0], docType1[1], docType1[2], docType1[3]); var dtd2 = new XDocumentType(docType2[0], docType2[1], docType2[2], docType2[3]); VerifyComparison(checkHashCode, dtd1, dtd2); }
/// <summary> /// Initializes an instance of the XDocumentType class /// from another XDocumentType object. /// </summary> /// <param name="other"><see cref="XDocumentType"/> object to copy from.</param> public XDocumentType(XDocumentType other) { if (other == null) throw new ArgumentNullException("other"); _name = other._name; _publicId = other._publicId; _systemId = other._systemId; _internalSubset = other._internalSubset; }
static void Main(string[] args) { string xml = "<?xml version=\"1.0\" encoding=\"utf-8\" ?><!DOCTYPE beer PUBLIC \"-//BEER//DTD beer DTD version 2.0//KF//XML\" \"Kingfisher.dtd\"><root></root>"; XDocument doc = XDocument.Parse(xml); XDocumentType _type = (XDocumentType)doc.Nodes().Where(x => x.NodeType == XmlNodeType.DocumentType).FirstOrDefault(); _type.SystemId = "C:/Beer/Kingfisher.dtd"; }
protected virtual XObject VisitDocumentType(XDocumentType node) { return(node.Update( node.Name, node.PublicId, node.SystemId, node.InternalSubset )); }
public string ToPapXml() { var doc = new XDocument(); var docType = new XDocumentType("pap", "-//WAPFORUM//DTD PAP 2.1//EN", "http://www.openmobilealliance.org/tech/DTD/pap_2.1.dtd", "<?wap-pap-ver supported-versions=\"2.0\"?>"); doc.AddFirst(docType); var pap = new XElement("pap"); var pushMsg = new XElement("push-message"); pushMsg.Add(new XAttribute("push-id", this.PushId)); pushMsg.Add(new XAttribute("source-reference", this.SourceReference)); if (!string.IsNullOrEmpty(this.PpgNotifyRequestedTo)) { pushMsg.Add(new XAttribute("ppg-notify-requested-to", this.PpgNotifyRequestedTo)); } if (this.DeliverAfterTimestamp.HasValue) { pushMsg.Add(new XAttribute("deliver-after-timestamp", this.DeliverAfterTimestamp.Value.ToUniversalTime().ToString("s", CultureInfo.InvariantCulture) + "Z")); } if (this.DeliverBeforeTimestamp.HasValue) { pushMsg.Add(new XAttribute("deliver-before-timestamp", this.DeliverBeforeTimestamp.Value.ToUniversalTime().ToString("s", CultureInfo.InvariantCulture) + "Z")); } //Add all the recipients foreach (var r in Recipients) { var address = new XElement("address"); var addrValue = r.Recipient; if (!string.IsNullOrEmpty(r.RecipientType)) { addrValue = string.Format( "WAPPUSH={0}%3A{1}/TYPE={2}", WebUtility.UrlEncode(r.Recipient), r.Port, r.RecipientType); } address.Add(new XAttribute("address-value", addrValue)); pushMsg.Add(address); } pushMsg.Add(new XElement("quality-of-service", new XAttribute("delivery-method", this.QualityOfService.ToString().ToLowerInvariant()))); pap.Add(pushMsg); doc.Add(pap); return("<?xml version=\"1.0\"?>" + Environment.NewLine + doc.ToString(SaveOptions.None)); }
public StatusFilterResolver(XDocumentType def) { //Discarded unreachable code: IL_0002, IL_0006 //IL_0003: Incompatible stack heights: 0 vs 1 //IL_0007: Incompatible stack heights: 0 vs 1 SingletonReader.PushGlobal(); base._002Ector(def); m_RegIssuer = def; }
public static DataReader CreateReader(string dataXml) { //var xDocument = new XDocument(); var xDocumentType = new XDocumentType("names", null, null, "<!ENTITY laquo \"«\">"); dataXml = dataXml.Insert(0, xDocumentType.ToString()); var doc = XDocument.Parse(dataXml); return(CreateReader(doc)); }
//[Variation(Priority = 0, Desc = "DTD : all field", Params = new object[] { new string[] { "root", "a", "b", "c" }, new string[] { "root", "a", "b", "c" }, true })] //[Variation(Priority = 1, Desc = "DTD : all nulls", Params = new object[] { new string[] { "root", null, null, null }, new string[] { "root", null, null, null }, true })] //[Variation(Priority = 2, Desc = "DTD : internal subset only", Params = new object[] { new string[] { "root", null, null, "data" }, new string[] { "root", null, null, "data" }, true })] //[Variation(Priority = 0, Desc = "DTD (negative) : name diff", Params = new object[] { new string[] { "A", "", "", "" }, new string[] { "B", "", "", "" }, false })] //[Variation(Priority = 1, Desc = "DTD (negative) : subset diff", Params = new object[] { new string[] { "A", null, null, "aa" }, new string[] { "A", null, null, "bb" }, false })] //[Variation(Priority = 2, Desc = "DTD (negative) : null vs. \"\"", Params = new object[] { new string[] { "A", "", "", "" }, new string[] { "A", null, null, null }, false })] public void DTD() { bool expected = (bool)Variation.Params[2]; var data0 = Variation.Params[0] as string[]; var data1 = Variation.Params[1] as string[]; XDocumentType dtd1 = new XDocumentType(data0[0], data0[1], data0[2], data0[3]); XDocumentType dtd2 = new XDocumentType(data1[0], data1[1], data1[2], data1[3]); VerifyComparison(expected, dtd1, dtd2); }
public void Save(string fileName, XDeclaration declaration, XDocumentType docType) { XElement xElement = new XElement("plist", ParseDictForSave(this)); xElement.SetAttributeValue("version", "1.0"); XDocument xDocument = new XDocument(declaration, docType); xDocument.Add(xElement); xDocument.Save(fileName); }
public void Save(string fileName, XDeclaration declaration, XDocumentType docType) { XElement plistNode = new XElement("plist", this.ParseDictForSave(this)); plistNode.SetAttributeValue("version", "1.0"); XDocument file = new XDocument(declaration, docType); file.Add(plistNode); file.Save(fileName); }
public override void DoctypeDecl(XDocumentType docType) { if (docType == null) { return; } Trace.TraceInformation($"DocType root element: {docType.Name}"); Trace.TraceInformation($"DocType root PUBLIC: {docType.PublicId}"); Trace.TraceInformation($"DocType root SYSTEM: {docType.SystemId}"); }
public void WriteToFile() { string publicId = "-//Apple//DTD PLIST 1.0//EN"; string systemId = "http://www.apple.com/DTDs/PropertyList-1.0.dtd"; string internalSubset = null; XDeclaration declaration = new XDeclaration("1.0", Encoding.UTF8.EncodingName, null); XDocumentType docType = new XDocumentType("plist", publicId, systemId, internalSubset); XMLDict.Save(filePath, declaration, docType); }
static void Main(string[] args) { var bookObj = new BookStore(); var bookList = bookObj.GetBookStores(); XDocumentType docType = new XDocumentType("bookstoredoc", null, null, @"<!ELEMENT bookstore (book+)> <!ELEMENT book (title|year|price|author+) > <!ATTLIST book category CDATA #REQUIRED> <!ELEMENT title (#PCDATA)> <!ATTLIST title lang CDATA #REQUIRED> <!ELEMENT year (#PCDATA)> <!ELEMENT price (#PCDATA)> <!ELEMENT author (name+)> <!ELEMENT name (#PCDATA)>"); var xmlDocument = new XDocument(new XElement("bookstore", bookList.Select(x => new XElement("book", new XAttribute("category", x.Category), new XElement("title", new XAttribute("lang", x.Lang), x.Title), new XElement("year", x.Year), new XElement("price", x.Price), new XElement("author", x.Author.Select(y => new XElement("name", y.Name))) )))); xmlDocument.Save(@"D:\Test.xml"); XmlReader reader = XmlReader.Create(@"D:\Test.xml"); XmlSchemaSet schemaSet = new XmlSchemaSet(); XmlSchemaInference schema = new XmlSchemaInference(); schemaSet = schema.InferSchema(reader); foreach (XmlSchema s in schemaSet.Schemas()) { using (var stringWriter = new StringWriter()) { using (var writer = XmlWriter.Create(stringWriter)) { s.Write(writer); } string text = stringWriter.ToString(); } } Console.WriteLine("Hello World!"); }
/// <summary> /// Initializes an instance of the XDocumentType class /// from another XDocumentType object. /// </summary> /// <param name="other"><see cref="XDocumentType"/> object to copy from.</param> public XDocumentType(XDocumentType other) { if (other == null) { throw new ArgumentNullException("other"); } this.name = other.name; this.publicId = other.publicId; this.systemId = other.systemId; this.internalSubset = other.internalSubset; }
internal static CreatorIssuer InvokeRequest(XObject init) { //Discarded unreachable code: IL_0002 //IL_0003: Incompatible stack heights: 0 vs 1 XDocument xDocument = init as XDocument; if (xDocument != null) { return(new AuthenticationComposerPool(xDocument)); } XElement xElement = init as XElement; if (xElement != null) { return(new SerializerDicCandidate(xElement)); } XContainer xContainer = init as XContainer; if (xContainer != null) { return(new ItemReaderMapper(xContainer)); } XProcessingInstruction xProcessingInstruction = init as XProcessingInstruction; if (xProcessingInstruction != null) { return(new ContainerIssuer(xProcessingInstruction)); } XText xText = init as XText; if (xText != null) { return(new ErrorEventConsumer(xText)); } XComment xComment = init as XComment; if (xComment != null) { return(new BaseIssuer(xComment)); } XAttribute xAttribute = init as XAttribute; if (xAttribute != null) { return(new ProccesorIssuer(xAttribute)); } XDocumentType xDocumentType = init as XDocumentType; if (xDocumentType != null) { return(new StatusFilterResolver(xDocumentType)); } return(new FieldIssuer(init)); }
/// <summary> /// Initializes an instance of the XDocumentType class /// from another XDocumentType object. /// </summary> /// <param name="other"><see cref="XDocumentType"/> object to copy from.</param> public XDocumentType(XDocumentType other) { if (other == null) { throw new ArgumentNullException("other"); } _name = other._name; _publicId = other._publicId; _systemId = other._systemId; _internalSubset = other._internalSubset; }
public void WriteToFile() { // Corrected header of the plist string publicId = "-//Apple//DTD PLIST 1.0//EN"; string stringId = "http://www.apple.com/DTDs/PropertyList-1.0.dtd"; string internalSubset = null; XDeclaration declaration = new XDeclaration("1.0", "UTF-8", null); XDocumentType docType = new XDocumentType("plist", publicId, stringId, internalSubset); xmlDict.Save(filePath, declaration, docType); }
public void XDocumentTypeDocTypeVariation() { XDocumentType toChange = new XDocumentType("root", "", "", ""); XDocumentType original = new XDocumentType(toChange); using (EventsHelper eHelper = new EventsHelper(toChange)) { toChange.Name = "newName"; Assert.True(toChange.Name.Equals("newName"), "Name did not change"); eHelper.Verify(XObjectChange.Name, toChange); } }
public void XDocTypeInXStreamingElement() { XDocumentType node = new XDocumentType( "DOCTYPE", "note", "SYSTEM", "<!ELEMENT note (to,from,heading,body)><!ELEMENT to (#PCDATA)><!ELEMENT from (#PCDATA)><!ELEMENT heading (#PCDATA)><!ELEMENT body (#PCDATA)>"); XStreamingElement streamElement = new XStreamingElement("Root", node); Assert.Throws <InvalidOperationException>(() => streamElement.Save(new MemoryStream())); }
// Token: 0x06001569 RID: 5481 RVA: 0x0006FAF0 File Offset: 0x0006DCF0 internal static IXmlNode WrapNode(XObject node) { XDocument xdocument = node as XDocument; if (xdocument != null) { return(new XDocumentWrapper(xdocument)); } XElement xelement = node as XElement; if (xelement != null) { return(new XElementWrapper(xelement)); } XContainer xcontainer = node as XContainer; if (xcontainer != null) { return(new XContainerWrapper(xcontainer)); } XProcessingInstruction xprocessingInstruction = node as XProcessingInstruction; if (xprocessingInstruction != null) { return(new XProcessingInstructionWrapper(xprocessingInstruction)); } XText xtext = node as XText; if (xtext != null) { return(new XTextWrapper(xtext)); } XComment xcomment = node as XComment; if (xcomment != null) { return(new XCommentWrapper(xcomment)); } XAttribute xattribute = node as XAttribute; if (xattribute != null) { return(new XAttributeWrapper(xattribute)); } XDocumentType xdocumentType = node as XDocumentType; if (xdocumentType != null) { return(new XDocumentTypeWrapper(xdocumentType)); } return(new XObjectWrapper(node)); }
public void ReadFromString(string text) { XDocument doc = ParseXmlNoDtd(text); version = (string) doc.Root.Attribute("version"); XElement xml = doc.XPathSelectElement("plist/dict"); var dict = ReadElement(xml); if (dict == null) throw new Exception("Error parsing plist file"); root = dict as PlistElementDict; if (root == null) throw new Exception("Malformed plist file"); documentType = doc.DocumentType; }
void RecordDocType(XDocumentType docType) { if (docType != null) { //specifying the copied doctype like this caused empty [] to be added //_usedDocType = new XDocumentType(docType); //but like this it is fine! _usedDocType = new XDocumentType(docType.Name, docType.PublicId, docType.SystemId, (string.IsNullOrEmpty(docType.InternalSubset) ? null : docType.InternalSubset)); } else { _usedDocType = null; } }
public void DocumentType(string[] docType1, string[] docType2, bool checkHashCode) { var dtd1 = new XDocumentType(docType1[0], docType1[1], docType1[2], docType1[3]); var dtd2 = new XDocumentType(docType2[0], docType2[1], docType2[2], docType2[3]); VerifyComparison(checkHashCode, dtd1, dtd2); }