newsmain.xml:
<?xml version="1.0" encoding="GB2312"?>
<?xml-stylesheet type="text/xsl" href="newsmain.xsl" ?>
<Main>
  <NewsMain>
    <Title>666</Title>
    <Href>200497162423.xml</Href>
    <inputtime>2004-9-7 16:24:23</inputtime>
  </NewsMain>
</Main>newsmain.xsl:
<?xml version="1.0" encoding="GB2312" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/">
<Html>
<table width="100%" border="1">
<xsl:apply-templates select="//NewsMain"></xsl:apply-templates>
</table>
</Html>
</xsl:template>

<xsl:template match="NewsMain">
<tr>
<td>
<xsl:apply-templates select="Title" /></td>
<td>
<xsl:value-of select="Href" />
</td>
<td>
<xsl:value-of select="inputtime"/>
</td>
</tr>
</xsl:template> <xsl:template match="Title">
<xsl:element name="A">
<xsl:attribute name="HREF">
<xsl:value-of select="@Href"/>
</xsl:attribute>
<xsl:value-of select="@Title" />
</xsl:element>
</xsl:template>
</xsl:stylesheet>
  我想让title显示为连接,路径就是的跟节点的href里面的内容,可我这么写就什么都不显示了???请大侠指教

解决方案 »

  1.   

    <?xml version="1.0" encoding="GB2312" ?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

    <xsl:template match="/">
    <Html>
    <table width="100%" border="1">
    <xsl:apply-templates select="//NewsMain"></xsl:apply-templates>
    </table>
    </Html>
    </xsl:template>

    <xsl:template match="NewsMain">
    <tr>
    <td>
    <xsl:element name="A">
    <xsl:attribute name="HREF">
    <xsl:value-of select="Href"/>
    </xsl:attribute>
    <xsl:value-of select="Title" />
    </xsl:element></td>
    <td>
    <xsl:value-of select="Href" />
    </td>
    <td>
    <xsl:value-of select="inputtime"/>
    </td>
    </tr>
    </xsl:template></xsl:stylesheet>
      

  2.   

    因为你用的是@,表示属性。或者,你把你的XML文件修改为:<?xml version="1.0" encoding="GB2312"?>
    <?xml-stylesheet type="text/xsl" href="newsMain.xsl" ?>
    <Main>
      <NewsMain>
        <Title Title='666' Href='200497162423.xml'/>
        <Href>200497162423.xml</Href>
        <inputtime>2004-9-7 16:24:23</inputtime>
      </NewsMain>
    </Main>这样也是可以的。有了这两个解决办法,你应该明白你的具体错误了吧?