コード例 #1
0
 /// <summary>
 /// See <see cref="XmlReader.Read"/>.
 /// </summary>        
 public override bool Read()
 {
     bool baseRead = base.Read();            
     if (base.NodeType == XmlNodeType.Element && base.NamespaceURI == nxsltNamespace &&
         base.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 (base.NodeType == XmlNodeType.EndElement && base.NamespaceURI == nxsltNamespace &&
         base.LocalName == characterMapTag)
     {
         if (this.mapping == null)
         {
             this.mapping = new CharacterMapping();
         }
         this.mapping.AddCharacterMap(currMapName, currMap);
     }
     else if (base.NodeType == XmlNodeType.Element && base.NamespaceURI == nxsltNamespace
       && base.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 (base.NodeType == XmlNodeType.Element && base.NamespaceURI == nxsltNamespace &&
        base.LocalName == outputTag)
     {
         //nxslt:output
         string useMaps = base[useCharacterMapsTag];
         if (!string.IsNullOrEmpty(useMaps))
         {
             if (this.useCharacterMaps == null)
             {
                 this.useCharacterMaps = new List<string>();
             }
             this.useCharacterMaps.AddRange(useMaps.Split(' '));
         }
     }
     return baseRead;
 }
コード例 #2
0
        /// <summary>
        /// See <see cref="XmlReader.Read"/>.
        /// </summary>
        public override bool Read()
        {
            bool baseRead = base.Read();

            if (base.NodeType == XmlNodeType.Element && base.NamespaceURI == nxsltNamespace &&
                base.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 (base.NodeType == XmlNodeType.EndElement && base.NamespaceURI == nxsltNamespace &&
                     base.LocalName == characterMapTag)
            {
                if (this.mapping == null)
                {
                    this.mapping = new CharacterMapping();
                }
                this.mapping.AddCharacterMap(currMapName, currMap);
            }
            else if (base.NodeType == XmlNodeType.Element && base.NamespaceURI == nxsltNamespace &&
                     base.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 (base.NodeType == XmlNodeType.Element && base.NamespaceURI == nxsltNamespace &&
                     base.LocalName == outputTag)
            {
                //nxslt:output
                string useMaps = base[useCharacterMapsTag];
                if (!string.IsNullOrEmpty(useMaps))
                {
                    if (this.useCharacterMaps == null)
                    {
                        this.useCharacterMaps = new List <string>();
                    }
                    this.useCharacterMaps.AddRange(useMaps.Split(' '));
                }
            }
            return(baseRead);
        }