2 // System.Xml.XPath.XPathDocument
5 // Tim Coleman (tim@timcoleman.com)
6 // Atsushi Enomoto (ginga@kit.hi-ho.ne.jp)
8 // (C) Copyright 2002 Tim Coleman
9 // (C) 2003 Atsushi Enomoto
13 // Permission is hereby granted, free of charge, to any person obtaining
14 // a copy of this software and associated documentation files (the
15 // "Software"), to deal in the Software without restriction, including
16 // without limitation the rights to use, copy, modify, merge, publish,
17 // distribute, sublicense, and/or sell copies of the Software, and to
18 // permit persons to whom the Software is furnished to do so, subject to
19 // the following conditions:
21 // The above copyright notice and this permission notice shall be
22 // included in all copies or substantial portions of the Software.
24 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
28 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
29 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
30 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
33 using System.Collections;
34 using System.ComponentModel;
38 using System.Xml.Schema;
39 using System.Xml.Serialization;
42 //using InternalBuilder = Mono.Xml.XPath.DTMXPathDocumentBuilder;
43 //using InternalDocument = Mono.Xml.XPath.DTMXPathDocument;
44 using InternalBuilder = Mono.Xml.XPath.DTMXPathDocumentBuilder2;
45 using InternalDocument = Mono.Xml.XPath.DTMXPathDocument2;
47 namespace System.Xml.XPath
49 public class XPathDocument : IXPathNavigable
51 IXPathNavigable document;
53 public XPathDocument (Stream stream)
55 XmlValidatingReader vr = new XmlValidatingReader (new XmlTextReader (stream));
56 vr.ValidationType = ValidationType.None;
57 Initialize (vr, XmlSpace.None);
60 public XPathDocument (string uri)
61 : this (uri, XmlSpace.None)
65 public XPathDocument (TextReader textReader)
67 XmlValidatingReader vr = new XmlValidatingReader (new XmlTextReader (textReader));
68 vr.ValidationType = ValidationType.None;
69 Initialize (vr, XmlSpace.None);
72 public XPathDocument (XmlReader reader)
73 : this (reader, XmlSpace.None)
77 public XPathDocument (string uri, XmlSpace space)
79 XmlValidatingReader vr = null;
81 vr = new XmlValidatingReader (new XmlTextReader (uri));
82 vr.ValidationType = ValidationType.None;
83 Initialize (vr, space);
90 public XPathDocument (XmlReader reader, XmlSpace space)
92 Initialize (reader, space);
95 private void Initialize (XmlReader reader, XmlSpace space)
97 document = new InternalBuilder (reader, space).CreateDocument ();
100 public XPathNavigator CreateNavigator ()
102 return document.CreateNavigator ();