我需要有关 XSL 和 XML Schema 的帮助。
这是 XML 文件:
<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="spellstyle.xsl"?>
<spells xmlns="spels.xml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="spellsschema.xsd">
<spell category="fire" cooldown="18" manacost="100">
<name>Fire Breath</name>
<image id="FireBreath"/>
<discription>Some text</discription>
<category>Fire</category>
<cooldown>18</cooldown>
<manacost>100</manacost>
</spell>
</spells>
这是 XML 模式:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="spells.xml" elementFormDefault="qualified">
<xs:element name="spells">
<xs:complexType>
<xs:sequence>
<xs:element name="spell">
<xs:attribute name="category" use="required">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern value="fire|water|air|earth"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="cooldown" type="xs:duration" use="required"/>
<xs:attribute name="manacost" type="xs:decimal" use="required"/>
<xs:complexType>
<xs:sequence>
<xs:element name="name" type="xs:string"/>
<xs:element name="image"/>
<xs:element name="discription" type="xs:string"/>
<xs:element name="category" type="xs:string"/>
<xs:element name="cooldown" type="xs:duration"/>
<xs:element name="manacost" type="xs:decimal"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
这是 XSL:
<?xml version="1.0" encoding="utf-8"?>
<!-- DWXMLSource="spells.xml" -->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:for-each select="spells/spell">
<xsl:value-of select="discription"/>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
问题是当我应用我的 XSL 文件时,XML 完全停止显示。而且我认为我的 XML Schema 也不能正常工作。我的限制也被忽略了。
我该怎么办?