XML plug-in structure in Framework

xiaoxiao2021-03-06  78

The XML in the .NET Framework has a plug-in structure. In the stream-based structure, the plug-in means that it is easy to replace the components based on these abstractions in the .NET Framework. The plug-in structure also means that the data can be transmitted in the form of flow between components and new components inserted into this stream can change the processing. For example, the stream from XML Web Services can be analyzed by XMLTextReader. You can create XMLDocument using XMLTextReader, and then you can create XMLNodeReader using XMLDocument.

Another example is to load the DOM (XMLDocument class) from XMLReader and save the output using XMLWRITER. By expanding existing classes to create their own implementations, you can affect the behavior of the XMLDocument class. For example, if a XMLReader implementation called MYXMLFileReader is created, and it can disclose the file system as XML, you can load XMLDocument from this reader. Or you can inherit from XMLTextReader, create a new custom reader to convert to an element-centered document with an element-centered document, which can be used to load XMLDocument. This provides a plug-in structure based on a new class of existing classes.

Another example of plugging together with a component is using different data stores (such as XpathDocument and XMLDocument) during the conversion process. These data storage areas can be converted with XSLTransform class, and output can then flow into another storage area or returned from XML Web Services in a stream. The following figure illustrates this.

Streaming data using the XSLTransform class

By using the IXPathnavigable interface, any storage area for XPathnavigator can be inserted into the XSLTransform class to allow XSLT conversion to the storage area. XMLDocument, XpathDocument and XMLDATADOCUMENT classes have this capability. The flow output from XSLTransform can then be sent to XMLReader or XMLWRITER in the plug-in structure style.

转载请注明原文地址:https://www.9cbs.com/read-108716.html

New Post(0)