-
12-10-2019 - |
题
我要删除所有空格,因此我的最终代码看起来像一个文本块。
这是我的标题
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml"
doctype-public="-W3CDTD XHTML 1.0 Strict//EN"
doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
omit-xml-declaration="yes"
encoding="UTF-8"
indent="no" />
这似乎大部分时间都起作用,但是我有问题。看 资源
有问题的区域似乎是
<!-- clinical research coordinator -->
<xsl:template match="clinical-research-coordinators">
<xsl:variable name="id" select="item/@id" />
<xsl:variable name="entry" select="//people/entry[@id=$id]" />
<xsl:value-of select="$entry/display-name" />,
clinical research coordinator, at
<xsl:element name="a">
<xsl:attribute name="href">mailto:<xsl:value-of select="$entry/email" /></xsl:attribute>
<xsl:attribute name="class">email</xsl:attribute>
<xsl:value-of select="$entry/email" />
</xsl:element>
or
<xsl:value-of select="$entry/phone" />
</xsl:template>
我正在使用交响乐CSM生成数据。我只希望将所有空格删除,但我想保留我的凹痕模式以进行可读性。
解决方案
有问题的区域似乎是
<!-- clinical research coordinator -->
<xsl:template match="clinical-research-coordinators">
<xsl:variable name="id" select="item/@id" />
<xsl:variable name="entry" select="//people/entry[@id=$id]" />
<xsl:value-of select="$entry/display-name" />, clinical research coordinator, at
<xsl:element name="a">
<xsl:attribute name="href">mailto:
<xsl:value-of select="$entry/email" />
</xsl:attribute>
<xsl:attribute name="class">email</xsl:attribute>
<xsl:value-of select="$entry/email" />
</xsl:element>
or
<xsl:value-of select="$entry/phone" />
</xsl:template>
解决方案是:
<!-- clinical research coordinator -->
<xsl:template match="clinical-research-coordinators">
<xsl:variable name="id" select="item/@id" />
<xsl:variable name="entry" select="//people/entry[@id=$id]" />
<xsl:value-of select="$entry/display-name" />, clinical research coordinator, at <xsl:text/>
<xsl:element name="a">
<xsl:attribute name="href">mailto:
<xsl:value-of select="$entry/email" />
</xsl:attribute>
<xsl:attribute name="class">email</xsl:attribute>
<xsl:value-of select="$entry/email" />
</xsl:element>
<xsl:text> or </xsl:text>
<xsl:value-of select="$entry/phone" />
</xsl:template>
请注意: :使用 <xsl:text>
指令消除现有的空格字符并明确指定应准确输出的文本。
其他提示
从 http://www.w3.org/tr/xslt#strip
在构建了源文档或样式表文档的树之后,但是在XSLT处理其他情况下,将剥离一些文本节点。除非仅包含空格字符,否则文本节点永远不会被剥离。
这个
",
clinical research coordinator, at
"
和
"
or
"
不仅仅是短文节点,那么它们不应从样式表中进行条纹。
这就是为什么 xsl:text
指示是为了。利用:
<xsl:text>, clinical research coordinator, at </xsl:text>
和
<xsl:text> or </xsl:text>
不隶属于 StackOverflow