请指教一个入门的问题
我刚学xml,看书上说显示xml文件有两种方法
第一种方法用xlst文件转换文件,用xalan 工具+xlst文件把xml文件转换成html文件然后用浏览器查看。我下载了一个Xalan-C_1_5-win32好象里边有原文件但一执行就出错误说缺动态连接库xerces-c_2_2_0D.dll
第二种方法是把xlst和xml放在一个文件中让支持xml的浏览器自己去解析,但我不知道现在那种浏览器支持这种方式。
请各位指点指点,如何用xalan,那种浏览器可以直接解析xml?
谢谢
问题点数:20、回复次数:3Top
1 楼tianlinyi(笨蛋)回复于 2003-06-02 20:16:07 得分 10
XML文档:
<results group="A">
<match>
<date>10-Jun-1998</date>
<team score="2">Brazil</team>
<team score="1">Scotland</team>
</match>
<match>
<date>23-Jun-1998</date>
<team score="0">Scotland</team>
<team score="3">Morocco</team>
</match>
</results>
XSLT:
<xsl:transform
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="results">
<html>
<head><title>
Results of Group <xsl:value-of select="@group">
</title></head>
<body><h1>
Results of Group <xsl:value-of select="@group">
</h1>
<xsl:apply-templates>
</body></html>
</xsl:template>
<xsl:template match="match">
<h2>
<xsl:value-of select="team[1]"> versus <xsl:value-of select="team[2]">
</h2>
<p>Played on <xsl:value-of select="date"></p>
<p>Result:
<xsl:value-of select="team[1] ">
<xsl:value-of select="team[1]/@score">,
<xsl:value-of select="team[2] ">
<xsl:value-of select="team[2]/@score">
</p>
</xsl:template>
</xsl:transform>
在xml文档中使用<?xml stylesheet="样式表的文件路径">引用样式表就ok了,就象http页面里引用css文件一样
Top
2 楼MikeWKL(星星之盾)回复于 2003-06-02 22:58:32 得分 10
xml文档
<?xml version="1.0" standalone="yes"?>
<?xml-stylesheet type="text/css" href="www1.css"?>
<document>
<name>Mike</name>
<sex>男</sex>
<birth>1980.01.12</birth>
</document>
www1.css文件
document {font-size: 14pt; background-color: white; color: black; display: block}
name {display: block; font-size: 32pt; font-weight: bold; text-align: center}
sex {display: block; font-size: 30pt; font-weight: bold; text-align: center}
birth {display: block; font-size: 28pt; font-weight: bold; text-align: center}
在IE上就可以看到效果了。Top
3 楼qianfang(qianfang)回复于 2003-06-03 10:27:13 得分 0
多谢两位,我知道这个意思了Top




