首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >XML、XSL、XML架构

XML、XSL、XML架构
EN

Stack Overflow用户
提问于 2016-05-09 04:32:29
回答 1查看 583关注 0票数 1

我需要关于XSL和XML模式的帮助。

这是XML文件:

代码语言:javascript
复制
<?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架构:

代码语言:javascript
复制
<?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:

代码语言:javascript
复制
<?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也不能正常工作。我的限制也会被忽略。

我做什么好?

EN

回答 1

Stack Overflow用户

发布于 2016-05-09 04:49:00

xsi:schemaLocation="spellsschema.xsd"是错误的,您需要在其中放置一对名称空间uri和位置uri:xsi:schemaLocation="spells.xml spellsschema.xsd"

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/37104533

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档