ASN1C C# Runtime Library  7.8
Static Public Member Functions | List of all members
Asn1XmlUtil Class Reference

Static Public Member Functions

static string CaptureElement (System.Xml.XmlReader reader, bool contentOnly, bool injectNsDecls)
 
static void EncodeDouble (Asn1XmlEncoder buffer, double data, System.String elemName, System.String nsPrefix)
 
static void EncodeDouble (Asn1XmlEncoder buffer, double data)
 
static void EncodeNSAttrs (Asn1XmlEncoder buffer, Asn1XmlNamespace[] nsArray)
 
static double GetMinusZero ()
 
static string GetTextContent (System.Xml.XmlReader reader)
 
static System.String GetXMLString (System.String data)
 
static bool IsMinusZero (double value)
 
static void KeepNullsInString (bool keep)
 
static String [] TokenizeXsdList (String listValue)
 

Detailed Description

This class contains some general purpose static utility functions for XML encoding or decoding.

Member Function Documentation

◆ CaptureElement()

static string CaptureElement ( System.Xml.XmlReader  reader,
bool  contentOnly,
bool  injectNsDecls 
)
static

Capture the XML text for an element, returning it in a string object. Optionally, this method can capture the element's content only.

PRE: The reader is positioned on the start tag of the element to be captured, call it E. POST: The reader is positioned on the event following element E.

Parameters
contentOnlyif TRUE, only capture the content of the current element. Otherwise, captures the current element's tags, namespace declarations, and attributes, as well as the content.
injectNsDeclsif TRUE, the outermost element(s) should include namespace declarations for prefixes used by those elements but not declared.

References Asn1OpenTypeField.actualType, Asn1Type.Decode(), Asn1OpenTypeField.decoder, and Asn1Type.DecodeXML().

◆ EncodeDouble() [1/2]

static void EncodeDouble ( Asn1XmlEncoder  buffer,
double  data,
System.String  elemName,
System.String  nsPrefix 
)
static

This method encodes an ASN.1 real value using the XML encoding (non-XER).

Parameters
bufferEncode message buffer object
valueValue to be encoded.
elemNameElement name
nsPrefixElement namespace prefix value

References Asn1XmlEncoder.EncodeEndElement(), and Asn1XmlEncoder.EncodeStartElement().

Referenced by Asn1XmlEncodeBuffer.EncodeDoubleValue(), and Asn1XmlOutputStream.EncodeDoubleValue().

◆ EncodeDouble() [2/2]

static void EncodeDouble ( Asn1XmlEncoder  buffer,
double  data 
)
static

This method encodes an ASN.1 real value using the XML encoding (non-XER).

Parameters
bufferEncode message buffer object
valueValue to be encoded.

References Asn1XmlXerEncoder.Copy(), and Asn1Real.NormalizedRealValueToString().

◆ EncodeNSAttrs()

static void EncodeNSAttrs ( Asn1XmlEncoder  buffer,
Asn1XmlNamespace []  nsArray 
)
static

This method encodes XML namespace attributes in the form 'xmlns[:prefix]="uri"'.

Parameters
nsArrayArray of XML namespace prefix/URI mappings.

References Asn1XmlXerEncoder.Copy().

◆ GetMinusZero()

static double GetMinusZero ( )
static

This method returns double value for "minus zero" (-0) special XML value.

Returns
double value for "-0".

◆ GetTextContent()

static string GetTextContent ( System.Xml.XmlReader  reader)
static

Return the current text node and subsequent text content until an EndElement is found.

This will throw an exception if any Element nodes are encountered. PRE: The reader is positioned on a Text or CDATA event. POST: The reader is positioned just past the closing EndElement.

◆ GetXMLString()

static System.String GetXMLString ( System.String  data)
static

This method will convert the given string value into XML character content by escaping special characters in the sting such as ampersand (&), left angle bracket (>), etc.

Parameters
dataString to convert
Returns
Converted string value

Referenced by Asn1XmlEncodeBuffer.EncodeData(), and Asn1XmlOutputStream.EncodeData().

◆ IsMinusZero()

static bool IsMinusZero ( double  value)
static

This method will return true, if value is "minus zero" (-0) special XML value.

Parameters
valuevalue to test
Returns
true, if this value is "-0".

◆ KeepNullsInString()

static void KeepNullsInString ( bool  keep)
static

This method allows users to toggle the output of a null entity code in XML strings. Null bytes are not permitted in any XML document, but are permissible in ASN.1 strings. When converting, users may elect to retain null bytes as entities (�) by passing true to this function. By default, null bytes are dropped.

Parameters
keepBoolean switch to keep or ignore null bytes.

◆ TokenizeXsdList()

static String [] TokenizeXsdList ( String  listValue)
static

Return an array of strings representing the (lexical) values of an xsd:list

Parameters
listValuethe lexical value of the xsd:list. It need not have whitepspace collapse applied yet.
Returns
array of lexical values, one per value in the listValue. No empty strings will appear in the array.

References Asn1XmlNamespace.Prefix, and Asn1XmlNamespace.URI.