Controlling Namespace Serialization of LINQ to XML

You can explicitly control how LINQ to XML serializes the namespaces for an XML tree.  You can control whether a namespace is serialized as the default namespace for a tree, or whether the namespace will use a prefix.  Namespace declarations look like attribute declarations, so to simplify the LINQ to XML tree, LINQ to XML…

0

Reducing Connaissance (Interconnectedness) and Increasing Robustness using LINQ

This is one in a series of posts on transforming Open XML WordprocessingML to XHtml.  You can find the complete list of posts here. Recently I went through the process of handling a variety of details in the XHtml converter – generating XHtml entities wherever possible, and making sure that whatever else, the XHtml converter doesn’t throw…

0

Serializing Encoded XML Documents using LINQ to XML

Writing encoded (utf-8, utf-16, etc.) documents using LINQ to XML is pretty straight-forward, but there is one interesting dynamic of the semantics.  When serializing to a file on disk, then you can set the encoding in the XML declaration, and the resulting XML document will be serialized as you wish.  However, if you are writing…

1

Convert XDocument to XmlDocument (and Convert XmlDocument to XDocument)

Some time ago, I blogged about an approach for converting an XElement object to an XmlNode object, and vice versa.  This is useful when you want to use a programming interface that takes and returns objects of type XmlNode, but you want to use the expressiveness and power of LINQ to XML for your code…

1

Writing Entity References using LINQ to XML

I need to write out some XHtml, and in several places, I want that XHtml to contain entities references.  However, you can’t simply write the entity reference like this: This is one in a series of posts on transforming Open XML WordprocessingML to XHtml.  You can find the complete list of posts here. This blog is inactive.New…

2

DescendantsAndSelfTrimmed LINQ to XML Axis Method

There are some circumstances where I need a variation on the DescendantsAndSelf axis method that allows me to specify that specific elements (and the descendants of those elements) are ‘trimmed’ from the returned collection.  One of the things that’s great about LINQ to XML is the ease with which we can create specialized axis methods…

0

XML Element and Attribute Name Guidelines

Some time ago, a dev team here at Microsoft asked me to review their XML vocabulary that they had designed.  They wanted to know if the element and attribute names in their vocabulary design were good ones. This blog is inactive.New blog: EricWhite.com/blogBlog TOCNote: I suspect that this is one of those religious issues.  I’m…

4

Recursive Approach to Pure Functional Transformations of XML

Writing pure functional transformations a in a recursive style enables us to put together interesting transformations in a very small amount of code.  Using some specific techniques that allow us to write this code very concisely, this approach takes advantage of some perhaps obscure semantics of LINQ to XML.  I’ve used this approach to write…

3

Document-Centric Transforms using LINQ to XML

When thought of in a certain way, XML documents come in two flavors – data-centric and document-centric.  Further, there are two types of document-centric documents.  This post presents my thoughts about approaches to various types of document-centric transformations – data-centric to document-centric, document-centric to data-centric, and document-centric to document-centric.  Then, I’ll tie my thoughts back…

0

Empty Elements and Self-Closing Tags

Last January, I blogged about an approach to normalizing LINQ to XML trees.  That post is based on another post, Manually Cloning LINQ to XML Trees.  In those posts, my code to clone an element would clone a self-closing element (<Tag/>) as self-closing, and an empty element with a start and end tag (<Tag></Tag>) as…

1