/// <summary> /// This is an internal method that is used to write the <paramref name="value"/> for the specified /// <paramref name="locale"/> /// The method create a XML element named by the name parameter. /// It will only write the XML element if the text inside <paramref name="value"/> is not null or empty /// </summary> /// <param name="namespacePrefix"> /// The namespace prefix /// </param> /// <param name="name"> /// The name of the XML element /// </param> /// <param name="value"> /// The text value. /// </param> /// <param name="locale"> /// The locale. /// </param> protected void WriteTextType( NamespacePrefixPair namespacePrefix, ElementNameTable name, string value, string locale) { if (!string.IsNullOrEmpty(value)) { this._writer.WriteStartElement( namespacePrefix.Prefix, NameTableCache.GetElementName(name), namespacePrefix.NS); if (!string.IsNullOrEmpty(locale)) { this._writer.WriteAttributeString(XmlConstants.XmlPrefix, XmlConstants.LangAttribute, null, locale); } this._writer.WriteString(value); this._writer.WriteEndElement(); } }
/// <summary> /// Write the element if it's value is not empty or null /// </summary> /// <param name="namespacePrefix"> /// The namespace prefix pair /// </param> /// <param name="elementName"> /// The <see cref="ElementNameTable"/> element name /// </param> /// <param name="value"> /// The elements text /// </param> protected void TryToWriteElement( NamespacePrefixPair namespacePrefix, ElementNameTable elementName, DateTime? value) { if (value.HasValue) { this.WriteElement(namespacePrefix, elementName, DateUtil.FormatDate(value.Value)); } }
/// <summary> /// Initializes a new instance of the <see cref="RegistryInterfaceWriterBaseV2"/> class. /// </summary> /// <exception cref="System.ArgumentNullException"> /// writer is null /// </exception> /// <param name="writer"> /// The XmlTextWriter object use to actually perform the writing /// </param> /// <param name="namespaces"> /// The namespaces. /// </param> protected RegistryInterfaceWriterBaseV2(XmlWriter writer, SdmxNamespaces namespaces) : base(writer, namespaces) { this._commonPrefix = this.Namespaces.Common.Prefix; this._defaultNs = this.Namespaces.Registry; }
/// <summary> /// Write an attribute with the specified name and value /// </summary> /// <param name="namespacePrefixPair"> /// The XML prefix /// </param> /// <param name="name"> /// Attribute name /// </param> /// <param name="value"> /// Attribute value /// </param> protected void WriteAttributeString( NamespacePrefixPair namespacePrefixPair, AttributeNameTable name, string value) { this.WriteAttributeString(namespacePrefixPair, NameTableCache.GetAttributeName(name), value); }
/// <summary> /// Write an attribute with the specified name and value /// </summary> /// <param name="namespacePrefixPair"> /// The XML prefix /// </param> /// <param name="name"> /// Attribute name /// </param> /// <param name="value"> /// Attribute value /// </param> protected void WriteAttributeString(NamespacePrefixPair namespacePrefixPair, string name, string value) { this._writer.WriteAttributeString(namespacePrefixPair.Prefix, name, namespacePrefixPair.NS, value); }
/// <summary> /// Initializes a new instance of the <see cref="StructureWriterBaseV2"/> class. /// Initializes a new instance of the <see cref="StructureWriterV2"/> class. /// Constructor that initialize the internal fields /// </summary> /// <exception cref="System.ArgumentNullException"> /// writer is null /// </exception> /// <param name="writer"> /// The XmlWriter object use to actually perform the writing /// </param> /// <param name="namespaces"> /// The namespaces /// </param> protected StructureWriterBaseV2(XmlWriter writer, SdmxNamespaces namespaces) : base(writer, _versionTwo, namespaces) { this._defaultNs = this.Namespaces.Structure; this._rootNamespace = this.Namespaces.Message; }
/// <summary> /// Write a Start Element to the given XmlTextWriter using the given prefix and the <see cref="ElementNameTable"/> name /// </summary> /// <param name="ns"> /// The namespace and prefix /// </param> /// <param name="element"> /// The <see cref="ElementNameTable"/> element name /// </param> protected void WriteStartElement(NamespacePrefixPair ns, ElementNameTable element) { this.WriteStartElement(ns, NameTableCache.GetElementName(element)); }
/// <summary> /// Write the element if it's value is not empty or null /// </summary> /// <param name="namespacePrefix"> /// The namespace prefix /// </param> /// <param name="element"> /// The <see cref="ElementNameTable"/> element name /// </param> /// <param name="value"> /// The elements text /// </param> protected void TryToWriteElement(NamespacePrefixPair namespacePrefix, ElementNameTable element, Uri value) { if (value != null) { this.WriteElement(namespacePrefix, element, value.ToString()); } }
/// <summary> /// Write the element /// </summary> /// <param name="namespacePrefix"> /// The namespace prefix /// </param> /// <param name="element"> /// The element name /// </param> /// <param name="value"> /// The elements text /// </param> protected void WriteElement(NamespacePrefixPair namespacePrefix, ElementNameTable element, string value) { this._writer.WriteElementString( namespacePrefix.Prefix, NameTableCache.GetElementName(element), namespacePrefix.NS, value); }
/// <summary> /// Write the specified <paramref name="ns"/> declaration /// </summary> /// <param name="ns"> /// The namespace with prefix /// </param> protected void WriteNamespaceDecl(NamespacePrefixPair ns) { this.WriteAttributeString(XmlConstants.Xmlns, ns.Prefix, ns.NS); }
/// <summary> /// Write the element /// </summary> /// <param name="namespacePrefix"> /// The namespace prefix /// </param> /// <param name="element"> /// The element name /// </param> /// <param name="value"> /// The elements text /// </param> protected void WriteElement(NamespacePrefixPair namespacePrefix, string element, string value) { this._writer.WriteElementString(namespacePrefix.Prefix, element, namespacePrefix.NS, value); }
/// <summary> /// Write the element with it's <c>xs:boolean</c> value /// </summary> /// <param name="namespacePrefix"> /// The namespace prefix /// </param> /// <param name="element"> /// The element name /// </param> /// <param name="value"> /// The elements text /// </param> protected void WriteElement(NamespacePrefixPair namespacePrefix, string element, int value) { this._writer.WriteElementString( namespacePrefix.Prefix, element, namespacePrefix.NS, XmlConvert.ToString(value)); }
/// <summary> /// Write the element with it's <c>xs:boolean</c> value /// </summary> /// <param name="namespacePrefix"> /// The namespace prefix /// </param> /// <param name="element"> /// The element name /// </param> /// <param name="value"> /// The elements text /// </param> protected void WriteElement(NamespacePrefixPair namespacePrefix, ElementNameTable element, int value) { this.WriteElement(namespacePrefix, NameTableCache.GetElementName(element), value); }
/// <summary> /// Write the element if it's value is not empty or null /// </summary> /// <param name="namespacePrefix"> /// The namespace prefix pair /// </param> /// <param name="element"> /// The <see cref="ElementNameTable"/> element name /// </param> /// <param name="value"> /// The elements text /// </param> protected void TryToWriteElement(NamespacePrefixPair namespacePrefix, ElementNameTable element, string value) { this.TryToWriteElement(namespacePrefix, NameTableCache.GetElementName(element), value); }
/// <summary> /// Write a Start Element to the given XmlTextWriter using the given prefix and the <see cref="ElementNameTable"/> name /// </summary> /// <param name="ns"> /// The namespace and prefix /// </param> /// <param name="element"> /// The <see cref="ElementNameTable"/> element name /// </param> protected void WriteStartElement(NamespacePrefixPair ns, string element) { this._writer.WriteStartElement(ns.Prefix, element, ns.NS); }
/// <summary> /// Write the element if it's value is not empty or null /// </summary> /// <param name="namespacePrefix"> /// The namespace prefix pair /// </param> /// <param name="element"> /// The <see cref="ElementNameTable"/> element name /// </param> /// <param name="value"> /// The elements text /// </param> protected void TryToWriteElement(NamespacePrefixPair namespacePrefix, string element, string value) { if (!string.IsNullOrEmpty(value)) { this.WriteElement(namespacePrefix, element, value); } }
/// <summary> /// This is an internal method that is used to write the <paramref name="textObject"/> /// The method create a xml element named by the name parameter. /// It will only write the xml element if the text inside <paramref name="textObject"/> is not null or empty /// </summary> /// <param name="namespacePrefix"> /// The namespace prefix pair /// </param> /// <param name="textObject"> /// The <see cref="KeyValuePair{TKey,TValue}"/> object containing the data to be written, where key is the locale and value the text value /// </param> /// <param name="name"> /// The name of the xml element /// </param> protected void WriteTextType( NamespacePrefixPair namespacePrefix, IDictionary<string, string> textObject, ElementNameTable name) { foreach (KeyValuePair<string, string> valuePair in textObject) { this.WriteTextType(namespacePrefix, valuePair, name); } }
/// <summary> /// Write the element with it's <c>xs:boolean</c> value if it is true /// </summary> /// <param name="prefix"> /// The namespace prefix /// </param> /// <param name="element"> /// The <see cref="ElementNameTable"/> element name /// </param> /// <param name="value"> /// The elements text /// </param> protected void TryToWriteElement(NamespacePrefixPair prefix, ElementNameTable element, bool value) { if (value) { this.WriteElement(prefix, element, true); } }
/// <summary> /// This is an internal method that is used to write the <paramref name="textObject"/> /// The method create a xml element named by the name parameter. /// It will only write the xml element if the text inside <paramref name="textObject"/> is not null or empty /// </summary> /// <param name="namespacePrefix"> /// The namespace Prefix. /// </param> /// <param name="textObject"> /// The <see cref="KeyValuePair{TKey,TValue}"/> object containing the data to be written, where key is the locale and value the text value /// </param> /// <param name="name"> /// The name of the xml element /// </param> protected void WriteTextType( NamespacePrefixPair namespacePrefix, KeyValuePair<string, string> textObject, ElementNameTable name) { this.WriteTextType(namespacePrefix, name, textObject.Value, textObject.Key); }
/// <summary> /// Set the top element namespace prefix /// </summary> /// <param name="namespaceUri"> /// The namespace URI /// </param> internal void SetTopElementsNS(NamespacePrefixPair namespaceUri) { this._rootNamespace = namespaceUri; }
/// <summary> /// This is an internal method that is used to write a <see cref="ITextTypeWrapper" /> /// The method create a XML element named by the name parameter. /// It will only write the XML element if the <see cref="ITextTypeWrapper.Value" /> is not null or empty /// </summary> /// <param name="namespacePrefix">The namespace prefix that should be used</param> /// <param name="textObject">The text object.</param> /// <param name="name">The name.</param> protected void WriteTextType(NamespacePrefixPair namespacePrefix, IList<ITextTypeWrapper> textObject, ElementNameTable name) { if (textObject != null && textObject.Count > 0) { this.WriteTextType(namespacePrefix, textObject[0], name); } }
/// <summary> /// This method is used to write the root xml tag and *Data tag /// with their corresponding attributes /// </summary> /// <param name="element"> /// The first element tag name /// </param> /// <param name="namespaces"> /// The namespaces used by sdmx that are /// appended by this method as attributes of the *Data tag /// </param> protected void WriteMessageTag(string element, SdmxNamespaces namespaces) { if (element == null) { throw new ArgumentNullException("element"); } // <?xml version="1.0" encoding="UTF-8"?> if (!this.Wrapped) { this.SdmxMLWriter.WriteStartDocument(); } // Generated File comment if (!string.IsNullOrEmpty(this._generatedFileComment)) { this.SdmxMLWriter.WriteComment(this._generatedFileComment); } // <CompactData this.WriteStartElement(this.Namespaces.Message, element); // xmlns="http://www.SDMX.org/resources/SDMXML/schemas/v2_0/message" this.WriteNamespaceDecl(this.Namespaces.Message); if (string.IsNullOrEmpty(this._namespacePrefix)) { this._namespacePrefix = string.Format( CultureInfo.InvariantCulture, "{0}{1}", PrefixConstants.DataSetStructureSpecific, this._prefixCount); this._prefixCount++; } switch (this.DataFormatType) { case BaseDataFormatEnumType.Generic: this._dataSetNS = this.Namespaces.Generic; break; case BaseDataFormatEnumType.Compact: case BaseDataFormatEnumType.CrossSectional: this._dataSetNS = this._namespace == null ? this.BuildDSDSpecificUrn(this._namespacePrefix) : new NamespacePrefixPair(this._namespace, this._namespacePrefix); this.Namespaces.DataSetStructureSpecific = this._dataSetNS; break; } this.WriteNamespaceDecl(this._dataSetNS); // xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" this.WriteNamespaceDecl(this.Namespaces.Xsi); // xsi:schemaLocation="http://www.SDMX.org/resources/SDMXML/schemas/v2_0/message SDMXMessage.xsd"> string schemaLocation = this.Namespaces.SchemaLocation ?? string.Empty; string structureSpecific = this.GetSchemaLocation(this.TargetSchema.EnumType); if (!string.IsNullOrWhiteSpace(structureSpecific)) { schemaLocation = string.Format( CultureInfo.InvariantCulture, "{0} {1}", schemaLocation, structureSpecific); } if (!string.IsNullOrWhiteSpace(schemaLocation)) { this.WriteAttributeString(this.Namespaces.Xsi, XmlConstants.SchemaLocation, schemaLocation); } }
/// <summary> /// This is an internal method that is used to write a <see cref="ITextTypeWrapper"/> /// The method create a xml element named by the name parameter. /// It will only write the xml element if the <see cref="ITextTypeWrapper.Value"/> is not null or empty /// </summary> /// <param name="namespacePrefix"> /// The namespace prefix that should be used /// </param> /// <param name="textObject"> /// The <see cref="ITextTypeWrapper"/> object containing the data to be written /// </param> /// <param name="name"> /// The name of the xml element /// </param> protected void WriteTextType( NamespacePrefixPair namespacePrefix, ITextTypeWrapperMutableObject textObject, ElementNameTable name) { string value = textObject.Value; string locale = textObject.Locale; this.WriteTextType(namespacePrefix, name, value, locale); }
/// <summary> /// Starts a dataset with the data conforming to the DSD /// </summary> /// <param name="dataflow">Optional. The dataflow can be provided to give extra information about the dataset.</param> /// <param name="dsd">The <see cref="IDataStructureObject" /> for which the dataset will be created</param> /// <param name="header">The <see cref="IHeader" /> of the dataset</param> /// <param name="annotations">Any additional annotations that are attached to the dataset, can be null if no annotations exist</param> /// <exception cref="System.ArgumentNullException">if the <paramref name="dsd" /> is null</exception> public override void StartDataset(IDataflowObject dataflow, IDataStructureObject dsd, IDatasetHeader header, params IAnnotation[] annotations) { base.StartDataset(dataflow, dsd, header, annotations); this._primaryMeasureConcept = this.GetComponentId(dsd.PrimaryMeasure); this._compactNs = this.TargetSchema.EnumType != SdmxSchemaEnumType.VersionTwoPointOne ? this.Namespaces.DataSetStructureSpecific : NamespacePrefixPair.Empty; this._obsConcept = this.IsTwoPointOne ? this.DimensionAtObservation : ConceptRefUtil.GetConceptId(this.KeyFamily.TimeDimension.ConceptRef); if (this.IsTwoPointOne) { this.WriteAnnotations(ElementNameTable.AnnotationType, annotations); } else { this._datasetAnnotations = annotations; } }
/// <summary> /// Write the list contacts. /// </summary> /// <param name="namespacePrefixPair"> /// The namespace prefix pair. /// </param> /// <param name="element"> /// The element. /// </param> /// <param name="list"> /// The list. /// </param> private void WriteListContacts( NamespacePrefixPair namespacePrefixPair, ElementNameTable element, IEnumerable<string> list) { foreach (string value in list) { if (!string.IsNullOrWhiteSpace(value)) { this.WriteElement(namespacePrefixPair, element, value); } } }