这可能是一个非常简单的问题,但它似乎无法得到它并且正在撕裂我的头发.我有以下
XML:
<?xml-stylesheet type="text/xsl" href="email.xsl"?> <Example xmlns=""> <Name xmlns="urn:rnb.fulfilment.bus.contracts.public.exampleBookName.v1">Mark</Name> </Example>
我正在尝试使用以下XSLT:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > <xsl:template match="/"> <html> <body> <table width="90%" border="0" cellpadding="0" cellspacing="0"> <tr> <td> <p>AUTOMATED CONFIRMATION: This confirmation email is unable to take replies. For further assistance please visit our Help pages or Contact us</p> <p>Dear <xsl:value-of select="Name"/>,</p> <p>Thank you for blah blah... </p> </td> </tr> </table> <xsl:apply-templates/> </body> </html> </xsl:template> </xsl:stylesheet>
当我在XML Feed中使用xmlns = urn:rnb.fulfilment.bus.contracts.public.exampleBookName.v1时,我无法显示Name,当我删除xmlns时,名称显示正常.
我缺少一些语法吗?我已经尝试将名称空间添加到< xsl:stylesheet>元件:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:rpg="urn:rnb.fulfilment.bus.contracts.public.exampleBookName.v1" >
然后使用我在XPath表达式中给XSLT的前缀:
<xsl:value-of select="Name"/>
但这也不起作用.有人可以帮忙吗?提前致谢.
解决方法
或者使用谓词和本地名称().例如.:
<xsl:value-of select="*[local-name() = 'Name']"/>