コード例 #1
0
ファイル: xpathdocument.cs プロジェクト: ArildF/masters
	    private void ReadAttributes( XPathElement parent, XmlReader reader ) {
            XPathNamespace last = null;
		    while(reader.MoveToNextAttribute()) {
		        documentIndex++;
                if ((object)reader.NamespaceURI == (object)xmlnsUri) {
                    XPathNamespace tmp = new XPathNamespace(reader.Prefix == string.Empty ? string.Empty : reader.LocalName, reader.Value, documentIndex);
                    tmp.next = last;
                    last = tmp;
                }
                else {
			        parent.AppendAttribute(new XPathAttribute(reader.Prefix, reader.LocalName, reader.NamespaceURI, reader.Value, documentIndex));
			        if (htElementIdMap != null) {
    			        Object attrname = htElementIdMap[new XmlQualifiedName(parent.Name, parent.Prefix)] ;
                        if (attrname != null && new XmlQualifiedName(reader.Name, reader.Prefix).Equals(attrname)) {
                            if (htElementIDAttrDecl[reader.Value] == null) {
                                htElementIDAttrDecl.Add(reader.Value, parent);
                            }
                        }
                    }
                }
		    }
            if (last != null) {
                parent.AppendNamespaces(last);
            }
	    }
コード例 #2
0
ファイル: xpathdocument.cs プロジェクト: ArildF/masters
	    private void ReadChildNodes( XPathContainer parent, string parentBaseUri, XmlReader reader, PositionInfo positionInfo ) {
		    do {
		        documentIndex++;
			    switch( reader.NodeType ) {
				case XmlNodeType.Element: {
                    string baseUri = reader.BaseURI;
                    XPathElement e = null;
                    if( reader.IsEmptyElement ) {
                        e = new XPathEmptyElement( reader.Prefix, reader.LocalName, reader.NamespaceURI, positionInfo.LineNumber, positionInfo.LinePosition, parent.topNamespace, documentIndex );
    					ReadAttributes( e, reader );
                    }
                    else {
                        e = new XPathElement( reader.Prefix, reader.LocalName, reader.NamespaceURI, positionInfo.LineNumber, positionInfo.LinePosition, parent.topNamespace, documentIndex );
    					ReadAttributes( e, reader );
    					reader.Read();
	    				ReadChildNodes( e, baseUri, reader, positionInfo );
                    }
                    if (parentBaseUri != baseUri) {
                        // We can't user Ref.Equial Because Reader fails to fully atomize base Uri.
                        if (elementBaseUriMap == null) {
                            elementBaseUriMap = new Hashtable();
                        }
                        elementBaseUriMap[e] = baseUri;
                    }
                    parent.AppendChild( e );
                    break;
				}	

				case XmlNodeType.Comment:
                    parent.AppendChild( new XPathComment( reader.Value, documentIndex ) );
                    break;

				case XmlNodeType.ProcessingInstruction:
                    parent.AppendChild( new XPathProcessingInstruction( reader.LocalName, reader.Value, documentIndex ) );
                    break;

				case XmlNodeType.SignificantWhitespace:
                    if( reader.XmlSpace == XmlSpace.Preserve ) {
                        parent.AppendSignificantWhitespace( reader.Value, positionInfo.LineNumber, positionInfo.LinePosition, documentIndex );
                    }
                    else {
                        // SWS without xml:space='preserve' is not really significant for XPath.
                        // so we treat it as just WS
                        goto case XmlNodeType.Whitespace;
                    }
                    break;

				case XmlNodeType.Whitespace:
                    if( space == XmlSpace.Preserve ) {
                        parent.AppendWhitespace( reader.Value, positionInfo.LineNumber, positionInfo.LinePosition, documentIndex );
                    }
                    break;

				case XmlNodeType.CDATA:
				case XmlNodeType.Text:
                    parent.AppendText( reader.Value, positionInfo.LineNumber, positionInfo.LinePosition, documentIndex );
                    break;

                case XmlNodeType.EntityReference:
                    reader.ResolveEntity();
                    reader.Read();
                    ReadChildNodes( parent, parentBaseUri, reader, positionInfo);
                    break;

                case XmlNodeType.EndEntity:
				case XmlNodeType.EndElement:
                case XmlNodeType.None:
					return;

                case XmlNodeType.DocumentType:
                    XmlValidatingReader vr = reader as XmlValidatingReader;
                    if ( vr != null ) {
                        SchemaInfo info = vr.GetSchemaInfo();
                        if ( info != null ) {
                            GetIDInfo( info);
                        }
                    }
                    break;
                case XmlNodeType.XmlDeclaration:
                default:
                    break;
			    }
		    }while( reader.Read() );
	    }