Пример #1
0
        /// <summary>
        /// Convert attributes that were stored in custom XLIFF elements
        /// </summary>
        private static void ConvertAttributeFromXliff(AttConversionMap attMap, XElement source, XElement target, XElement optionalTarget = null)
        {
            var attElem = source.Element(XliffUtils.SilNamespace + attMap.SilEltName);

            if (attElem != null)
            {
                target.SetAttributeValue(attMap.AttName, attElem.Value);
                optionalTarget?.SetAttributeValue(attMap.AttName, attElem.Value);
            }
        }
Пример #2
0
        /// <summary>
        /// Store attributes in custom XLIFF elements
        /// </summary>
        private static void ConvertAttributeAsElement(AttConversionMap attMap, XElement sourceElement, XElement targetElement)
        {
            var attValue = sourceElement.Attribute(attMap.AttName)?.Value;

            if (attValue != null)
            {
                var attElemString = $"<sil:{attMap.SilEltName}>{SecurityElement.Escape(attValue)}</sil:{attMap.SilEltName}>";
                var attElement    = XElement.Load(new XmlTextReader(attElemString,
                                                                    XmlNodeType.Element,
                                                                    new XmlParserContext(null, XliffUtils.NameSpaceManager, null, XmlSpace.None)));
                targetElement.Add(attElement);
            }
        }