注意: 此html文件只能用IE浏览器打开 解压压缩文件就可以看到html文件了
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>PDMreport</title>
<script type="text/javascript">
var loadXML = function(fileRoute){
xmlDoc=null;
if (window.ActiveXObject){
xmlDoc = new ActiveXObject('Msxml2.DOMDocument');
xmlDoc.async=false;
xmlDoc.load(fileRoute);
}
else if (document.implementation && document.implementation.createDocument){
var xmlhttp = new window.XMLHttpRequest();
xmlhttp.open("GET",fileRoute,false);
xmlhttp.send(null);
var xmlDoc = xmlhttp.responseXML.documentElement;
}
else {xmlDoc=null;}
return xmlDoc;
}
window.onload = function(){
var oxml= loadXML("ORG.pdm");
var tables = oxml.getElementsByTagName("c:Tables")[0];
var itable=tables.firstChild;
var html=[];
var indextable=[];
var refs= oxml.getElementsByTagName("c:References")[0];
var refIds=[];
var refsCount=refs.childNodes.length;
for(var i=0;i<refsCount;i++){
var refId=refs.childNodes[i].getElementsByTagName("c:Object2")[0].firstChild.getAttribute("Ref");
refIds.push(refId);
}
indextable.push("<table cellpadding=\"0\" cellspacing=\"0\">");
indextable.push("<tr><td class=\"topitd\" style=\"width:50px\">编号</td><td class=\"topitd\" style=\"width:150px\">名称</td><td class=\"trightitd\" style=\"width:200px\">描述</td></tr>");
var indextableCount=0;
while(itable){
indextableCount++;
indextable.push("<tr><td>"+indextableCount+"</td>");
var columns=itable.getElementsByTagName("c:Columns")[0].childNodes;
var tableName=itable.getElementsByTagName("a:Name")[0].firstChild.nodeValue;
indextable.push("<td>"+tableName+"</td>");
var tableCode=itable.getElementsByTagName("a:Code")[0].firstChild.nodeValue;
indextable.push("<td class=\"rightitd\">"+tableCode+"</td></tr>");
try{
var tableComment=itable.getElementsByTagName("a:Comment")[0].firstChild.nodeValue;
}catch(e){
var tableComment=" ";
}
var colsCount=columns.length;
html.push("<div class=\"tableName\">");
html.push(tableName+"("+tableCode+")");
html.push("</div>");
html.push("<table cellpadding=\"0\" cellspacing=\"0\">");
html.push("<tr>");
html.push("<td class=\"topitd\" style=\"width:150px\">");
html.push("字段名称");
html.push("</td>");
html.push("<td class=\"topitd\" style=\"width:150px\">");
html.push("字段描述");
html.push("</td>");
html.push("<td class=\"topitd\" style=\"width:120px\">");
html.push("数据类型");
html.push("</td>");
html.push("<td class=\"topitd\" style=\"width:80px\">");
html.push("是否非空");
html.push("</td>");
html.push("<td class=\"trightitd\" style=\"width:40px\">");
html.push("约束");
html.push("</td>");
/*
html.push("<td class=\"trightitd\" style=\"width:200px\">");
html.push("备注");
html.push("</td>");
*/
html.push("</tr>");
var ikeys=itable.getElementsByTagName("c:Keys")[0].childNodes;
var keyCount=ikeys.length;
var akeys=[];
var ks=[];
for(var i=0;i<keyCount;i++){
var keyId=ikeys[i].getAttribute("Id");
var refCol=ikeys[i].getElementsByTagName("c:Key.Columns")[0].firstChild.getAttribute("Ref");
akeys.push(refCol);
ks.push(keyId);
}
var pkeys=[];
ikeys=null;
keyCount=null
var ikeys=itable.getElementsByTagName("c:PrimaryKey")[0].childNodes;
var keyCount=ikeys.length;
for(var i=0;i<keyCount;i++){
var keyId=ikeys[i].getAttribute("Ref");
var index=ks.join(",").indexOf(keyId);
if(index>-1){
pkeys.push(akeys[ks.join(",").substr(0, index).split(",").length-1]);
};
}
for(var i=0;i<colsCount;i++){
var colId=columns[i].getAttribute("Id");
html.push("<tr>");
var colCode=columns[i].getElementsByTagName("a:Code")[0].firstChild.nodeValue;
html.push("<td>"+colCode+"</td>");
var colName=columns[i].getElementsByTagName("a:Name")[0].firstChild.nodeValue;
html.push("<td>"+colName+"</td>");
var dataType=columns[i].getElementsByTagName("a:DataType")[0].firstChild.nodeValue;
html.push("<td>"+dataType+"</td>");
try{
var isNull=columns[i].getElementsByTagName("a:Mandatory")[0].firstChild.nodeValue;
if(isNull=="1"){html.push("<td>非空</td>");
}else{
if(isNull=="1")html.push("<td> </td>");
}
}catch(e){
html.push("<td> </td>");
}
if(pkeys.join(",").indexOf(colId)>-1){
html.push("<td class=\"rightitd\">PK</td>");
}else if(akeys.join(",").indexOf(colId)>-1){
html.push("<td class=\"rightitd\">AK</td>");
}else if(refIds.join(",").indexOf(colId)>-1){
html.push("<td class=\"rightitd\">FK</td>");
}
else{
html.push("<td class=\"rightitd\"> </td>");
}
/*增加备注栏
try{
var dataComment=columns[i].getElementsByTagName("a:Comment")[0].firstChild.nodeValue;
}catch(e){
var dataComment=" "
}
html.push("<td class=\"rightitd\">"+dataComment+"</td>");
*/
html.push("</tr>");
}
html.push("</table>");
document.getElementById("dataDictionary").innerHTML=html.join("");
itable=itable.nextSibling;
}
indextable.push("</tr></table>");
document.getElementById("tableIndex").innerHTML=indextable.join("");
}
</script>
<style type="text/css">
body{
font-family:宋体, Arial, Helvetica, sans-serif;
font-size:14px;
font-style:normal;
}
#dataDictionary table{
margin-bottom: 30px
}
#dataDictionary table tr td{
border-bottom: 1px #3399FF solid;
border-left : 1px #3399FF solid;
height: 19px;
}
#dataDictionary table tr .rightitd{
border-right : 1px #3399FF solid;
}
#dataDictionary table tr .trightitd{
border-right : 1px #3399FF solid;
border-top : 1px #3399FF solid;
color: #000066;
font-weight:400;
}
#dataDictionary table tr .topitd{
border-top : 1px #3399FF solid;
color: #000066;
font-weight:400;
}
#dataDictionary .tableName{
margin-bottom:5px;
font-weight:400;
color:#CC3300
}
#tableIndex table{
margin-bottom: 30px
}
#tableIndex table tr td{
border-bottom: 1px #3399FF solid;
border-left : 1px #3399FF solid;
height: 19px;
}
#tableIndex table tr .rightitd{
border-right : 1px #3399FF solid;
}
#tableIndex table tr .trightitd{
border-right : 1px #3399FF solid;
border-top : 1px #3399FF solid;
color: #000066;
font-weight:400;
}
#tableIndex table tr .topitd{
border-top : 1px #3399FF solid;
color: #000066;
font-weight:400;
}
#tableIndex .tableName{
margin-bottom:5px;
font-weight:400;
color:#CC3300
}
</style>
</head>
<body>
<div id="tableIndex"></div>
<div id="dataDictionary"></div>
</body>
</html>