我想将XML Schema与XML文件链接起来。我按照这个例子:XSD How To。
note.xml
看起来像:
<?xml version="1.0"?>
<note
xmlns="http://www.w3schools.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.w3schools.com note.xsd">
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
note.xsd
看起来像:
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.w3schools.com"
xmlns="http://www.w3schools.com"
elementFormDefault="qualified">
<xs:element name="note">
<xs:complexType>
<xs:sequence>
<xs:element name="to" type="xs:string"/>
<xs:element name="from" type="xs:string"/>
<xs:element name="heading" type="xs:string"/>
<xs:element name="body" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
但是当我打开note.xml
时,它在我的浏览器中看起来就像常规XML,其描述如下:This XML file does not appear to have any style information associated with it. The document tree is shown below.
这些文件都在同一目录中。
答案 0 :(得分:2)
您是否因为附加XSLT转换而附加XML Schema而感到困惑?因为您的浏览器告诉您缺少样式表,而不是没有架构
答案 1 :(得分:0)
XSD(架构)仅用于任何xml的验证目的...而XSLT用于为XML提供样式用途 - 在ur xml中根本不存在,所以你怎么能期望浏览器中的任何样式当你运行这个XML文件时...... !!!