我有xml中的命名空间问题(它是来自供应商的xml),以及如何在xsl上解决这个问题。namespace from xml in xsl template
我的XML:
<?xml version="1.0" encoding="utf-8"?>
<string xmlns="https://www.website.com/getdata/service/" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xmlresponse>
<header>
<reportinformation>
<time>27/06/2017 19:42:07</time>
<reporttype>getcompanyinformation</reporttype>
</reportinformation>
</header>
</xmlresponse>
</string>
我的XSL是
?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:my="https://www.website.com/getdat/service/">
<xsl:output indent="yes" method="xhtml" omit-xml-declaration="yes"/>
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:template match="/my:xmlresponse">
<html>
<head>
<title>www.website.com GetData XML Stylesheet</title>
</head>
<body>
<table>
<tr>
<td><span style="{$reporttitle}">GetData </span></td>
</tr>
<xsl:apply-templates select="my:reportinformation"/>
</table>
</body>
</html>
</xsl:template>
<xsl:template match="my:reportinformation">
<tr>
<td align="left">
<table style="{$datatable}">
<tr>
<td><span style="{$prompt}">Timestamp:</span></td>
<td><span style="{$data}"><xsl:value-of select="my:time"/></span></td>
</tr>
<tr>
<td><span style="{$prompt}">Report type:</span></td>
<td><span style="{$data}"><xsl:value-of select="my:reporttype"/></span></td>
</tr>
</table>
</td>
</tr>
</xsl:template>
问题我已经被显示来自模板reportinformation信息,但不匹配/显示来自主模板信息。
我不擅长xml,更多的是在前端。好朋友要正确转换什么?
我搜索SO和谷歌,但仍然或显示主要模板或子模板。
我做到了,但仍然没有工作。 我更新了代码 – maw2be
@ maw2be错误的文件。我在XSLT中说过。 此外,你能真正修改你的提供商给你的XML吗? – kumesana
抱歉,您的权利我编辑错误的文件。应该编辑xslt – maw2be