【发布时间】:2012-07-19 15:02:27
【问题描述】:
我需要制作将生成 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>;"
}
【问题讨论】:
-
请编辑问题并提供足够的信息,以便每个人都可以重现问题。除了 XML 文档和想要的结果,我们还需要:1. 完整的 XSLT 代码(尽可能小),2. 您得到的实际结果。