コード例 #1
0
ファイル: Validation.cs プロジェクト: jugglingcats/XEditNet
        public void Attach(XmlDocument doc, Uri baseUri)
        {
            Detach();
            this.document=doc;
            if ( doc.DocumentType == null )
                return;

            DTDParser dtp=new DTDParser();

            bool hasInternalSubset=doc.DocumentType.InternalSubset != null;
            bool internalSubsetOnly=doc.DocumentType.SystemId == null;

            if ( baseUri == null && !doc.BaseURI.Equals("") )
                baseUri=new Uri(doc.BaseURI);

            // TODO: H: shouldn't this use the doc's resolver?
            CustomXmlResolver cxr=new CustomXmlResolver(baseUri);
            dtp.XmlResolver=cxr;

            if ( hasInternalSubset )
            {
                InputSource ii=new InputSource(doc.DocumentType.InternalSubset);
                documentType=dtp.parseInternalSubset(ii, internalSubsetOnly);
            }

            if ( !internalSubsetOnly )
            {
                Uri doctypeUri=cxr.ResolveUri(baseUri, doc.DocumentType.SystemId);
                InputSource i=new InputSource(doctypeUri);
                if ( hasInternalSubset )
                    documentType=dtp.parseExternalSubset(i);
                else
                    documentType=dtp.parseExternalSubset(i, true);
            }

            validationEngine=new ValidationEngine(documentType, this);
            quickFixer=new QuickFixer(documentType);

            GetAllIdAndIdRefs();
            ValidateAllIdAndIdRefs();

            document.NodeChanging+=new XmlNodeChangedEventHandler(NodeChanging);
            document.NodeChanged+=new XmlNodeChangedEventHandler(NodeChanged);
            document.NodeInserted+=new XmlNodeChangedEventHandler(NodeInserted);
            document.NodeRemoved+=new XmlNodeChangedEventHandler(NodeRemoved);
        }
コード例 #2
0
ファイル: DTDParser.cs プロジェクト: jugglingcats/XEditNet
        void openInputSource(InputSource src)
        {
            //      TextReader      srcReader;
            //      Stream srcStream;

            if ( src.Uri != null )
            {
                createURLReader(src.Uri);
                return;
            }
            createTextReader(src.Text);
        }
コード例 #3
0
ファイル: DTDParser.cs プロジェクト: jugglingcats/XEditNet
 /**
  * Parse the DocumentType in an XML document containing an internal subset,
  * reference to an external subset, or both.
  *
  * @param src A SAX InputSource for the XML document.
  * @param namespaceURIs A Hashtable of keyed by prefixes used in the DocumentType,
  *    mapping these to namespace URIs. May be null.
  * @return The DocumentType object.
  * @exception XMLMiddlewareException Thrown if a DocumentType error is found.
  * @exception EOFException Thrown if EOF is reached prematurely.
  * @exception MalformedURLException Thrown if a system ID is malformed.
  * @exception IOException Thrown if an I/O error occurs.
  */
 protected DocumentType parseXMLDocument(InputSource src/*, Hashtable namespaceURIs*/)
 {
     initGlobals();
     //      this.namespaceURIs = namespaceURIs;
     openInputSource(src);
     parseDocument();
     postProcessDTD();
     return dtd;
 }
コード例 #4
0
ファイル: DTDParser.cs プロジェクト: jugglingcats/XEditNet
        public DocumentType parseInternalSubset(InputSource src, /* Hashtable namespaceURIs, */bool finalise)
        {
            initGlobals();
            //			this.namespaceURIs = namespaceURIs;
            openInputSource(src);
            parseInternalSubset(true);
            if ( finalise )
                postProcessDTD();

            return dtd;
        }
コード例 #5
0
ファイル: DTDParser.cs プロジェクト: jugglingcats/XEditNet
 public DocumentType parseInternalSubset(InputSource src/*, Hashtable namespaceURIs*/)
 {
     return parseInternalSubset(src, /*namespaceURIs, */true);
 }
コード例 #6
0
ファイル: DTDParser.cs プロジェクト: jugglingcats/XEditNet
 public DocumentType parseExternalSubset(InputSource src, bool init)
 {
     if ( init )
         initGlobals();
     //      this.namespaceURIs = namespaceURIs;
     openInputSource(src);
     parseExternalSubset(true);
     postProcessDTD();
     return dtd;
 }
コード例 #7
0
ファイル: DTDParser.cs プロジェクト: jugglingcats/XEditNet
 /**
  * Parse the DocumentType in an external subset.
  *
  * @param src A SAX InputSource for DocumentType (external subset).
  * @param namespaceURIs A Hashtable of keyed by prefixes used in the DocumentType,
  *    mapping these to namespace URIs. May be null.
  * @return The DocumentType object.
  * @exception XMLMiddlewareException Thrown if a DocumentType error is found.
  * @exception EOFException Thrown if EOF is reached prematurely.
  * @exception MalformedURLException Thrown if a system ID is malformed.
  * @exception IOException Thrown if an I/O error occurs.
  */
 public DocumentType parseExternalSubset(InputSource src)
 {
     return parseExternalSubset(src, false);
 }
コード例 #8
0
ファイル: DTDParser.cs プロジェクト: jugglingcats/XEditNet
 // ********************************************************************
 // Methods
 // ********************************************************************
 public DocumentType Parse(string systemId)
 {
     InputSource s=new InputSource(new Uri(systemId));
     return parseXMLDocument(s/*, null*/);
 }