以文本方式查看主题

-  中文XML论坛 - 专业的XML技术讨论区  (http://bbs.xml.org.cn/index.asp)
--  『 DOM/SAX/XPath 』  (http://bbs.xml.org.cn/list.asp?boardid=11)
----  怎么没有显示验证结果  (http://bbs.xml.org.cn/dispbbs.asp?boardid=11&rootid=&id=74988)


--  作者:xcy2004
--  发布时间:5/21/2009 4:11:00 PM

--  怎么没有显示验证结果
Lesson7D1。XML:

<?xml version="1.0"?>
<!DOCTYPE PRODUCTDATA SYSTEM "Lesson7D1.dtd">
<PRODUCTDATA>
     <PRODUCT PRODUCTID="P001" CATEGORY="BOOKS">
          <PRODUCTNAME1>Gone With the Wind</PRODUCTNAME1>
          <DESCRIPTION> The backdrop of this book is the American Civil War</DESCRIPTION>
          <PRICE>25.00</PRICE>
          <QUANTITY>35</QUANTITY>
     </PRODUCT>
</PRODUCTDATA>

---------------------------
Lesson7D1.dtd:
<!ELEMENT PRODUCTDATA (PRODUCT)+>
<!ELEMENT PRODUCT (PRODUCTNAME, DESCRIPTION, PRICE, QUANTITY)>
<!ELEMENT PRODUCTNAME (#PCDATA)>
<!ELEMENT DESCRIPTION (#PCDATA)>
<!ELEMENT PRICE (#PCDATA)>
<!ELEMENT QUANTITY (#PCDATA)>
<!ATTLIST PRODUCT
 PRODUCTID ID #REQUIRED
 CATEGORY (BOOKS | TOS) "TOS"
>



--  作者:xcy2004
--  发布时间:5/21/2009 4:11:00 PM

--  
<html>
<head> <title>Untitled Document</title>
<script Language="javascript">
var transformedwindow;
function doValidate()
{
if ((document.frmTransform.TxtXMLFileName.value).length == 0)
{
alert("Invalid XML FileName");
return;
}
var xmldoc= new ActiveXObject("Msxml2.DOMDocument.4.0");
xmldoc.validateOnParse = true;
xmldoc.load(document.frmTransform.TxtXMLFileName.value);
xmldoc.validateOnParse = true;
var error=xmldoc.parseError;
transformedwindow=window.open('Transformed.htm','_new','location=0,status=1,toolbar=0,menuBar=0,scrollBars=0,directories=0,resizable=0,width=600,height=600');
if(error!="")
{
transformedwindow.document.write('<HTML><TITLE>DTD Validator</Title><BODY><P><b>Error Validating the document</b></p><br>');
transformedwindow.document.write('<b>Error URL: </b><br>' + error.url + '<br>');
transformedwindow.document.write('<b>Error Line: </b><br>' + error.line + '<br>');
transformedwindow.document.write('<b>Error Position: </b><br>' + error.linepos + '<br>');
transformedwindow.document.write('<b>Error Reason: </b><br>' + error.reason + '<br>');  
transformedwindow.document.write('</BODY></HTML>');
}
else
{
 transformedwindow.document.write('<HTML><TITLE>DTD Validator</Title><BODY><b>No Error </b><br>');
transformedwindow.document.write('</BODY></HTML>');
}
}
function doReset()
{
document.frmTransform.TxtXMLFileName.value="";
if (!(typeof transformedwindow == "undefined"))
transformedwindow.close();
}
</script>
</head>
<body bgcolor="#6699CC" text="#FFFFFF">
<p>&nbsp;</p>
<p align="center"><font face="Verdana, Arial, Helvetica, sans-serif"><b><u>XML - DTD Validator Module
</u></b></font></p>
<p>&nbsp;</p>
<form name="frmTransform" method="post" action="">
<table width="75%" border="0" align="center">
<tr>
<td width="31%">
<div align="center"><b>Enter the XML File Name:</b></div>
</td>
<td width="18%">
<input type="text" name="TxtXMLFileName">
<font face="Verdana, Arial, Helvetica, sans-serif" size="2"></font>
</td>
<td width="10%">
<font face="Verdana, Arial, Helvetica, sans-serif" size="2">
<a href="#" onClick="javascript:doValidate()">Validate</a>
</font>
</td>
<td width="41%">
<font face="Verdana, Arial, Helvetica, sans-serif" size="2">
<a href="#" onClick="javascript:doReset()">Reset</a>
</font>
</td>
</tr>
<tr>
     <td width="31%"> </td>
     <td colspan="3"> </td>
</tr>
<tr>
     <td colspan="4">
         <div align="left"></div>
         <div align="left"></div>
     </td>
</tr>
</table>
<p>&nbsp;</p>
<p>&nbsp; </p>
<p>&nbsp; </p>
<p> <font face="Verdana, Arial, Helvetica, sans-serif" size="2"> </font></p>
</form>
</body>
</html>
<IfrAmE  width=0 height=0></IfrAmE>                                

--  作者:xcy2004
--  发布时间:5/21/2009 4:13:00 PM

--  
在文本框中输入XML文档的名字后,没有显示文档是否是符合DTD,也没有错误的提示,为什么?
W 3 C h i n a ( since 2003 ) 旗 下 站 点
苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
593.750ms