求各位大侠帮忙看看问题出在哪里

qq_36340418 2019-03-07 11:17:56
我自学XSLT,试着做了一个,但不出结果:
xml源文件:
<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/html" href="invoice_output.xmlt" ?>
<invoices xmlns="http://www.huachuangandchengyuan.com/invoice">
<invoice>
<beneficiary>Lu Yan</beneficiary>
<items>
<item>
<item_name>gas</item_name>
<item_amount>370</item_amount>
</item>
</items>
<invoice_date>2019-02-13</invoice_date>
<application_date>2019-02-02</application_date>
</invoice>
</invoices>

xslt转换文件:
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
<xsl:output method="text"/>
<xsl:template match="/">
<html><head><title>This is a test for the invoice output.</title></head>
<body>
<h1>
<xsl:value-of select="/invoices/invoice/beneficiary"/>
</h1>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

我期待的结果是:
<html>
<head>
<title>This is a test for the invoice output.</title>
</head>
<body>
<h1>Lu Yan</h1>
</body>
</html>

而实际结果是
<html>
<head>
<title>This is a test for the invoice output.</title>
</head>
<body>
</h1>
</body>
</html>

请高手帮帮看看为什么<xsl:value-of select="/invoices/invoice/beneficiary"/>提取不了元素的值?
...全文
25 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

8,906

社区成员

发帖
与我相关
我的任务
社区描述
XML/XSL相关问题讨论专区
社区管理员
  • XML/XSL社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧