在xsd文件中对字段price设置为int型,但在xml中我输入字符时也不报错?
我想是不是在xml中xsd文件路径设置有问题?
请高手指出!!!!
谢谢!!!
book.xml
<?xml version="1.0" encoding="gb2312"?>
<?xml:stylesheet type="text/xsl" href="book.xsl"?>
<books xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance" xsi:noNamespaceSchemaLocation="book.xsd">
<class>
<title> 语文</title>
<price>1234455677</price>
</class>
<class>
<title> 数学</title>
<price>7654ggg321</price>
</class>
</books>
book.xsl
<?xml version="1.0" encoding="gb2312" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
<xsl:template match="/">
<html>
<head>
<title>
测试xsd
</title>
<style>
body,books,title,price,class,{ font: 12px "宋体", "Arial", "Times New Roman"; }
table { font-size: 12px; border: 0px double; border-color: #99CC99 #99CC99 #CCCCCC #CCCCCC; cellpadding:3;cellspacing:3; bgcolor:#eeeeee; text-decoration: blink}
.keybutton { cursor:hand; font-size: 12px; color: #003300; background: #ffffff; border: 0px solid;}
</style>
<script>
<xsl:comment>
<![CDATA[
function window.onload()
{
}
]]>
</xsl:comment>
</script>
</head>
<body>
<div id="Layer1" name="Layer1"> <xsl:apply-templates select="books" /></div>
</body>
</html>
</xsl:template>
<xsl:template match="books">
<table width="600" border="1" align="center" cellpadding="1" cellspacing="1" bordercolordark="#ffffff" bordercolorlight="#ADAAAD">
<tr bgcolor="#FFCC99" align="center">
<td>书名</td>
<td>价钱</td>
</tr>
<xsl:apply-templates select="class" order-by="title"/>
</table>
</xsl:template>
<xsl:template match="class">
<tr align="center">
<xsl:apply-templates select="title"/>
<xsl:apply-templates select="price" />
</tr>
</xsl:template>
<xsl:template match="title">
<td bgcolor="#eeeeee">
<xsl:value-of />
</td>
</xsl:template>
<xsl:template match="price">
<td>
<input type="text" size="20" maxlength="8" name="aa" ><xsl:attribute name="value"><xsl:value-of /></xsl:attribute></input>
</td>
</xsl:template>
</xsl:stylesheet>
book.xsd
<?xml version="1.0" encoding="gb2312"?>
<!-- edited with XML Spy v4.2 U (
http://www.xmlspy.com) by yiding (deep) -->
<xsd:schema targetNamespace="http://www.example.com/IPO" xmlns:ipo="http://www.example.com/IPO" xmlns:xsd="http://www.w3.org/2000/10/XMLSchema">
<xsd:element name="books">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="class" minOccurs="0" maxOccurs="unbounded">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="title" type="xsd:string"/>
<xsd:element name="price" type="xsd:int"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<xsd:attribute name="isbn" type="xsd:string"/>