2014-02-05 75 views
0

我的XML文件的代码如下:XSL锚属性

<?xml version="1.0" encoding="utf-8"?> 

<testimonials> 
    <item> 
     <author-name>xyz</author-name> 
     <author-url>http://xyz.net</author-url> 
    </item> 
    <item> 
     <author-name>abcde</author-name> 
     <author-url>http://abc.org</author-url> 
    </item> 

</testimonials> 

XSL文件的代码看起来

<?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" encoding="utf-8" indent="no"/> 

<xsl:template match="/xmlfile"> 
    <xsl:for-each select="item"> 

    <li> 
     <a> 
        <xsl:attribute name="href"> 
         <xsl:value-of select="author-url"/> 
        </xsl:attribute> 
        <xsl:attribute name="target">_blank</xsl:attribute> 
        <xsl:value-of select="author-url"/> 
     </a> 

    </li> 

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

</xsl:stylesheet> 

当我尝试使用这些XML文件,我没有得到锚标签,我根本看不到文本输出

XYZ http://xyz.net ABCDE http://abc.org

PL缓解让我知道,如果我做任何chnages使我能看到的锚标记

回答

0

变化:

<xsl:template match="/xmlfile"> 

到:

<xsl:template match="/testimonials"> 
+0

谢谢你,它的工作了。 – ashu09