GoDiagram Win Reference
SetNamespaceUri Method

must not be null
if null this method removes any URI associated with the prefix
Define the namespace URI for a prefix string, used when writing prefixed attribute names.
Syntax
'Declaration
 
Public Overridable Sub SetNamespaceUri( _
   ByVal prefix As String, _
   ByVal uri As String _
) 
public virtual void SetNamespaceUri( 
   string prefix,
   string uri
)

Parameters

prefix
must not be null
uri
if null this method removes any URI associated with the prefix
Remarks
This should be called to establish a namespace URI for a prefix before calling WriteStartElement(String) or WriteAttrVal with a name that has that prefix. To specify the default namespace for the root element, set the DefaultNamespace property. Calls to this method before a call to a Generate method will result in the addition of "xmlns:prefix" attributes in the root element.
Example

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 GoImages, where there needs to be a link to the element representing the actual Image.

Requirements

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

See Also

Reference

GoXmlWriter Class
GoXmlWriter Members
GetNamespaceUri Method

 

 


© 2015. Northwoods Software Corporation. All Rights Reserved.

Send Feedback