我是新手。我有以下xml
:使用XSLT格式化文本
<text>
<sentence type="grocery">I bought <fruit> apples</fruit> at the grocery store.</sentence>
<sentence type="grocery">I also bought <fruit> bananas</fruit> at the store.</sentence>
<sentence>Then, I bought a basket at another store.</sentence>
</text>
我怎樣才能在下面的格式(the fruits should be red or different color)
顯示的文字:
"I bought <font color="red">apples</font> at the grocery store."
"I also bought <font color="red">bananas</font> at the story."
這裏是xsl:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:for-each select="text/sentence">
<p><p> <xsl:value-of select="descendant-or-self::node()[contains(.,'')]" /></p>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
感謝。
嗯,這是目標格式,HTML,PDF,東西else_瞭解如何在目標格式的文本一種特定的顏色標記,然後簡單地編寫模板包含正確標記的 ... xsl:template>。 –
目標格式爲HTML。 –
然後檢查任何基本的HTML和CSS教程,以標記具有特定顏色的元素https://developer.mozilla.org/en-US/docs/Learn/CSS/Styling_text/Fundamentals#Color –