What is reverse link?
Abstract: Benjamin guralnik, a special author, introduced the concept of reverse link. A reverse link is an instruction in the new document. This instruction can fill the old document with a link pointing to the new document in one step without updating each old document separately.
RequirementsDownload this ProgramMicrosoft Internet Explorer 5.0 or later with msxml3.0 installed is required.
Editor's note: this month's serialization of extreme XML was written by specially invited columnist Benjamin guralnik. Benjamin lives in Jerusalem, Israel and is an independent developer specializing in XML/XSLT development. He has been regularly introducing Microsoft XML products onlineCommunityWrite. Benjamin has been developing XML-oriented information systems since 1999, when he started developing award-winning SAS interactive handbook. This is a novel help assistant that organizes the SAS system's local help into a simple and effective interface. Benjamin enjoys reading, playing tennis, and studying classical piano music in his spare time.
Cause
Everyone knows what direct links are. Whether it's the blue-underlined text you clicked while browsing the Web, or the comment "See page 2, 276th" that you saw in the book in the past, these links can provide you with navigation functions from the vast amount of data when you focus on a topic and find information related to the topic. Although direct links help a lot, they remain unchanged, which is a tough problem. I happen to have a rare George Orwell 1945 version of "Animal Farm", which naturally cannot reference the content in "1984", because "1984" was written four years later. Of course, any new version of Animal Farm you bought today has a concise preface listing all the books of Orwell, but I have always hoped to find a method in private, I can update my dilapidated book that is almost dismounted.
The only way to update printed materials is re-printing, which is obvious, but the strange thing is that online content updates must also be processed. The only difference is that for the Web, there is no need to waste additional paper. Almost every page needs to be opened, edited, saved, and re-published on the Web. Only in this way can new content be reflected. It is because it is inconvenient to add new links in many old documents that I think of the concept of "reverse link. A reverse link refers to an instruction in the new document (target document) to indicate which old documents (Source Document) will reference the content in the new document.
Reverse link concept
Another way to learn about reverse links is to compare them with the recipient's paid phone number. Unlike regular phone calls (the caller is the payer), the recipient's paid phone calls are separated from the payer and paid by the caller. Similarly, regular links are declared and displayed inside the source document, while reverse links are declared inside the target document. In other words, regular links indicate "point to document B" in document A, while reverse links require "point to me" in document B ". Figure 1 below intuitively illustrates the entire concept.
Figure 1: direct link and reverse link
As a shortcut, the reverse link declaration can contain multipleHrefTo list all target documents at the same time.
Figure 2: Extension Syntax of reverse link
For exampleCodeThe example demonstrates the usage of condition templates in XSLT. You can use a single line to access the four "Language Reference" documents.
<Link: From href1 = ".. /langref/xsl-if.xml "href2 = ".. /langref/xsl-choose.xml "href3 = ".. /langref/xsl-when.xml "href4 = ".. /langref/xsl-otherwise.xml "> condition template </link: From>
But how does one know that other document requests display all reverse reference links on the page? One way is to scan all other documents each time you open a page to search for related reverse link declarations. However, when there are a large number of documents, this method exposes extremely low efficiency shortcomings. Therefore, I think of another method, that is, to scan all documents only once, and then compile all declarations and arrange them in an intermediate "link group", as shown in 3.
Figure 3: Link Group example
Let's see how to create a link group. First, the compiler scans all the XML files in the basefolder and its subfolders at startup, and then saves the results to the corresponding tree (which mirrors the scanned directory structure). These trees enable each document to immediately locate its entries, and developers can move their project folders to other folders, drives, or networks, or even publish them on the Internet. The tree has a relative root (basefolder) that only contains relative links. As long as the internal structure of the project folder remains unchanged, all links remain unchanged.
In the entries of each file in the link group, the compiler copies all reverse links found in the corresponding document. When copying all documents, oneAlgorithmTo convert the reverse link "request" to the actual direct link andLink: reqby(RequestedElements are stored in the document that actually shows the link, rather than in the entries in the Request Document.
Finally, if we want to know which documents will be referenced for a specific document, we only need to view the content under this document entry in the Link Group, because all requests from other documents are concentrated here.
Figure 4: Example document of reverse link display
Let's look back at the payment phone examples of the other party. Here, the link group serves as an intermediary phone carrier. The telephone operator notifies the paying user of the request to pay for the call charge. Similarly, the link group displays all links on a page for other document requests to this page. Figure 5 shows the reverse link solution.
Figure 5 reverse link Architecture
Remember that you must compile the link group each time you change the information system. Otherwise, the old link group cannot be synchronized with the updated or newly added content and its sent link requests.
Applicable scope of reverse links
Even though I want myArticleCan be found at msn.com or Yahoo! It is easier to add the following code on my page:
<Link: From href1 = "www.msn.com" href2 = "www.yahoo.com" href3 = "www.w3.org"> Please read my new article </Link: From>
Although reverse links do greatly extend the direct link function, they also have their own limitations. That is to say, they are not valid for remote resources, because you must compile a link group for the entire Internet and use "http: //" as the base folder, which is purely whimsical. However, what I want to say is that although it is possible to set up an interface for exchanging reverse link groups between two "friendly sites" (simulating B2B information exchange channels, but I will introduce this type of reverse link later.
In your information system, reverse link is an ideal choice. It not only allows old documents to contain new related content, the changing part of the information system can also be linked to a fixed system. In almost allProgramming LanguageThere is always a conflict between the "language reference" and "User Guide" in the Help file. We will take this as an example to further illustrate the problem. For some reason, most "User Guide" articles contain precise redirection on the relevant "Language Reference" page, but "Language Reference" does not mention the articles in "User Guide. Why? The reason is simple, because "Language Reference" is the core of the language, and the core will not change with the version upgrade, even if it is an important version upgrade. Maybe I am a bit conservative, but even in today's. Net Era, I still feel that my Microsoft manual for the 1981 version and basic is very useful. The "User Guide" is the most changing and unpredictable part of the Manual. The "User Guide" contains important introductions and the latest examples about the usage of elements in different languages, and it is generally well-developed by the "language reference, so who has time to change or update the "language reference?
This result is unfortunate, but it is always unavoidable. The conservative "Language Reference" section is never updated with the new content and modern technology (just like my 1945 version of "Animal Farm"), even if it contains error messages. Now, this problem can be solved through the reverse link solution. You can use reverse link requests to display the "User Guide" article, "encoding personnel field" demonstration, and other types of dynamic content on the relevant "Language Reference" page.
Compiler
The following briefly introduces the main functions of the compiler. If you want to extend the current implementation or want to learn from some new Code, these functions will be used.
Compiler Functions
| Init () |
Main function. |
| Getfiles (whatfolder, root, PATH) |
Maps the directory where the compiler is started and the folders and files in its subdirectories. For each fileGetreverselinks. |
| Getreverselinks (xmldoc) |
Retrieve the reverse link set from the specified document and pass itBuildreqlinks. |
| Buildreqlinks (Root) |
Create a direct link for each reverse link declaration and store it in the Link Group under the document that actually displays the link. |
Compiler style sheet
| Link Group |
Filter and format the link group from the reverse link declaration. |
| Tree |
The link group is displayed immediately after the link group is compiled, and the closed reverse link is reported. |
Path/url-related functions (used by compilers and supported style sheets)
| Getpath (PATH) |
Provide the file path and return the path of the folder where the file is stored. |
| Getrelurl (SRC, DEST) |
Obtain two absolute paths and calculate the relative links between the source and target documents. |
| Normalizepath (PATH) |
Delete the path string (for example,./AndPath /../. |
Supported Style Sheets
| Reverse-linking-library.xslt |
Access the link group to obtain the request links of the displayed documents and display them. To enable reverse link in your document, add the following three lines of code in the style sheet: Xmlns: link = "urn: reverse-Linking-library"
(XSL: stylesheetThe namespace declaration within the element .) <XSL: Import href = "reverse-linking-library.xslt"/>
(Import the database to use its templates and functions .) <XSL: Call-Template Name = "link: seealso"/>
(Display the request link. In general, you should call this template at the top of the page to fill in the traditional "see" section. However, it may also appear at the bottom of the page that you think is relevant or elsewhere. |
Thanks
Thanks to Chris Lovett, it was through a series of detailed discussions with him that I realized that what I implemented in this demonstration was not xlink, but only a small part of it. Compared with the xlink introduction (in English) written by Steven J. derose (one of the xlink creators), the reverse link solves at least three of the six problems that xlink can solve:
- Bidirectional link
- Annotate the link of a read-only document
- Link Database
I found that the terms "arc", "positioner", and "Cross" in xlink are hard to understand, so I decided not to discuss these terms and the close relationship between the project and xlink for the moment.
In addition, we would like to thank dare Obasanjo for reviewing this article and providing valuable suggestions. Finally, I would like to thank God.