我正在尝试获取正在播放的 selecao 的名称,例如<jogo numero="1">
我想从 IDREF s1 中获取 PAIS 的名称,它是 Franca。
xpath 中的查询://id(@pais) 并返回 Franca 和 Senegal,OK,这两个是唯一有 IDREF pais 的。但是我把这个表达式放在 xsl 中并不起作用。
有人知道错误在哪里吗?
这是我的代码:
XML
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="file:///C:/Users/Cesar%20Frantz/Desktop/XML/trabalhoxml.xsl"?>
<Bolaocopa xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="file:///C:/Users/Cesar%20Frantz/Desktop/exemplo.xsd">
<grupos>
<grupo tipo="A">
<pais id="s1">Franca</pais>
<pais id="s2">Senegal</pais>
<pais id="s3">Uruguai</pais>
<pais id="s4">Dinamarca</pais>
</grupo>
</grupos>
<jogos>
<faseGrupos>
<jogoGrupo id="a">
<jogo numero="1">
<selecao pais="s1">0</selecao>
<selecao pais="s2">1</selecao>
</jogo>
</jogoGrupo>
</faseGrupos>
</jogos>
</Bolaocopa>
XSL:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<xsl:value-of select="//id(@pais)"/>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
架构:
<?xml version="1.0" encoding="UTF-8"?>
<!-- edited with XMLSpy v2013 sp1 (x64) (http://www.altova.com) by Cesar (UNIFRA - Franciscan University Center) -->
<!--W3C Schema generated by XMLSpy v2013 sp1 (x64) (http://www.altova.com)-->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:simpleType name="ST_selecao">
<xs:restriction base="xs:int">
<xs:enumeration value="0"/>
<xs:enumeration value="1"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="ST_pais">
<xs:restriction base="xs:string">
<xs:enumeration value="Dinamarca"/>
<xs:enumeration value="Franca"/>
<xs:enumeration value="Senegal"/>
<xs:enumeration value="Uruguai"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="AT_6">
<xs:restriction base="xs:string">
<xs:enumeration value="s1"/>
<xs:enumeration value="s2"/>
<xs:enumeration value="s3"/>
<xs:enumeration value="s4"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="AT_5">
<xs:restriction base="xs:string">
<xs:enumeration value="A"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="AT_3">
<xs:restriction base="xs:string">
<xs:enumeration value="s1"/>
<xs:enumeration value="s2"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="AT_2">
<xs:restriction base="xs:int">
<xs:enumeration value="1"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="AT_1">
<xs:restriction base="xs:string">
<xs:enumeration value="a"/>
</xs:restriction>
</xs:simpleType>
<xs:complexType name="T_selecao">
<xs:simpleContent>
<xs:extension base="ST_selecao">
<xs:attribute ref="pais"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
<xs:complexType name="T_pais">
<xs:simpleContent>
<xs:extension base="ST_pais">
<xs:attribute name="id" type="xs:ID" use="required"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
<xs:complexType name="T_jogos">
<xs:sequence>
<xs:element ref="faseGrupos"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="T_jogoGrupo">
<xs:sequence>
<xs:element ref="jogo"/>
</xs:sequence>
<xs:attribute name="id" type="AT_1" use="required"/>
</xs:complexType>
<xs:complexType name="T_jogo">
<xs:sequence>
<xs:element ref="selecao" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute ref="numero" use="required"/>
</xs:complexType>
<xs:complexType name="T_grupos">
<xs:sequence>
<xs:element ref="grupo"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="T_grupo">
<xs:sequence>
<xs:element ref="pais" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute ref="tipo" use="required"/>
</xs:complexType>
<xs:complexType name="T_faseGrupos">
<xs:sequence>
<xs:element ref="jogoGrupo"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="T_Bolaocopa">
<xs:sequence>
<xs:element ref="grupos"/>
<xs:element ref="jogos"/>
</xs:sequence>
</xs:complexType>
<xs:attribute name="tipo" type="AT_5"/>
<xs:attribute name="pais" type="xs:IDREF"/>
<xs:attribute name="numero" type="AT_2"/>
<xs:element name="selecao" type="T_selecao"/>
<xs:element name="pais" type="T_pais"/>
<xs:element name="jogos" type="T_jogos"/>
<xs:element name="jogoGrupo" type="T_jogoGrupo"/>
<xs:element name="jogo" type="T_jogo"/>
<xs:element name="grupos" type="T_grupos"/>
<xs:element name="grupo" type="T_grupo"/>
<xs:element name="faseGrupos" type="T_faseGrupos"/>
<xs:element name="Bolaocopa" type="T_Bolaocopa"/>
</xs:schema>