XBinder C# Runtime Library
2.6
|
Provides methods for encoding to XML (text). More...
Public Member Functions | |
virtual void | setNamespaces (XBXmlNamespace[] nsArray) |
XBXmlEncoder (System.IO.Stream ostream) | |
Create an XBXmlEncoder on top of the given output More... | |
XBXmlEncoder (System.IO.Stream ostream, System.String charsetName) | |
Create an XBXmlEncoder on top of the given output More... | |
virtual System.String | checkWellFormedElementAndContent (System.String xmlFragment) |
Parse the given XML fragment to ensure it is well-formed. The fragment must contain a single element and its content, and it must begin with the element start tag. More... | |
void | enableUniqueAttrChecking () |
For the current element only, turn on unique attribute checking. It must be invoked prior to the first encodeAttr; otherwise, the results are undefined. More... | |
virtual void | encodeAttr (System.String name, System.String nsUri, System.String prefix, System.String value_Renamed) |
This method encodes an XML attribute value. More... | |
virtual void | encodeAttrs (IList< XBAttributeBase > attrs) |
This method encodes the attributes in the given list. The prefix in the attribute is treated as a suggested prefix. More... | |
virtual void | encodeChars (System.String data) |
Encode characters, applying escaping. More... | |
virtual void | encodeCharsNoEscaping (System.String data) |
Encode characters, as is (without escaping). Users of this method should apply XML escaping when it may be needed. More... | |
virtual void | encodeNamespace (XBXmlNamespace namespace_Renamed) |
Encode the given namespace on the next start element tag. If called after encodeStartElement, but before encoding any content (characters or child elements) for that element, the declaration will belong to that element. If called after encoding some content, or ending an element, the declaration will belong to the next element. More... | |
virtual void | encodeStartElement (System.String elemName, System.String nsUri, System.String nsPrefix) |
This method encodes an XML start element tag. More... | |
virtual void | encodeEndElement () |
This method closes an element. If the start tag is still open (ie, no content was written), it will be closed with "/>". Otherwise, the most recently opened element is closed with "</qname>" More... | |
virtual void | encodeXsiType (XBQualifiedName typeQName) |
Encode an xsi:type attribute for the given QName Eg. xsi:type="pre:name" More... | |
virtual void | encodeStartDocument () |
This method encodes standard header information at the beginning of the XML document. More... | |
void | setCanonicalXML (bool value) |
Public Attributes | |
const int | XMLINDENT = 3 |
Properties | |
virtual int | Indent [set] |
This method sets the number of spaces per indentation. If the value is set to zero, no indentation of the XML data is done. More... | |
virtual XBXmlNamespace [] | Namespaces [set] |
Set the namespaces that should be encoded in the root element. Each namespace in the array will end up being declared. However, prefixes declared using encodeNamespaces take precedence, so that a prefix found in this array and also given to encodeNamespaces will be replaced with a generated prefix. Also, if a namespace is given a prefix by encodeNamespaces, the prefix given here will be ignored. More... | |
Provides methods for encoding to XML (text).
This class is a Writer, so you can always use the Writer methods to directly write to the output stream. However, doing that has the obvious consequences that you are writing directly to the output stream and this class won't know anything about what you are doing.
com.objsys.xbinder.runtime.XBXmlEncoder.XBXmlEncoder | ( | System.IO.Stream | ostream | ) |
Create an XBXmlEncoder on top of the given output
(byte) stream. Characters will be encoded according to UTF-8. Output will be buffered.
ostream |
com.objsys.xbinder.runtime.XBXmlEncoder.XBXmlEncoder | ( | System.IO.Stream | ostream, |
System.String | charsetName | ||
) |
Create an XBXmlEncoder on top of the given output
(byte) stream. Output will be buffered.
ostream | |
charsetName | Characters will be encoded according to the given charset name (see System.Text.Encoding class). |
|
virtual |
Parse the given XML fragment to ensure it is well-formed. The fragment must contain a single element and its content, and it must begin with the element start tag.
Return the namespace for the element. If the element has a prefix, it will first be resolved according to the namespaces declared in the fragment. If this prefix is not declared, it will be resolved according to the currently declared namespaces known to this encoder. Calling this method has the side-effect of moving the encoder into the content of the current element, if it is not already there. This means you should make calls to encodeAttr and encodeNamespace prior to calling this method.
xmlFragment |
void com.objsys.xbinder.runtime.XBXmlEncoder.enableUniqueAttrChecking | ( | ) |
For the current element only, turn on unique attribute checking. It must be invoked prior to the first encodeAttr; otherwise, the results are undefined.
By default, unique attribute checking is turned off. This is because the uniqueness of attributes is normally the result of data binding's mapping each declared attribute to a property. However, when wildcard attributes are in use, uniqueness is no longer guaranteed.
|
virtual |
This method encodes an XML attribute value.
If a prefix is already declared for the namespace, it will be used. Otherwise, if the suggested prefix is not in use, it will be used. Otherwise, a prefix will be generated. Any prefix used but not declared will automatically be declared.
name | Attribute name |
nsUri | The attribute's namespace (empty if none) |
prefix | Suggested prefix |
value | Attribute value in string form. |
|
virtual |
This method encodes the attributes in the given list. The prefix in the attribute is treated as a suggested prefix.
If a prefix is already declared for the namespace, it will be used. Otherwise, if the suggested prefix is not in use, it will be used. Otherwise, a prefix will be generated. Any prefix used but not declared will automatically be declared.
You should not modify the attribute objects you give to this method. The attribute objects may have their prefix changed.
attrs | The attributes to encode. |
|
virtual |
Encode characters, applying escaping.
Calling this method automatically closes any open element start tag.
|
virtual |
Encode characters, as is (without escaping). Users of this method should apply XML escaping when it may be needed.
Calling this method automatically closes any open element start tag.
|
virtual |
This method closes an element. If the start tag is still open (ie, no content was written), it will be closed with "/>". Otherwise, the most recently opened element is closed with "</qname>"
|
virtual |
Encode the given namespace on the next start element tag. If called after encodeStartElement, but before encoding any content (characters or child elements) for that element, the declaration will belong to that element. If called after encoding some content, or ending an element, the declaration will belong to the next element.
A prefix cannot be bound to two different namespaces in the same scope. To declare the default namespace, use an empty prefix.
|
virtual |
This method encodes standard header information at the beginning of the XML document.
<throws> XBException Thrown, if operation is failed. </throws>
|
virtual |
This method encodes an XML start element tag.
The prefix provided is a suggestion. If the namespace is already mapped to some prefix, the existing prefix is used. Otherwise, if the prefix is not in use, it will be used. Otherwise, a prefix is generated.
No prefix is used when the namespace is the default namespace.
Whichever prefix is used, a namespace declaration will be automatically encoded, if necessary.
For every call to encodeStartElement, you should make a corresponding call to encodeEndElement.
elemName | The name of element. |
nsUri | The element's namespace (possibly empty) |
nsPrefix | A suggested prefix for nsUri |
<throws> XBException Thrown, if operation is failed. </throws>
|
virtual |
Encode an xsi:type attribute for the given QName Eg. xsi:type="pre:name"
The namespace for the QName should already be mapped to a prefix (or be the default namespace).
This method will determine the prefix to use inside the attribute value. This method may undeclare the default namespace (necessary if the given QName does not have a namespace).
|
set |
This method sets the number of spaces per indentation. If the value is set to zero, no indentation of the XML data is done.
value | Number of spaces per indentation level. |
|
set |
Set the namespaces that should be encoded in the root element. Each namespace in the array will end up being declared. However, prefixes declared using encodeNamespaces take precedence, so that a prefix found in this array and also given to encodeNamespaces will be replaced with a generated prefix. Also, if a namespace is given a prefix by encodeNamespaces, the prefix given here will be ignored.
To declare the default namespace, use an empty prefix. For the default namespace, declarations made with encodeNamespaces take precedence.