以文本方式查看主题

-  中文XML论坛 - 专业的XML技术讨论区  (http://bbs.xml.org.cn/index.asp)
--  『 XSL/XSLT/XSL-FO/CSS 』  (http://bbs.xml.org.cn/list.asp?boardid=8)
----  xml文件经翻译后页面显示完成但是空白没有东东是怎么回事?  (http://bbs.xml.org.cn/dispbbs.asp?boardid=8&rootid=&id=7104)


--  作者:Cindylm
--  发布时间:4/28/2004 8:48:00 PM

--  xml文件经翻译后页面显示完成但是空白没有东东是怎么回事?
我的xml文件用xsl文件翻译后,用IE打开,结果没有错误信息,浏览器下方显示完成,但是页面空白,我想要显示的文字,按钮都没有,这是为什么那?
--  作者:admin
--  发布时间:4/29/2004 12:30:00 AM

--  
因为代码写错了呗..

贴出来让大家给你找找问题吧


--  作者:Cindylm
--  发布时间:4/29/2004 9:15:00 AM

--  
xml文件:
<?xml version="1.0" encoding="GB2312"?>
<?xml:stylesheet type="text/xsl" href="component.xsl"?>
<page>
 <head>
  <title>组件测试</title>
 </head>
 <body>
  <bgcolor>#66CCFF</bgcolor>

  <component>
   
   <ButtonType>
    <id>button1</id>
    <value>提示</value>
    <type>button</type>
    <onclickevent>have()</onclickevent>
   </ButtonType>
  </component>

  <component>
   
   <StaticTextType>
    <id>text1</id>
    <size>6</size>
    <content>测试成功</content>
   </StaticTextType>
  </component>

 </body>

</page>

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>
   <head>
    <title><xsl:value-of select="title"/></title>
   </head>
   
  
  
   <xsl:apply-templates select="body"/>
  
 </html>
</xsl:template>

<!--body模板-->
<xsl:template match="body">
 <body>
 <bgcolor><xsl:value-of select="bgcolor"/></bgcolor>
 <xsl:apply-templates select="component"/>
 </body>
</xsl:template>

<!--component模板-->
<xsl:template match="component">
    <xsl:for-each  select="*">
        <xsl:choose>
             <xsl:when test="starts-with(.,'Button')">
  <xsl:apply-templates  select="ButtonType"/>
             </xsl:when>
             <xsl:when test="starts-with(.,'StaticText')">
  <xsl:apply-templates  select=" StaticTextType"/>
             </xsl:when>
        </xsl:choose>
    </xsl:for-each>
</xsl:template>

<!--button模板-->
<xsl:template match="ButtonType">
   <xsl:element name="input">
       <xsl:attribute name="name"><xsl:value-of select="id"/>
       </xsl:attribute>
      <xsl:attribute name="type"><xsl:value-of select="type"/>
      </xsl:attribute>
      <xsl:attribute name="value"><xsl:value-of select="value"/>
      </xsl:attribute>
   </xsl:element>
</xsl:template>

<!--Text模板-->
<xsl:template match="StaticTextType">
   <xsl:element name="input">
       <xsl:attribute name="name"><xsl:value-of select="id"/>
       </xsl:attribute>
      <xsl:attribute name="size"><xsl:value-of select="size"/>
      </xsl:attribute>
      <xsl:attribute name="value"><xsl:value-of select="content"/>
      </xsl:attribute>
   </xsl:element>
</xsl:template>

</xsl:stylesheet>

问题出在哪儿呢。。。?


--  作者:sam
--  发布时间:4/29/2004 11:59:00 AM

--  
<?xml version="1.0" encoding="GB2312"?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!--根模板-->
<xsl:template match="/">
<html>
   <head>
    <title><xsl:value-of select="//title"/></title>
   </head>
   
  
  
   <xsl:apply-templates select="//body"/>
  
</html>
</xsl:template>

<!--body模板-->
<xsl:template match="body">
<body>
<bgcolor><xsl:value-of select="bgcolor"/></bgcolor>
<xsl:apply-templates select="component"/>
</body>
</xsl:template>

<!--component模板-->
<xsl:template match="component">
    <xsl:for-each  select="*">
        <xsl:choose>
             <xsl:when test="starts-with(.,'Button')">
  <xsl:apply-templates  select="ButtonType"/>
             </xsl:when>
             <xsl:when test="starts-with(.,'StaticText')">
  <xsl:apply-templates  select=" StaticTextType"/>
             </xsl:when>
        </xsl:choose>
    </xsl:for-each>
</xsl:template>

<!--button模板-->
<xsl:template match="ButtonType">
   <xsl:element name="input">
       <xsl:attribute name="name"><xsl:value-of select="id"/>
       </xsl:attribute>
      <xsl:attribute name="type"><xsl:value-of select="type"/>
      </xsl:attribute>
      <xsl:attribute name="value"><xsl:value-of select="value"/>
      </xsl:attribute>
   </xsl:element>
</xsl:template>

<!--Text模板-->
<xsl:template match="StaticTextType">
   <xsl:element name="input">
       <xsl:attribute name="name"><xsl:value-of select="id"/>
       </xsl:attribute>
      <xsl:attribute name="size"><xsl:value-of select="size"/>
      </xsl:attribute>
      <xsl:attribute name="value"><xsl:value-of select="content"/>
      </xsl:attribute>
   </xsl:element>
</xsl:template>

</xsl:stylesheet>


--  作者:Cindylm
--  发布时间:4/29/2004 3:04:00 PM

--  
标题显示的出来,但是页面仍然是空白的
--  作者:sam
--  发布时间:4/29/2004 3:33:00 PM

--  
<?xml version="1.0" encoding="GB2312"?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!--根模板-->
<xsl:template match="/">
<html>
   <head>
    <title><xsl:value-of select="//title"/></title>
   </head>
   
  
  
   <xsl:apply-templates select="//body"/>
  
</html>
</xsl:template>

<!--body模板-->
<xsl:template match="body">
<body>
<xsl:attribute name="bgcolor"><xsl:value-of select="bgcolor"/></xsl:attribute>
<xsl:apply-templates select="component"/>
</body>
</xsl:template>

<!--component模板-->
<xsl:template match="component">
    <xsl:for-each  select="*">
        <xsl:choose>
             <xsl:when test="starts-with(name(),'Button')">
  <xsl:apply-templates select="."/>
             </xsl:when>
             <xsl:when test="starts-with(name(),'StaticText')">
  <xsl:apply-templates select="."/>
             </xsl:when>

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

<!--button模板-->
<xsl:template match="ButtonType">
   <xsl:element name="input">
       <xsl:attribute name="name"><xsl:value-of select="id"/>
       </xsl:attribute>
      <xsl:attribute name="type"><xsl:value-of select="type"/>
      </xsl:attribute>
      <xsl:attribute name="value"><xsl:value-of select="value"/>
      </xsl:attribute>
   </xsl:element>
</xsl:template>

<!--Text模板-->
<xsl:template match="StaticTextType">
   <xsl:element name="input">
       <xsl:attribute name="name"><xsl:value-of select="id"/>
       </xsl:attribute>
      <xsl:attribute name="size"><xsl:value-of select="size"/>
      </xsl:attribute>
      <xsl:attribute name="value"><xsl:value-of select="content"/>
      </xsl:attribute>
   </xsl:element>
</xsl:template>

</xsl:stylesheet>


--  作者:wh010607
--  发布时间:4/29/2004 5:14:00 PM

--  
我以前也碰到这样的问题,大多因为Match定位错误,找不到数据所致
W 3 C h i n a ( since 2003 ) 旗 下 站 点
苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
62.500ms