예제 #1
0
        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
        void openInputSource(InputSource src)
        {
            //      TextReader      srcReader;
            //      Stream srcStream;

            if ( src.Uri != null )
            {
                createURLReader(src.Uri);
                return;
            }
            createTextReader(src.Text);
        }
예제 #3
0
 /**
  * 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
        public DocumentType parseInternalSubset(InputSource src, /* Hashtable namespaceURIs, */bool finalise)
        {
            initGlobals();
            //			this.namespaceURIs = namespaceURIs;
            openInputSource(src);
            parseInternalSubset(true);
            if ( finalise )
                postProcessDTD();

            return dtd;
        }
예제 #5
0
 public DocumentType parseInternalSubset(InputSource src/*, Hashtable namespaceURIs*/)
 {
     return parseInternalSubset(src, /*namespaceURIs, */true);
 }
예제 #6
0
 public DocumentType parseExternalSubset(InputSource src, bool init)
 {
     if ( init )
         initGlobals();
     //      this.namespaceURIs = namespaceURIs;
     openInputSource(src);
     parseExternalSubset(true);
     postProcessDTD();
     return dtd;
 }
예제 #7
0
 /**
  * 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
 // ********************************************************************
 // Methods
 // ********************************************************************
 public DocumentType Parse(string systemId)
 {
     InputSource s=new InputSource(new Uri(systemId));
     return parseXMLDocument(s/*, null*/);
 }