关于xsl解析的问题
<?xml version="1.0" encoding="UTF-16" ?>
<root>
<ID ID="00000">
<struct classid="1085288449" aliasoffset="0">
<info mbrid="0">Microsoft XML 分析程序和 SDK</info>
<info mbrid="1">
<detail mbrid="0">2005</detail>
-
<detail mbrid="1">10</detail>
-
<detail mbrid="2">24</detail>
</info>
<info mbrid="2">4.10.9406.0</info>
<info mbrid="3">Microsoft Corporation</info>
<info mbrid="4">C:\</info>
<info mbrid="5">{3E908702-AF35-4611-9518-955DA24B7E07}</info>
</struct>
<struct classid="1085288449" aliasoffset="0">
<info mbrid="0">Microsoft Text-to-Speech Engine</info>
<info mbrid="5">MSTTS</info>
</struct>
</ID>
</root>
因为两个struct的内容不同,第二个比第一个少几个info,但是两个struct下面的info对应的意思是一样的,mbrid=0都代表程序名称,mbrid=5代表说明。
问题是,怎么在for-each的时候,正确的取得相应的info?
我的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="root">
<html>
<head>
<title>汇总</title>
</head>
<body>
<table cellpadding="0" cellspacing="0" >
<tr>
<th width="100px">程序名称</th>
<th width="100px">安装日期</th>
<th width="100px">程序版本</th>
<th width="100px">公司</th>
<th width="100px">安装目录</th>
<th width="100px">程序说明</th>
</tr>
<xsl:for-each select="ID/struct">
<tr>
<td width="150px"><xsl:value-of select="这里该怎么写?"/></td>
<td width="150px"><xsl:value-of select="这里该怎么写?"/></td>
<td width="150px"><xsl:value-of select="这里该怎么写?"/></td>
<td width="150px"><xsl:value-of select="这里该怎么写?"/></td>
<td width="150px"><xsl:value-of select="这里该怎么写?"/></td>
<td width="150px"><xsl:value-of select="这里该怎么写?"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
由于刚接触xsl,所以还请大家帮忙,谢谢!分不够可以再加
<root>
<ID ID="00000">
<struct classid="1085288449" aliasoffset="0">
<info mbrid="0">Microsoft XML 分析程序和 SDK</info>
<info mbrid="1">
<detail mbrid="0">2005</detail>
-
<detail mbrid="1">10</detail>
-
<detail mbrid="2">24</detail>
</info>
<info mbrid="2">4.10.9406.0</info>
<info mbrid="3">Microsoft Corporation</info>
<info mbrid="4">C:\</info>
<info mbrid="5">{3E908702-AF35-4611-9518-955DA24B7E07}</info>
</struct>
<struct classid="1085288449" aliasoffset="0">
<info mbrid="0">Microsoft Text-to-Speech Engine</info>
<info mbrid="5">MSTTS</info>
</struct>
</ID>
</root>
因为两个struct的内容不同,第二个比第一个少几个info,但是两个struct下面的info对应的意思是一样的,mbrid=0都代表程序名称,mbrid=5代表说明。
问题是,怎么在for-each的时候,正确的取得相应的info?
我的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="root">
<html>
<head>
<title>汇总</title>
</head>
<body>
<table cellpadding="0" cellspacing="0" >
<tr>
<th width="100px">程序名称</th>
<th width="100px">安装日期</th>
<th width="100px">程序版本</th>
<th width="100px">公司</th>
<th width="100px">安装目录</th>
<th width="100px">程序说明</th>
</tr>
<xsl:for-each select="ID/struct">
<tr>
<td width="150px"><xsl:value-of select="这里该怎么写?"/></td>
<td width="150px"><xsl:value-of select="这里该怎么写?"/></td>
<td width="150px"><xsl:value-of select="这里该怎么写?"/></td>
<td width="150px"><xsl:value-of select="这里该怎么写?"/></td>
<td width="150px"><xsl:value-of select="这里该怎么写?"/></td>
<td width="150px"><xsl:value-of select="这里该怎么写?"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
由于刚接触xsl,所以还请大家帮忙,谢谢!分不够可以再加
...全文
相关推荐
java XSL解析器
同时,熟悉Java的异常处理机制,以便在遇到问题时能够正确地捕获和处理错误。
解锁Windows下Composer切换PHP版本的奥秘
本文围绕 Windows 系统下 Composer 切换 PHP 版本展开,先阐述 Composer 与 PHP 版本关系的重要性,强调不同 PHP 版本特性及第三方库要求导致切换版本的必要性。接着说明查看当前 PHP 和 Composer 版本的方法,介绍安装多 PHP 版本的工具与方式,以及环境变量的作用。随后详细讲解切换 PHP 版本的步骤,包括修改系统环境变量、验证切换结果及配置 Composer 使用新 PHP 版本。还列举了可能遇到的问题及解决方案,最后总结关键步骤并建议定期更新相关版本。
XSL Split
XSL样式表中的模板匹配和计数器等机制可以实现这样的功能。XSL Split工具通常包含以下核心组件:1. XML解析器:读取XML输入文件并将其解析为内存中的数据结构。2.
网页XSL基础教程,支持XML和XSL
#### 五、总结通过对XSL的学习,我们可以有效地处理XML文档,使其适应不同的显示需求。无论是浏览器端还是服务器端的转换,XSL都是一个强大的工具,能够帮助我们解决多种问题。
XML+XSL 与 HTML 两种方案的结合
在 CSDN 论坛中,使用 XML+XSL 方式可以实现一些复杂的功能,如支持 UBB 等,但也存在一些缺点,如客户端解析 XML+XSL 的问题等。

