Northwoods.GoWeb.Xml Assembly > Northwoods.GoWeb.Xml Namespace > GoXmlWriter Class : SetNamespaceUri Method |
Generate
method will result in the addition of "xmlns:prefix" attributes in the root element.As an example, consider the following code adapted from the GoSvg implementation:
GoXmlWriter w = ... w.DefaultNamespace = "http://www.w3.org/2000/svg"; w.SetNamespaceUri("xlink", "http://www.w3.org/1999/xlink");
The above code causes the root element to have an "xmlns" attribute. It also defines a prefix, "xlink", that refers to a particular namespace URI. The result may look like:
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> ... </svg>
By calling SetNamespaceUri, you can then define a GoXmlTransformer with code such as:
public override void GenerateBody(Object obj) { base.GenerateBody(obj); GoImage img = (GoImage)obj; Image image = img.Image; String id = this.Writer.FindShared(image); if (id != null) { WriteStartElement("use"); WriteAttrVal("xlink:href", "#S" + id); WriteEndElement(); } }
The above transformer method example is simplified from the code used by the SVG transformer for GoImage
s, where there needs to be a link to the element representing the actual Image.
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2