Example #1
0
        /// <summary>
        /// See <see cref="XmlReader.Read"/>.
        /// </summary>
        public override bool Read()
        {
            bool baseRead = base.Read();

            if (NodeType == XmlNodeType.Element && NamespaceURI == nxsltNamespace && LocalName == characterMapTag)
            {
                //nxslt:character-map
                currMapName = base[nameTag];
                if (string.IsNullOrEmpty(currMapName))
                {
                    throw new System.Xml.Xsl.XsltCompileException("Required 'name' attribute of nxslt:character-map element is missing.");
                }
                currMap = new CharacterMap();
                string referencedMaps = base[useCharacterMapsTag];
                if (!string.IsNullOrEmpty(referencedMaps))
                {
                    currMap.ReferencedCharacterMaps = referencedMaps.Split(' ');
                }
            }
            else if (NodeType == XmlNodeType.EndElement && NamespaceURI == nxsltNamespace && LocalName == characterMapTag)
            {
                if (mapping == null)
                {
                    mapping = new CharacterMapping();
                }
                mapping.AddCharacterMap(currMapName, currMap);
            }
            else if (NodeType == XmlNodeType.Element && NamespaceURI == nxsltNamespace && LocalName == outputCharacterTag)
            {
                //nxslt:output-character
                string character = base[characterTag];
                if (string.IsNullOrEmpty(character))
                {
                    throw new System.Xml.Xsl.XsltCompileException("Required 'character' attribute of nxslt:output-character element is missing.");
                }
                if (character.Length > 1)
                {
                    throw new System.Xml.Xsl.XsltCompileException("'character' attribute value of nxslt:output-character element is too long - must be a single character.");
                }
                string _string = base[stringTag];
                if (string.IsNullOrEmpty(character))
                {
                    throw new System.Xml.Xsl.XsltCompileException("Required 'string' attribute of nxslt:output-character element is missing.");
                }
                currMap.AddMapping(character[0], _string);
            }
            else if (NodeType == XmlNodeType.Element && NamespaceURI == nxsltNamespace && LocalName == outputTag)
            {
                //nxslt:output
                string useMaps = base[useCharacterMapsTag];
                if (string.IsNullOrEmpty(useMaps))
                {
                    return(baseRead);
                }

                if (useCharacterMaps == null)
                {
                    useCharacterMaps = new List <string>();
                }
                useCharacterMaps.AddRange(useMaps.Split(' '));
            }
            return(baseRead);
        }