You can use a simple XSL style sheet to convert XML data into HTML. With the continuous evolution of XML specifications, it seems necessary to meet the needs of everyone in the new version. suppose there is an XML data that represents the content of a page, now I want Apply a simple
XSLThe style sheet can convert XML data
HTML. With the continuous evolution of XML specifications, it seems necessary to meet the needs of everyone in the new version. suppose there is an XML data that represents the content of a page, now I want to convert the content to layout. The XML to be converted is as follows:
Folder 1
File 1
String
50
Some data
This content represents a group of folders, files, and domains. Each folder contains files, and each file contains the fields used for data input. Each folder in the folder group is represented as a TR element and a TD element in the first row of a TABLE. Each file in the file Group is represented as a TR element and a TD element in the first row of a TABLE element nested in the TR element of the folder. Each domain in the Domain Group is represented as an INPUT in the coherent file.
The following is the XSL used for this conversion:
Xmlns: xsl = "http://www.w3.org/1999/XSL/Transform" version = "1.0"
Xmlns: msxsl = "urn: schemas-microsoft-com: xslt"
Xmlns: fn = http://www.aaa.com/aaa>
Function getElementCount (nodelist, what ){
Var rtrn = 0;
Rtrn = nodelist [0]. parentNode. selectNodes (what). length;
Return (rtrn 1); // 1 is added for filler TD
}
WIDTH = "100%" BORDER = "0" ID = "tblRoot" NAME = "tblRoot"
Style = "table-layout: fixed;">
Width: 55px
WIDTH = "100%" BORDER = "0" style = "table-layout: fixed;">
Width: 55px;