Home  >  Article  >  Backend Development  >  Teach you a detailed explanation of how to quickly convert XML files through XSL

Teach you a detailed explanation of how to quickly convert XML files through XSL

黄舟
黄舟Original
2017-03-06 16:23:241996browse

Recently, I fell in love with XML programming, but I suffered from the fact that it was not beautiful enough, so I looked for many books to get it right.

It is good to use xml, but it is still not suitable as a language for displaying data. (It takes more checking than HTML!)
The XML file does not look so beautiful, but you can still find a remedy.

XML can only focus on the description of data and file formats, while the display work is left to the typesetting style sheet.
Typesetting style sheets are divided into: CSS and XSL. Among them XSL is very suitable for XML. (CSS will not be discussed here!)
Start converting now!

XSL consists of two parts: XSLT and XSL Formatting Object

XSLT (XSL Transformations) is a language used to transform XML files.

XSL Formatting Object: A set of vocabulary used to format (typesetting) semantics.

Step One: Conversion

The first thing the XSL processor needs to do is to read XML tags and data through parser (DOM or SAX) technology.

DOM (Document Object Model) file object model. (XML applications often use DOM technology to access XML data files.)

When the browser reads the XML tree structure and data through the XML DOM object, it rearranges the XML tree structure and combines it to generate A temporary numerical structure, this tree structure is called a result tree.

After the result tree is generated, if new tags or data appear, they must be merged into the result tree.

Second step: Format conversion

The result tree is also a tree structure. You can use DOM technology to access the data of the result tree. The data is displayed in node mode and a record is reserved. The position of the style.

The program in XSL processing converts (formats) these data into another Well-Formed XML file (such as: WML, HTML, VoiceXML, etc.).

It’s over, this is just a small revelation.

Everyone, please come on and work hard. The country is vigorously promoting XML to resist Microsoft's attack. As long as we learn XML well, we will accomplish much.

The above is a detailed explanation of how to quickly convert XML files through XSL. For more related content, please pay attention to the PHP Chinese website (www.php.cn)!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn