以文本方式查看主题

-  中文XML论坛 - 专业的XML技术讨论区  (http://bbs.xml.org.cn/index.asp)
--  『 XSL/XSLT/XSL-FO/CSS 』  (http://bbs.xml.org.cn/list.asp?boardid=8)
----  为什么吗缺少所需的属性 'select'?  (http://bbs.xml.org.cn/dispbbs.asp?boardid=8&rootid=&id=13439)


--  作者:yaoxin
--  发布时间:1/10/2005 10:46:00 PM

--  为什么吗缺少所需的属性 'select'?
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
 <xsl:template  match="/">
  <xsl:apply-templates select="唐诗/五言绝句"/>
 </xsl:template>
 <xsl:template match="唐诗/五言绝句">
  <xsl:apply-templates select="标题"/>
  <br/>
  <xsl:apply-templates select="作者"/>
  <xsl:apply-templates select="作者/@字号"/>
  <br/>
  <xsl:apply-templates select="内容"/>
 </xsl:template>
 <xsl:template match="标题">
  <xsl:value-of select="*" />
 </xsl:template>
 <xsl:template match="作者">
  作者:<xsl:value-of  select="*"/>
 </xsl:template>
 <xsl:template match="作者/@字号">
  字号:<xsl:value-of  select="*"/>
 </xsl:template>
 <xsl:template match="内容">
  <xsl:value-of  select="*"/>
 </xsl:template>
 
</xsl:stylesheet>
<?xml version="1.0" encoding="GB2312"?>
<?xml-stylesheet type="text/xsl" href="xsl93-5.xsl"?>
<唐诗>
 <五言绝句>
  <作者 字号="太白">李白</作者>
  <标题>静夜思</标题>
  <内容>
   床前明月光,疑是地上霜。
   举头望明月,低头思故乡。
  </内容>
 </五言绝句>
 <五言绝句>
  <作者 字号="太白">李白</作者>
  <标题>春晓</标题>
  <内容>
   春眠不觉晓,处处闻啼鸟。
   夜来风雨声,花落知多少。
  </内容>
 </五言绝句>
 <五言绝句>
  <作者 字号="季凌">王之涣</作者>
  <标题>登黄鹳楼</标题>
  <内容>
   白日依山尽,黄河入海流。
   欲穷千里目,更上一层楼。
  </内容>
 </五言绝句>
</唐诗>
提示错误:缺少所需的属性 'select'。 请教各位大师

--  作者:mailtolily
--  发布时间:1/11/2005 3:05:00 PM

--  
是你所用的encoding不能显示中文的原因。
你把utf-8修改为gb2312.
--  作者:hyl_fr
--  发布时间:1/14/2005 8:27:00 PM

--  
好像xsl程序写的有问题啊!
--  作者:菜籽
--  发布时间:1/16/2005 12:09:00 PM

--  
<?xml version="1.0" encoding="GBK"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
<xsl:template  match="/">
  <xsl:apply-templates select="唐诗/五言绝句"/>
</xsl:template>
<xsl:template match="唐诗/五言绝句">
  <xsl:apply-templates select="标题"/>
  <br/>
  <xsl:apply-templates select="作者"/>
  <xsl:apply-templates select="作者/@字号"/>
  <br/>
  <xsl:apply-templates select="内容"/>
</xsl:template>
<xsl:template match="标题">
  <xsl:value-of select="." />
</xsl:template>
<xsl:template match="作者">
  作者:<xsl:value-of  select="*"/>
</xsl:template>
<xsl:template match="作者/@字号">
  字号:<xsl:value-of  select="."/>
</xsl:template>
<xsl:template match="内容">
  <xsl:value-of  select="."/>
</xsl:template>

</xsl:stylesheet>

--  作者:菜籽
--  发布时间:1/16/2005 12:10:00 PM

--  
这是输出结果不知是不是你要的:
静夜思
作者: 字号:太白
床前明月光,疑是地上霜。 举头望明月,低头思故乡。 春晓
作者: 字号:太白
春眠不觉晓,处处闻啼鸟。 夜来风雨声,花落知多少。 登黄鹳楼
作者: 字号:季凌
白日依山尽,黄河入海流。 欲穷千里目,更上一层楼。
W 3 C h i n a ( since 2003 ) 旗 下 站 点
苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
46.875ms