我需要制作将生成 json 的 XSLT。
问题是我的 xml 中有<
和>
符号,需要在输出中用 <> 替换。但是 disable-output-escaping="yes" 使换行符,我可以删除这个换行符吗?
XML:
<item id="166" group="0">
<name>Some Titile</name>
<text><p>A dizzying array of deep, robust color, the Hugs and Kisses bouquet contains one dozen tulips and one dozen iris, fresh from the fields. It's an always-impressive bouquet perfect for a "dinner for two," a special someone's birthday, or anytime you want to make someone's heart race.</p></text>
</item>
我需要的输出
{
"name": "Some Title",
"text": "<p>A dizzying array of deep, robust color, the Hugs and Kisses bouquet contains one dozen tulips and one dozen iris, fresh from the fields. It's an always-impressive bouquet perfect for a "dinner for two," a special someone's birthday, or anytime you want to make someone's heart race.</p>;"
}
XSLT
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" encoding="UTF-8"/>
<xsl:template match="item">
{
"name": "<xsl:value-of select="name" />",
"text": "<xsl:value-of select="text" />"
}
</xsl:template>
</xsl:stylesheet>
输出
{
"name": "Some Title",
"text": "<p>A dizzying array of deep, robust color, the Hugs and Kisses bouquet contains one dozen tulips and one dozen iris, fresh from the fields. It's an always-impressive bouquet perfect for a "dinner for two," a special someone's birthday, or anytime you want to make someone's heart race<./p>;"
}