filemaker xml 导出和保留文本
filemaker xml export and preserve text
我从 Filemaker 导出的 xml 用于提供 InDesign 模板。
我不想在 InDesign 文档中避免回车 returns。
经过一些研究,我找到了一个解决方案,用
Substitute ( textfield ; "¶" ; "
" )
(InDesign 会在 return 中给出可爱的 'soft returns'。)
当我将记录导出为纯文本时,它会被保留,但到 xml 它会变成


我的结论是编码问题。是吗?
我尝试了不同的编码但没有结果。
解决办法是什么?
如何将纯文本强制写入 xml 文件?
谢谢你
n
已添加:
xslt模板的header:
<?xml version='1.0' encoding='utf-8'?>
<xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform' xmlns:fm="http://www.filemaker.com/fmpdsoresult" exclude-result-prefixes="fm">
<xsl:output version='1.0' encoding='utf-8' indent='yes' method='xml' />
<xsl:template match="/">
您可能在使用 utf-16 时遇到了问题。根据 this post,您可以轻松导出 XML 指定 XSLT 文档以强制输出内容为 utf-8。这是引用 post:
中的 xslt 模板
<?xml version="1.0" encoding="UTF-8" ?>
<!--
Beverly Voth
beverlyvoth@gmail.com
SEP 2012
# this XSLT will work with any version of FileMaker that uses the
# FMPXMLRESULT grammar as export.
# Use with one record - one field to preserve the UTF-8.
# Alternate for Export Field Contents, which is UTF-16.
-->
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fm="http://www.filemaker.com/fmpxmlresult"
exclude-result-prefixes="fm">
<xsl:output method="text" />
<xsl:variable name="row" select="fm:FMPXMLRESULT/fm:RESULTSET/fm:ROW[1]" />
<xsl:template match="/">
<xsl:copy-of select="$row/fm:COL/fm:DATA[1]" />
</xsl:template>
</xsl:stylesheet>
My conclusion that is an encoding issue. Is it?
不,不是。
问题是您试图欺骗 Filemaker 的 XML 导出逻辑,但它不会让您这么做。如果你想让字段包含一个字符,你必须在计算中使用字符本身,而不是它的十六进制代码(这在 Filemaker 中是没有意义的)。这意味着:
Substitute ( textfield ; ¶ ; Char ( 8232 ) )
另一种选择是通过以下方式在 XSLT 样式表中执行此操作:
<xsl:value-of select="translate(., '
', '
')"/>
这样做的好处是可以在样式表中保留所有与导出相关的逻辑,并且不会为解决方案增加没有内部用途的额外字段。
我从 Filemaker 导出的 xml 用于提供 InDesign 模板。 我不想在 InDesign 文档中避免回车 returns。 经过一些研究,我找到了一个解决方案,用
Substitute ( textfield ; "¶" ; "
" )
(InDesign 会在 return 中给出可爱的 'soft returns'。) 当我将记录导出为纯文本时,它会被保留,但到 xml 它会变成
&#x2028;
我的结论是编码问题。是吗? 我尝试了不同的编码但没有结果。 解决办法是什么? 如何将纯文本强制写入 xml 文件? 谢谢你 n
已添加: xslt模板的header:
<?xml version='1.0' encoding='utf-8'?>
<xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform' xmlns:fm="http://www.filemaker.com/fmpdsoresult" exclude-result-prefixes="fm">
<xsl:output version='1.0' encoding='utf-8' indent='yes' method='xml' />
<xsl:template match="/">
您可能在使用 utf-16 时遇到了问题。根据 this post,您可以轻松导出 XML 指定 XSLT 文档以强制输出内容为 utf-8。这是引用 post:
中的 xslt 模板<?xml version="1.0" encoding="UTF-8" ?>
<!--
Beverly Voth
beverlyvoth@gmail.com
SEP 2012
# this XSLT will work with any version of FileMaker that uses the
# FMPXMLRESULT grammar as export.
# Use with one record - one field to preserve the UTF-8.
# Alternate for Export Field Contents, which is UTF-16.
-->
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fm="http://www.filemaker.com/fmpxmlresult"
exclude-result-prefixes="fm">
<xsl:output method="text" />
<xsl:variable name="row" select="fm:FMPXMLRESULT/fm:RESULTSET/fm:ROW[1]" />
<xsl:template match="/">
<xsl:copy-of select="$row/fm:COL/fm:DATA[1]" />
</xsl:template>
</xsl:stylesheet>
My conclusion that is an encoding issue. Is it?
不,不是。
问题是您试图欺骗 Filemaker 的 XML 导出逻辑,但它不会让您这么做。如果你想让字段包含一个字符,你必须在计算中使用字符本身,而不是它的十六进制代码(这在 Filemaker 中是没有意义的)。这意味着:
Substitute ( textfield ; ¶ ; Char ( 8232 ) )
另一种选择是通过以下方式在 XSLT 样式表中执行此操作:
<xsl:value-of select="translate(., '
', '
')"/>
这样做的好处是可以在样式表中保留所有与导出相关的逻辑,并且不会为解决方案增加没有内部用途的额外字段。