So, I have this XML document that looks like any other, except it has links in it, which is also the issue. When I run xsl:value-of , I do get the value in itself but the text thats suppoed to become a hyperlink doesn't. How do I get this to work?
The XML code:
<Response>
<Reminders>
<Reminder>
<ReminderLong>Sample Text with a link <a href="http://google.com" target="_blank">here</a></ReminderLong>
</Reminder>
</Reminders>
</Response>
The current XSL code (tried a lot of different versions of this to try to get the links to work, but this is what I am sitting on right now, keep in mind I am very much a newbie at this) :
<xsl:for-each select="Response/Reminders/Reminder">
<p><xsl:value-of select="ReminderLong" /></p>
</xsl:for-each>
The XSL code binding stylesheets and whatnot
<?xml
version="1.0"
encoding="UTF-8"
?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
What I expect:
<p>Sample Text with a link <a href="http://google.com" target="_blank">here</a></p>
What it does:
<p>Sample Text with a link here</p>
答案 0 :(得分:1)
这是一种方式:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html"/>
<xsl:strip-space elements="*"/>
<xsl:template match="Reminder">
<p>
<xsl:apply-templates/>
</p>
</xsl:template>
<xsl:template match="a">
<xsl:copy-of select="."/>
</xsl:template>
</xsl:stylesheet>