Parameters
- prefix
- must not be null
- uri
- if null this method removes any URI associated with the prefix
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.