在 XML 中使用格式化标签
Use formatting tags in XML
下面是 XML 和 XSLT 文件的源代码,我得到的输出是 "Bold Text Italics Text" 粗体和斜体格式标记被忽略。我如何调整此代码以确保应用所有标签并且我的输出文本位于 bold/italic?
XML 文件 (text.xml)
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="test.xsl"?>
<examples>
<example><b>Bold Text</b> <i>Italics Text</i></example>
</examples>
XSL 文件 (test.xsl)
<xsl:template match="/">
<html>
<head>
<title>Title</title>
</head>
<body>
<xsl:value-of select="examples/example"/>
</body>
</html>
</xsl:template>
您应使用 xsl:copy-of
,因为输入格式是 example
的预期格式:
<xsl:template match="/">
<html>
<head>
<title>Title</title>
</head>
<body>
<xsl:copy-of select="examples/example"/>
</body>
</html>
</xsl:template>
下面是 XML 和 XSLT 文件的源代码,我得到的输出是 "Bold Text Italics Text" 粗体和斜体格式标记被忽略。我如何调整此代码以确保应用所有标签并且我的输出文本位于 bold/italic?
XML 文件 (text.xml)
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="test.xsl"?>
<examples>
<example><b>Bold Text</b> <i>Italics Text</i></example>
</examples>
XSL 文件 (test.xsl)
<xsl:template match="/">
<html>
<head>
<title>Title</title>
</head>
<body>
<xsl:value-of select="examples/example"/>
</body>
</html>
</xsl:template>
您应使用 xsl:copy-of
,因为输入格式是 example
的预期格式:
<xsl:template match="/">
<html>
<head>
<title>Title</title>
</head>
<body>
<xsl:copy-of select="examples/example"/>
</body>
</html>
</xsl:template>