internal static XmlReaderSettings CreateDefaultXmlReaderSettings()
        {
            XmlReaderSettings xmlReaderSettings = new XmlReaderSettings
            {
#if FEATURE_XML_PROHIBIT_DTD
                ProhibitDtd = true,                     // set true explicitly for security fix
#else
                DtdProcessing = DtdProcessing.Prohibit, // set to prohibit explicitly for security fix
#endif

                // init XmlReaderSettings
                NameTable = new NameTable()
            };

            // O15:#3024890, Set IgnoreWhitespace to false for the SDK to handle the whitespace node type. We have to do this because
            // PPT does not use the preserve attribute (xml:space="preserve") for non-ignorable whitespaces. (See the bug for details.)
            xmlReaderSettings.IgnoreWhitespace = false;

            // load predifined namespace to nametable
            for (int i = 1; i < NamespaceIdMap.Count; i++)
            {
                xmlReaderSettings.NameTable.Add(NamespaceIdMap.GetNamespaceUri((byte)i));
            }
            xmlReaderSettings.NameTable.Add(xmlnsUri);

            return(xmlReaderSettings);
        }
Пример #2
0
        internal static XmlReaderSettings CreateDefaultXmlReaderSettings()
        {
            var nameTable = new NameTable();

            // load predifined namespace to nametable
            for (int i = 1; i < NamespaceIdMap.Count; i++)
            {
                nameTable.Add(NamespaceIdMap.GetNamespaceUri((byte)i));
            }

            nameTable.Add(xmlnsUri);

            return(new XmlReaderSettings
            {
#if FEATURE_XML_PROHIBIT_DTD
                ProhibitDtd = true,
#else
                DtdProcessing = DtdProcessing.Prohibit,
#endif
                NameTable = new NameTable(),

                // Set IgnoreWhitespace to false for the SDK to handle the whitespace node type. We have to do this because
                // PPT does not use the preserve attribute (xml:space="preserve") for non-ignorable whitespaces.
                IgnoreWhitespace = false
            });
        }
        internal static XmlQualifiedName GetFixedAttributeQname(this OpenXmlElement element, int attriuteIndex)
        {
            var localName          = element.AttributeTagNames[attriuteIndex];
            var attributeNamespace = NamespaceIdMap.GetNamespaceUri(element.AttributeNamespaceIds[attriuteIndex]);

            return(new XmlQualifiedName(localName, attributeNamespace));
        }
Пример #4
0
        /// <summary>
        /// Initializes a new instance of the SchemaAttrAttribute.
        /// </summary>
        /// <param name="nsId">Specifies the Namespace Id of the schema attribute.</param>
        /// <param name="tag">Specifies the Tag name of the schema attribute.</param>
        public SchemaAttrAttribute(byte nsId, string tag)
        {
            if (string.IsNullOrEmpty(tag))
            {
                throw new ArgumentNullException(nameof(tag));
            }

            NamespaceUri = NamespaceIdMap.GetNamespaceUri(nsId);
            Tag          = tag;
        }
Пример #5
0
        internal bool IsIgnorableNs(byte namespaceId)
        {
            if (_currentIgnorable.Count == 0)
            {
                return(false);
            }

            if (_currentIgnorable.Contains(NamespaceIdMap.GetNamespaceUri(namespaceId)))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #6
0
        private void Init()
        {
            // load predifined namespace to nametable
            for (int i = 1; i < NamespaceIdMap.Count; i++)
            {
                this._xmlNameTable.Add(NamespaceIdMap.GetNamespaceUri((byte)i));
            }

            this._xmlNameTable.Add(xmlnsUri);

            // init XmlReaderSettings
            this.XmlReaderSettings           = new XmlReaderSettings();
            this.XmlReaderSettings.NameTable = this.XmlNameTable;

            // O15:#3024890, Set IgnoreWhitespace to false for the SDK to handle the whitespace node type. We have to do this because
            // PPT does not use the preserve attribute (xml:space="preserve") for non-ignorable whitespaces. (See the bug for details.)
            this.XmlReaderSettings.IgnoreWhitespace = false;
        }