-
Notifications
You must be signed in to change notification settings - Fork 7
Attributes
Josef edited this page Sep 3, 2021
·
9 revisions
All CAEXElements which can have Attributes assigned implement the Interface IObjectWithAttributes.
The programming examples show how to access attribute values and ensure the correct encoding and decoding of attribute values according to the defined attribute datatype.
using Aml.Engine.CAEX;
void AttributeValuesAndDataTypes(CAEXDocument document)
{
// adds a raw attribute - without value and datatype - to an element
var instanceHierarchy = document.CAEXFile.InstanceHierarchy.Append("ih1");
var element1 = instanceHierarchy.InternalElement.Append("element1");
var attribute1 = element1.Attribute.Append("attribute1");
// Attributes provide 'Value'- and 'AttributeDataType'- properties
// The value property is of type 'string' which means that the user
// has to define the correct xml format for the desired data type himself.
// storing a date time value, using 'Value' and 'AttributeDataType'.
// The standard .NET class XmlConvert provides Xml decoding and encoding methods.
// The ClrToXmlType method converts the ClrType to a XSD datatype.
attribute1.Value = System.Xml.XmlConvert.ToString(DateTime.Now, System.Xml.XmlDateTimeSerializationMode.Local);
attribute1.AttributeDataType = AttributeTypeType.ClrToXmlType(typeof(DateTime));
// Attributes provide 'AttributeValue'- property (also 'DefaultAttributeValue')
// This property selects the correct xml encoding and decoding, depending of the value type.
attribute1.AttributeValue = DateTime.Now;
attribute1.DefaultAttributeValue = DateTime.MinValue;
}
Home | Installation | API | Solutions
Getting Started
- Install
- First Steps with CAEX
- Working with CAEX Libraries
- Working with CAEX Relations
- Managing Inheritance
- Attribut Values
- Document Versions
Extended Examples
API Reference Guide