以文本方式查看主题

-  中文XML论坛 - 专业的XML技术讨论区  (http://bbs.xml.org.cn/index.asp)
--  『 XSL/XSLT/XSL-FO/CSS 』  (http://bbs.xml.org.cn/list.asp?boardid=8)
----  [求助]   关键字 xsl:choose 可能不包含 PCDATA 节点。  (http://bbs.xml.org.cn/dispbbs.asp?boardid=8&rootid=&id=40008)


--  作者:ppt2006hg
--  发布时间:11/14/2006 6:39:00 PM

--  [求助]   关键字 xsl:choose 可能不包含 PCDATA 节点。

关键字 xsl:choose 可能不包含 PCDATA 节点。这是什么错误?


下面是2个文件:


--  作者:ppt2006hg
--  发布时间:11/14/2006 6:41:00 PM

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

<?xml-stylesheet type="text/xsl" href="XSLTFileLlink.xsl"?>

<items>

  <roomitem>

   <text>新浪</text>

   <link>http://www.sina.com.cn</link>

  </roomitem>

  <roomitem>

   <text>yahoo</text>

   <link>http://www.yahoo.com</link>

  </roomitem>

  <roomitem>

   <text>google</text>

   <link>http://www.google.com</link>

  </roomitem>

  <studyitem>

   <text>html简易教程</text>  

  <link>

 <a href="gohttp://www.shanxiwindow.net/teaching/htmlbook/">go</a>
 
 </link>

  </studyitem>

  <studyitem> 

   <text>javascript中文简介</text>

   <link>http://www.lib.tsinghua.edu.cn/chinese/INTERNET/JavaScript/</link>

  </studyitem>

  <studyitem> 

   <text>msdn中文站点</text>

   <link>http://www.microsoft.com/china/msdn/default.mspx</link>

  </studyitem>

  <studyitem>

   <text>Microsoft .Net 框架 SDK 快速入门教程</text>

   <link>http://chs.gotdotnet.com/quickstart/default.aspx</link>

  </studyitem>
</items>
XSLTFileLlink.xsl-------------------------------------------------------------------------------------------
<?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>

  <!--

    This is an XSLT template file. Fill in this area with the

    XSL elements which will transform your XML to XHTML.

  -->

   <h1>XSLT应用测试</h1>

   <hr/>

   <h3>功能类:</h3>

   <table width="100%" border="1">

    <tr bgcolor="#C9BBAD">

     <th>name</th>

     <th>link</th>

    </tr>

    <xsl:for-each select="items/roomitem">

     <xsl:choose>

      <xsl:when test="(position() mod 2) = 1">

      <tr bgcolor="#C9BBAD">

      <td>

       <xsl:value-of select="text"/>

      </td>

      <td>

       <xsl:value-of select="link"/>

      </td>

      </tr>

      </xsl:when>

      <xsl:otherwise>

       <tr>

        <td>

         <xsl:value-of select="text"/>

        </td>

        <td>

         <xsl:value-of select="link"/>

        </td>

       </tr>

      </xsl:otherwise>

     </xsl:choose>

    </xsl:for-each>

   </table>

   <br/>

   <h3>资源类:</h3>

   <table width="100%" border="1">

    <tr bgcolor="#C9BBAD">

     <th>name</th>

     <th>link</th>

    </tr>

    <xsl:for-each select="items/studyitem">

     <xsl:choose>

      <xsl:when test="(position() mod 2) = 1">

       <tr bgcolor="#C9BBAD">

        <td>

         <xsl:value-of select="text"/>

        </td>

        <td>

         <xsl:value-of select="link"/>

        </td>

       </tr>

      </xsl:when>

      <xsl:otherwise>

       <tr>

        <td>

         <xsl:value-of select="text"/>

        </td>

        <td>

         <xsl:value-of select="link"/>

        </td>

       </tr>

      </xsl:otherwise>

     </xsl:choose>

    </xsl:for-each>

   </table>

  </body>

  </html>

 </xsl:template>

</xsl:stylesheet>


--  作者:Qr
--  发布时间:11/15/2006 6:17: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>
   <h1>XSLT应用测试</h1>
   <hr/>
   <h3>功能类:</h3>
   <table width="100%" border="1">
    <tr bgcolor="#C9BBAD">
     <th>name</th>
     <th>link</th>
    </tr>
    <xsl:for-each select="items/roomitem">
     <xsl:choose>
      <xsl:when test="position() mod 2 = 1">
      <tr bgcolor="#C9BBAD">
      <td>
       <xsl:value-of select="text"/>
      </td>
      <td>
       <xsl:value-of select="link"/>
      </td>
      </tr>
      </xsl:when>
      <xsl:otherwise>
       <tr>
        <td>
         <xsl:value-of select="text"/>
        </td>
        <td>
         <xsl:value-of select="link"/>
        </td>
       </tr>
      </xsl:otherwise>
     </xsl:choose>
    </xsl:for-each>
   </table>

   <br/>
   <h3>资源类:</h3>
   <table width="100%" border="1">
    <tr bgcolor="#C9BBAD">
     <th>name</th>
     <th>link</th>
    </tr>
    <xsl:for-each select="items/studyitem">
     <xsl:choose>
      <xsl:when test="(position() mod 2) = 1">
       <tr bgcolor="#C9BBAD">
        <td>
         <xsl:value-of select="text"/>
        </td>
        <td>
         <xsl:value-of select="link"/>
        </td>
       </tr>
      </xsl:when>
      <xsl:otherwise>
       <tr>
        <td>
         <xsl:value-of select="text"/>
        </td>
        <td>
         <xsl:value-of select="link"/>
        </td>
       </tr>
      </xsl:otherwise>
     </xsl:choose>
    </xsl:for-each>
   </table>
  </body>
  </html>
</xsl:template>
</xsl:stylesheet>


--  作者:ppt2006hg
--  发布时间:11/18/2006 11:05:00 AM

--  

谢谢你,
我把空格都删了,问题就解决了,
哈哈,顺便说一下,编写这个文件时 “记事本、Altova XMLSpy、notepad++” 我都用过,
也许格式上就出问题了。
W 3 C h i n a ( since 2003 ) 旗 下 站 点
苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
62.012ms