以文本方式查看主题

-  中文XML论坛 - 专业的XML技术讨论区  (http://bbs.xml.org.cn/index.asp)
--  『 灌水天堂 』  (http://bbs.xml.org.cn/list.asp?boardid=26)
----  一个小问题  (http://bbs.xml.org.cn/dispbbs.asp?boardid=26&rootid=&id=84490)


--  作者:yulhsu
--  发布时间:4/24/2010 8:18:00 PM

--  一个小问题
?xml version="1.0" encoding="utf-8"?>

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

<xsl:template match="/">
    <html>
    <body>
      <table border="3" bgcolor="pink">
        <tr>
          <th>符号</th>
          <th>名字</th>
          <th>价格</th>
        </tr>
        <xsl:for-each select="new1/stock">
          <tr>
            <td>
              <xsl:value-of select="符号"/>
            </td>
            <td>
              <xsl:value-of select="名字"/>
            </td>
            <td>
              <xsl:value-of select="价格"/>
            </td>
          </tr>
        </xsl:for-each>
      </table>
    </body>
    </html>
</xsl:template>

</xsl:stylesheet>


--  作者:yulhsu
--  发布时间:4/24/2010 8:18:00 PM

--  
<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="new1.xsl"?>
<portfolio>
  <stock exchange="nyse">
    <名字>zacx corp</名字>
    <符号>ZCXM</符号>
    <价格>28.875</价格>
  </stock>
  <stock exchange="nasdap">
    <名字>zaffymat inc</名字>
    <符号>ZFFX</符号>
    <价格>92.250</价格>
  </stock>
</portfolio>
--  作者:yulhsu
--  发布时间:4/24/2010 8:21:00 PM

--  
却不能全部显示???
--  作者:hjx_221
--  发布时间:4/24/2010 8:22:00 PM

--  
Sorry, Not Found.

--------------------------------------------------------------------------------

The URL path in your request doesn't match anything we have available.
If you believe this is not the page you were trying to reach.


--  作者:jj_long
--  发布时间:4/28/2010 11:01:00 PM

--  
主要问题是没有选择到任何节点,修改如下:

方法一:
====================================================
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">

    <xsl:output encoding="UTF-8" method="html"
                         doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
                         doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"></xsl:output>
    
    <xsl:template match="/">
        <html>
            <head>
                <meta content="text/html; charset=UTF-8" http-equiv="Content-Type"/>
                <title>测试</title>
            </head>
            <body>
                <table border="3" bgcolor="pink">
                    <tr>
                        <th>符号</th>
                        <th>名字</th>
                        <th>价格</th>
                    </tr>
                    <xsl:for-each select="portfolio/stock">
                        <tr>
                            <td>
                                <xsl:value-of select="符号"/>
                            </td>
                            <td>
                                <xsl:value-of select="名字"/>
                            </td>
                            <td>
                                <xsl:value-of select="价格"/>
                            </td>
                        </tr>
                    </xsl:for-each>
                </table>
            </body>
        </html>
    </xsl:template>
    
</xsl:stylesheet>


方法二:
=====================================================
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">

    <xsl:output encoding="UTF-8" method="html"
                         doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
                         doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"></xsl:output>
    
    <xsl:template match="/">
        <html>
            <head>
                <meta content="text/html; charset=UTF-8" http-equiv="Content-Type"/>
                <title>测试</title>
            </head>
            <body>
                <table border="3" bgcolor="pink">
                    <tr>
                        <th>符号</th>
                        <th>名字</th>
                        <th>价格</th>
                    </tr>
                    <xsl:apply-templates/>
                </table>
            </body>
        </html>
    </xsl:template>


    <xsl:template match="stock">
        <tr>
            <td>
                <xsl:value-of select="符号"/>
            </td>
            <td>
                <xsl:value-of select="名字"/>
            </td>
            <td>
                <xsl:value-of select="价格"/>
            </td>
        </tr>
    </xsl:template>

</xsl:stylesheet>


--  作者:Qr
--  发布时间:4/30/2010 12:31:00 PM

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

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

<xsl:template match="/">
    <html>
    <body>
      <table border="3" bgcolor="pink">
        <tr>
          <th>符号</th>
          <th>名字</th>
          <th>价格</th>
        </tr>
        <xsl:for-each select="portfolio/stock">
          <tr>
            <td>
              <xsl:value-of select="符号"/>
            </td>
            <td>
              <xsl:value-of select="名字"/>
            </td>
            <td>
              <xsl:value-of select="价格"/>
            </td>
          </tr>
        </xsl:for-each>
      </table>
    </body>
    </html>
</xsl:template>

</xsl:stylesheet>


W 3 C h i n a ( since 2003 ) 旗 下 站 点
苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
93.750ms