应用的XSL转换未显示XML文档

时间:2016-09-20 23:26:03

标签: xml xslt

我有以下xml文件在电视节目中有一些虚拟数据..

<?xml version = "1.0" encoding = "UTF-8"?>
<?xml-stylesheet type = "text/xsl" href = "shows_transform.xsl"?>

  <TVSHOWS>

<newsshow xmlns="http://www.w3schools.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="shows_schema.xsd">
  <showtitle lang="en">Arizona Horizon</showtitle>
  <showcategory> news</showcategory>
  <subgroup>Horizon 2016</subgroup>
  <host>
    <firstname>Ted</firstname>
    <lastname>Simons</lastname>
  </host>
  <airdate>2016-07-15</airdate>
  <episodetitle>Arizona Governor Live</episodetitle>
  <description>Join Arizona Governor on his weekly appearance on Arizona  Horizon.</description>
</newsshow>

<newsshow xmlns="http://www.w3schools.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="shows_schema.xsd">
  <showtitle lang="en">Horizonte</showtitle>
  <showcategory> news</showcategory>
  <subgroup>Horizonte 2016</subgroup>
  <host>
    <firstname>Jose</firstname>
    <lastname>Cardenas</lastname>
  </host>
  <airdate>2016-08-24</airdate>
  <episodetitle>Political Roundtable</episodetitle>
  <description>We talk about the primary election results.</description>
</newsshow>

<show xmlns="http://www.w3schools.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="shows_schema.xsd">
  <showtitle lang="en">Father Brown</showtitle>
  <showcategory>drama</showcategory>
  <subgroup>Season 4</subgroup>
  <cast>
    <fullname>Mark Williams</fullname>
  </cast>
  <airdate>2016-09-13</airdate>
  <episodetitle>The blue cross</episodetitle>
  <description>Father Brown saves an ancient relic from getting stolen.    </description>
</show>

<show xmlns="http://www.w3schools.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="shows_schema.xsd">
  <showtitle lang="en">Dalziel and Pascoe</showtitle>
  <showcategory>drama</showcategory>
  <subgroup>Season 12</subgroup>
  <cast>
    <fullname>Warren Clark</fullname>
  </cast>
  <airdate>2016-09-13</airdate>
  <episodetitle>Fallen Angel</episodetitle>
  <description>A rescue mission to save several cavers goes awry.</description>
</show>

</TVSHOWS>

我正在使用以下XSL文档应用转换。但是,浏览器不应用转换。我正在使用Firefox来显示输出。

<?xml version = "1.0" encoding = "UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" version = "4.0" encoding="utf-8" indent =" yes"/>
<xsl:template match = "/">
 <html xmlns="http://www.w3.org/1999/xhtml">
 <body style = "padding:4px">

<xsl:for-each select = "TVSHOWS/newsshow">
  <div style="padding:4px">
    <h1><span style="font-weight: bold"><xsl:value-of select = "showtitle"/></span>
    (<xsl:value-of select = "showcategory"/>)
    </h1>

    <div style = "padding:4px">
      <p>Hosted by: <xsl:value-of select = "host/firstname"/> <xsl:value-of select = "host/firstname"/><br/>
      Aired on: <xsl:value-of select = "airdate"/><br/>
      Episode Title: <xsl:value-of select = "episodetitle"/><br/>
      Description: <xsl:value-of select = "description"/><br/>
      </p>
    </div>

  </div>
</xsl:for-each>

<xsl:for-each select = "TVSHOWS/show">
  <div style = "padding: 4px">
    <h1><span style = "font-weight: bold"> <xsl:value-of select = "showtitle"/></span>
      (<xsl:value-of select = "showcategory"/>)
    </h1>

    <div style = "padding: 4px">
      <p>Cast: <xsl:for-each select = "cast">
          <xsl:value-of select = "cast/fullname"/><br/>
        </xsl:for-each>
        Aired on: <xsl:value-of select = "airdate"/><br/>
        Episode Title: <xsl:value-of select = "episodetitle"/><br/>
        Description: <xsl:value-of select = "description"/><br/>
      </p>
    </div>

  </div>

</xsl:for-each>

</body>
</html>

</xsl:template>
</xsl:stylesheet>

0 个答案:

没有答案