Use SQLXML 3.0 (Web Services, XML Views, Managed Classes) [3]

zhaozj2021-02-17  69

Use SQLXML 3.0 (Web Services, XML Views, Managed Classes)

Mood

2002-5-25

Article Type: Overview

Difficult Level: 5/9

Version: 4.16

Generate mapping files

How to create a mapping file? First it is an XML file, in the past Microsoft recommended using XDR (XML-Data Reduced) to define, English's full name is "CREANG XML Views By Using Annotated XDR Schemas", Annotated I don't know how to translate it more image. After SQLXML 3.0, Microsoft began to support the use of more specified annotated XSD Schemas to complete the definition of the past XDR, and provide a tool CVTSChema.exe to complete the file that converts the original XDR definition into XSD format. But the problem is that we still need to generate an XSD or XDR file. Even in the past use XDR, generating a mapping file is still a relatively boring thing, manually producing a basic Schema file seems to be necessary, but for a person who has never used XDR or XSD, it is painful, this Just like you have to generate an XSLT file for an XML file, no matter how much tool can be automatically generated according to XML, but in fact, we find that manual way is more effective than tools. I didn't understand this truth, I gathered in Microsoft's SQL Server XML View Mapper tool, and the most disappointed was that it still asked me to provide an XDR document before automation (I started to understand the significance of Mapper because it only Automatic mapping, SCHEMA files or you want to produce themselves). Even if it is able to automate some of the function (automatically add SQL: RELATION, I will give up using it, because its new version may be better, will support XSD Schema, not to now Supports XDR Schema. It must be admitted to when you are working a little bigger, such as more than a dozen tables, more than twenty mapping files, each time you define a similar SCHEMA board file from the header definition, becomes painful and lengthy.

(XML View Mapper interface) After I spent a few hours, turning up the DOTNET About the XML API manual, starting to write a buffer to write a tool that automatically generates a Schema file according to the database, it is basically the default mapping, it means it almost no need. Plus Annotate, you may still need to add some other annotate according to specific situations. I hope it can automatically generate the Schema file according to the table in the database, so I can start the next coding and access XML data section in the template catalog of IIS (of course we will see, that is, the fourth The character is said in the feature). In fact, its function "is very powerful", I am constantly adding parameters, making it generate more related files. This gadget writexsd.exe (I will allow me to call it this), you can generate and preview the Schema we need from a table of a database.

Then we run the following command: WritexSD / C: Attribute / T: XSD /O :Emplyeesa.xml /M :Emplyeeso.xml Employees

If we success we will get two files Emplyeesa.xml and Emplyeeso.xml one is a schema file, and the other is a template-mapping file, then we will copy them to our previously set directory, one is / schema one after / temples Execute the following command: http://localhost/northwind/templates/emplyeeso.xml We will see the following results, basically it is generated by our Emplyeesa.xml, of course, some small problems such as Photo field, it should be a picture type, and in EmplyeesA.xml simply type = " 'xs: string" (this version any field I have converted to string type haha) you can clearly see that this field is displayed: FRwvAAIAAAANAA4AFAAhAP9CaXRtYXAgSW1hZ2UAUGFpbnQuUGljdHVyZQABBQAAAgAAAAcAAABQQnJ1c2gAAAA ... For this display, I am sorry :), the next version may be added to the database field type and the XSD data type conversion. Of course, in some shortly, I found that there are other ways to generate Annotated Schemas: vs.net, create new XML Schema, then drag and drop in VS you need on the Table to design view, such as below

To switch to the XML view we see the code that is approximately below, then manually deletes the part of the black bitter with underscore.

Save this file and then copy it to our set / schema directory. No matter how it hand has always existed, but we can choose a way to solve the boring operation in a way that is suitable for our own. Finally, I don't know which way I will like, but I have become an interesting rather than a painful thing about generating Annotated Schemas. (Haha)

The previous use of SQL 2000 and SQLXML in the manual or direct way, and then we will look at some additional features - how to use the program to use SQLXML function. This is also the next character we have to say.

Special Note:

This article original, 9CBS signature start, all text and photo copyright. Do not propagate, reprint, or adaptation without authorization.

If you have any questions or suggestions, please email new2001@msn.com

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

New Post(0)