Prepare new MSDN directory (from MSDN)

zhaozj2021-02-08  229

Zee Note: Although it is not very complicated, it is also an XML application. :)

Bryn Waibel and John Boylan July 10, 2000 MSDN Library is MSDN's information center library, including more than 250,000 files, directory (TOC) is the main access point of such data. But the TOC work in the MSDN library is not satisfactory, so it is necessary to discard and replace - the sooner the better. Including the MSDN Web Design Team, including Bryn Waibel and Mike Barta, is entrusted to create a new TOC. Fortunately, the solution is very direct: the new TOC uses JavaScript to override the XML as the data layer. We will show you this work in this article and include a TOC example as a design template.

We hope that TOC can provide cross-platform access, improved maintainability, and extended character sets required for globalization.

The actual situation

If the above problem is simple, it is also very serious - and it is possible to deteriorate. Fortunately, the answer is clear.

The new TOC must be able to handle large data sets and data for many different sources.

We hope that TOC can provide cross-platform access to improve maintainability (using standard data storage formats) and the extension character set required for globalization.

We also need to link from anywhere of library to any node of TOC.

The old TOC is difficult to maintain is that the data source link of the Java applet is poor. The data source is required to illustrate the association between more than 200 different datasets.

The only way to link these datasets without sending it to the user at the same time is to manually copy the given data set into the hierarchy.

When the world-wide application built for the web is also in the primary phase, the applet does not provide extended character support. These applets cannot adapt to the advancement of browser technology to meet the growing language and the corresponding operating system.

For example, for a Java applet, if you want to view the SHIFT-JIS character set, you can only use the browser in the operating system of the Shift-Jis set by default ANSI character set.

Similarly, the Java applet cannot handle the Unicode character set such as UTF-8.

In addition, the user interacts with the initial TOC slow and clumsy. What's more, you can't access TOC from a Macintosh machine, which greatly limits access to Macintosh users.

Finally, TOC uses a dedicated data structure. A new Java applet dedicated data structure must be generated to reuse the TOC source.

Capture the actual situation

Understand the lack of this model, we can start working on the content we have to have. Start exploring some key design matters:

XML Structure We know that you need an XML data layer. Regardless of the solution, the answer always eventually ends to XML. Data block data must be divided into a small block so that it can be sent to the client in any connection. The Windows 2000 team tried to encounter similar problems when setting the Windows 2000 Help file to online, so their code is obviously just a beginning. Each node in the TOC with a node must be discovered, it only knows the .htm page it points to. This data must be updated and is independent of the change in TOC. Data from the supplier MSDN Library comes from hundreds of suppliers, including a variety of formats: .rtf, .chm, .htm, etc. There is a way in a way that they are mapped together and remain independent. Reuse data needs to be reused. We do not want to re-edit some of the TOC when displaying the same data in different views.

After introducing the production process of the TOC, they will be returned to discuss these problems and explain how they affect the final design.

Generate a directory

Now let's start with a framework, we will push our TOC. All segments - XML, JavaScript, XSL, and .asp files are taken to form a whole. TOC XML structure

The key issue that creating TOC is the size of the structure. Since the entire MSDN TOC is too large, it cannot be sent to the client. The current TOC contains 250,000 nodes; calculated according to 150 bytes per node, with a total of more than 37 MB, and cannot be sent to the user.

Because mainly considering the structure size, we try to make the document type definition (DTD) as simply simply as possible without sacrificing readability. At the same time, we also use the property-centric rather than elements. In this way, we can merge the data and give the XML structure of strict compliance with data types in TOC. Provides the connection of nodes in the TOC in the property-centric approach, which leads to many nodes of the XML represent the same node in TOC in the TOC.

For our model, we start with the latest version of HTML Help 2.0.Hxt files, is committed to creating a work for our work. As indicated by the following code, nimt each node is MTN (MSDN TOC node), and each node contains 0 and more sub-MTN nodes. We add a large number of properties that do not necessarily implement MSDN Library, but it is useful to explain all types of TOC on our site.

Library property

The following is a direct-related property directly related to MSDN Library:

There are three possible values ​​of NodeType properties:

Node This node has a sub-node, and the child node appears in this file. Page This is a terminal node; it has no child nodes. Set this node has a sub-node, but they are located in different files. The prepaartum property references a file that can be found in it. This property value is a path to a specific file. This file contains exact backups in its root directory - unless its NodeType value is "Node", and its subtiter exists. For XML Document Object Model (DOM), the operation performed is: load the pointed file by prepaartum and replaces the current node with the top node of the file. The TOCPATH property contains a given node zero index path in TOC. Each node index is separated from other indexs through dashed lines to easily extract from a string table and inserted into XML DOM. The TOCPATH value of the first node in TOC is 0, and the TOCPATH value of the second sub-node is 0-1, which pushs to form a direct path to any node to the top of TOC. We also add a tag to the beginning of the TOCPATH value to indicate the path-related area. At the top of library, this tag is "lib". We will further discuss this problem when we will say how to maintain independence of each directory vendor. The State property is the property of displaying the drive; if there is no state, the node will process it in its default state. Nodes can have two status:

SEL This is the current node of the node in the tree. If the node points to the directory; will be displayed in bold; if nodetype = "node", the node will appear as an open state. Open This state indicates that the node is located in the path of the current node. Only nodettype = "node" node can have this property. The REF property contains the path to the data referenced by the relevant node. In Library, this path is the URL of the .htm or .asp file. The Title property contains the display name of the current node.

Data block

We have started working on the WINDOWS 2000 group to work to help files. The Windows 2000 group uses XML to maintain its data, and disengage the build file, forming an HTML solution - do most of the build logic before sending the data to the user. In a Windows 2000 solution, the user sees in the file system in the Netscape version and the Internet Explorer version. But this method has obvious defects - if you need to build a variety of solutions, each of them can only meet the needs of different client platforms.

Performance Consideration is one of the main reasons for disengagement, especially before the final release of Windows 2000 final release. Windows 2000 has made a lot of significant improvements in XSL conversion and XML DOM processing. So we are willing to look at the status of data processing. As a result, our TOC stores XML data in a file system, which will then add a conversion on the server according to the user.

Synchronize with a node

Synchronization with a node is the most difficult problem that is designed to design this TOC. The Windows 2000 group uses a continuous number to quote its node, but this is really a problem for us because we don't want to change the entire synchronization architecture at each addition and replacement nodes. At the same time, due to 250,000 nodes in the collection, we don't want to store synchronization information in a place; we need a hash mechanism. An obvious option is to store data in a given file path, which indexes by file names in the folder. We decided to store information in a XML file called an image file.

]>

It can be seen that the image file is very simple and very useful. The image file is a way to create a name / value using XML. Each node consists of a file name as a name and a TOCPATH as a value, put the name into the URL of the id attribute, and put the value into the CDATA property.

Pth.

Only give a file path and file name we can open the corresponding map.xml file under the directory and use the file name to find the path to the node, which requires the file in it.

XmlDomDocument object

NodeFromid. Use it in the Toc.asp file

The FormatFileName (STRFNAME) function exchanges code on the file name, as shown in the following code.

Function FormatFileName (sfilename)

{

IF ("String" == TypeOf (sfilename))

{// Remove all characters outside the non-alphanumeric characters, the junctions, dashed lines, underscores or parentheses (ID attributes)

sfilename = sfilename.replace (/[1w/.-_:]/gi, "");

/ / Can't start with numbers

IF (sfilename.match) sfilename = "f" sfilename;

Return sfilename;}}

Supplier

In order to keep the independence between the directory sets, we use a mark to represent each collection. we are at

Talking in TOCPATH illustrates a role below.

Create a name for each vendor, then add a unique integer to the end of each tag to name the node on the top of the Supplier Tree. For simple implementation, use continuous integers from 0. The image file from the top node of the supplier directory reference TOCPATHS. Then we will have a Submap.xml file that puts each marker from the top of the TOC to its respective position. Store this data file is just another image file - the REF property of the file contains the tagname, and

PTH is the path to the tag. Now we can move the directory clip relative to other fragments, which only needs to update the main mark image file. You can also move the directory inside a catalog block without chaos other node sequences outside of the chaos, and other advantages are to generate data views as you like by reference to the same data different from the top level.

Application example

After watching XML works after the solution, you will discuss how the above segments are set together to generate an application. We will complete this work through outlined examples of application examples. If you want to build a node that records TOC technology, it means an application example including TOC code, so I hope it looks like this:

Figure 1. TOC Example: MSDN TOC Node in "Code Center"

Suppose you would like to use the nodes under the MSDN Code Example as a single element, then you need two XML files indicating this structure: MSDNCE.XML and LTOC.XML.

MSDNCE.XML

TOCPATH = "MSDNCE-0" HAL = "EN-US">

TOCPATH = "LTOC0" HAL = "en-us" prepaartum = "ltoc0.xml" />

msdnce.xml file is very simple; it just controls a node for all MSDN code examples.

This control includes a single collection node pointing to our example LTOC0.xml.

LTOC.XML

Ref = "library.asp"? TOCPATH = "LTOC0-0" />

Ref = "loadtree.asp.txt"? TOCPATH = "LTOC0-1-0" />

REF = "TOC.ASP.TXT"? TOCPATH = "LTOC0-1-1" />

Ref = "default.asp.txt"? TOCPATH = "LTOC0-1-2" />

Ref = "toc.css.txt"? TOCPATH = "LTOC0-2-0" />

Ref = "TOC.JS.TXT"? TOCPATH = "LTOC0-3-0" />

Ref = "locals.inc"? TOCPATH = "LTOC0-4-0" />

Ref = "msdnce.xml"? TOCPATH = "LTOC0-5-0" />

Ref = "ltoc0.xml"? TOCPATH = "LTOC0-5-1" />

Ref = "map.xml"? TOCPATH = "LTOC0-5-2" />

Ref = "submap.xml"? TOCPATH = "LTOC0-5-3" />

REF = "TOCDOWN.XSL"? TOCPATH = "LTOC0-6-0" />

We have mastered the privilege of naming two collections: LTOC is one of the supplier tags mentioned in "Division Supplier"; and MSDNCE is a top-level tag name representing this data view. LTOC0.XML is more meaningful than MSDNCE.XML; it is the representation of this example. Please remember that in our naming system, LTOC0 is

The first node of the LTOC collection.

At this point, we can easily see how repeatable use works. We can point from any other TOC from the site to LTOC0.XML, but all to do just to build a node such as the secondary node in the MSDNCE file. We can also add any of the examples under the MSDN code sample node and keep the examples completely independent.

Map.xml

The map.xml file maps the directory into the path within its subshore. It is particularly interesting that each node is referenced by the LTOC0 sub-tag. This makes any applications that need to use LTOC0 data to point to the same LTOC0.xml file. XML users only need to provide their images to LTOC0, and the map.xml file will be extracted from Lotc0.

]>

Submasp.xml

Submap.xml file is an image that each XML user is reserved; it provides contact between data segments. Since this view only points to a set of data (LTOC0), there is only one node. Note that it is important to define sub-areas within the LTOC0; in the sub-zone of the submap.xml only relatively LTOC0 references. If you want to include the same .css node in other views, you can refer to this node as TOCCSS, and reference it to LTOC0-2 in the Submap.xml file - from this view to the real path MSDNCE-0-0 -2.

]>

Locals.inc

The locals.inc file includes all the information of this view and is referenced by each .asp file in the application. For our application example, the file is as follows:

<% // default.asp Title Var L_HomePageTitle_htmlText = "MSDN TOC CODE EXAMPLE";

// Text direction setting (from right to left is RTL)

Var l_strbidimode_htmltext = "LTR";

// is loading a message text

Var l_loadingmsg_htmltext = "Loading, Click to Cancel ...";

/ Source information

Var rootdir = "msdnce.xml";

Var defaulttopic = "library.asp";

Var submappath = "submap.xml";

Var roottoctoken = "msdnce";%>

ASP

There are two main .asp in TOC responsible for XML processing and preparing to display data for clients: loadTree.asp and Toc.asp.

LoadTree.asp

LoadTree.asp file

PREPARTUM and

TOCPATH as a parameter and outputs resident in designated

The child node in TOCPATH. There is a simple and complex two ways to achieve this. When the required node is on the top of the file

Use a simple method when Prepartum is referenced. At this point, just put the file

The DomDocument object is as simple as the TOCDOWN.XSL, and the result is output to the page. Once the result is output to the page, the user interface can begin to process it.

When LoadTree.asp must

Prepartum Reference Questions Internal Find a node, there is a second case, which is more complicated. When provided to loadtree.asp

TOCPATH attribute with the top of the load document

This will happen when the TOCPATH parameter is inconsistent. When this happens, LoadTree.asp will be passed from the form of query strings.

Clear in the TOCPATH parameter

TOCPATH parameter (at the top node of the XML file). The loadtree.asp file is then used as the following segments as the path to find. When the fragment is running, it will find the node you want to find. Then copy this node (style sheet needs to be run from the root of the document), convert the copy, and deliver the result to the page.

Toc.asp

Toc.asp file

REF and

TOCPATH is used as a parameter, loaded into top TOC, and outputs all data from top-level downwards to

The node referenced by REF. If it can find

The node path referenced by REF will traverse the entire tree structure, delete unwanted subtals until the node is reached. If not found, it outputs it to top.

XSL

The XSL is used to display XML in the browser by converting XSL to XHTML. The server can select different .xsl files for each client configuration. The XSL file is very similar to some extent because they have a recursive template mechanism that converts XML to HTML to the user. This mechanism is similar to the following form:

>

JavaScript and CSS

JavaScript and laminated style sheets (CSS) of each browser may also be different. The versions of the examples can only run TOC in Internet Explorer 4.0 and later versions. The HTML generated by the .xsl file is the .asp file to complete most of the information transfer, .asp files are responsible for navigating in other browsers and putting TOC into one.

Taken here

This is the MSDN Library directory. It is the starting point you build your own TOC, especially if you want to connect to different files and want to easily access these files. We design TOC's purpose is to provide various models in either case you want to handle hierarchical data in XML - from the directory to the organization chart and schematic diagram.

Andrew Clinick is the program manager in the Microsoft Script Technology group, the opportunity, as long as the script is involved, he may have a big show. Most of his spare time flowers watching the wonderful football game for US TV broadcasts, and explains with his US colleagues.

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

New Post(0)