如何将HTML保存到我的XML中,然后使用XSL显示所述HTML?
我需要将一些HTML保存到XML文件中,然后通过XSL输出该HTML:如何将HTML保存到我的XML中,然后使用XSL显示所述HTML?,html,xml,xslt,Html,Xml,Xslt,我需要将一些HTML保存到XML文件中,然后通过XSL输出该HTML: <?xml version="1.0"?> <?xml-stylesheet type="text/xsl" href="http://mywebsite.com/sites/default/files/lesson_resource.xsl"?> <lesson_resource name="Verbs" type="vocabulary" help="<p>
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="http://mywebsite.com/sites/default/files/lesson_resource.xsl"?>
<lesson_resource name="Verbs" type="vocabulary" help="<p><span style="font-size:24px">Ask your teacher about this:</span></p> <p><u>Example:</u> <span style="color:#FF0000">Verbs</span></p> <p>I <span style="color:#FF0000">like </span>school.<br /> I <span style="color:#FF0000">eat </span>pizza.<br /> I<span style="color:#FF0000"> go</span> home.</p> <p><u>Description:</u></p> <p><span style="color:#FF0000">Verbs </span>are doing words.</p> ">
</lesson_resource>
目前我已经在Chrome上实现了这一点,但Firefox只打印实际的HTML,因为它不支持禁用输出转义:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" encoding="utf-8" indent="yes" />
<xsl:template match="/">
<html>
<head>
</head>
<body>
<xsl:for-each select="lesson_resource">
<div class="page">
<img src="../pictures/logo.png" style="height:100px; padding-right:20px;"/>
<h3 style="display:inline-block;"><xsl:value-of select="@name" /></h3>
<div style="float:right;">http://www.mywebsite.com</div>
<div><xsl:value-of select="@help" disable-output-escaping="yes"/></div>
</div>
</xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
我应该以不同的方式存储HTML吗?理想情况下,您应该将其存储为XHTML节点,而不是转义标记,然后您可以使用XSLT轻松处理节点。或者,通过扩展,您可以解释如何将转义字符串作为属性值进行存储吗?