- xml - AJAX/Jquery XML 解析
- 具有多重继承的 XML 模式
- .net - 枚举序列化 Json 与 XML
- XML 简单类型、简单内容、复杂类型、复杂内容
这是 xml 文件。 “CategoryName”元素中的空格和回车是有意的。
<?xml version="1.0" encoding="utf-8"?>
<group>
<item>
<id>item 1</id>
<CategoryName>
</CategoryName>
</item>
<item>
<id>item 2</id>
<CategoryName></CategoryName>
</item>
<item>
<id>item 3</id>
<CategoryName> </CategoryName>
</item>
</group>
以下是上述 XML 文件的 XSLT 文件。它应该做的是清除“CategoryName”元素中的所有空白区域。然后,它将测试“CategoryName”是否为空。
<?xml version="1.0" encoding="utf-8"?>
<!-- DWXMLSource="testempty.xml" -->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" encoding="utf-8" doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/>
<xsl:strip-space elements="*" /> <!--HERE IS STRIP SPACE-->
<xsl:template match="/">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>Untitled Document</title>
</head>
<body>
<xsl:for-each select="/group/item">
<xsl:if test="CategoryName = ''"> <!--HERE IS THE TEST-->
<p>Empty</p> <!--IT WILL OUTPUT 'EMPTY' IF THE ELEMENT IS EMPTY-->
</xsl:if>
</xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
问题是,xsl:strip-space
没有发挥作用。只有项目 2 的“CategoryName”通过了“空”测试。
怎么了?
最佳答案
我不知道 Dreamweaver 使用的是什么 XSLT 引擎,但这看起来不对。
我认为可能有一些 XSLT 处理器只在您向它们提供未解析的输入(词法 XML)时才应用 xsl:strip-space,而在您向它们提供 DOM 时则不会。规范中没有任何内容可以证明这种行为是合理的,但它使实现者的生活变得更加轻松。
然而,值得指出的是,这不是 xsl:strip-space 的预期使用方式。它旨在用于去除“可忽略的”空白,即用于在纯元素内容中缩进的空白。如果您使用的是 XSLT 2.0 模式感知转换,这将成为规则:xsl:strip-space 不会影响具有简单内容的元素的内容。这是因为去除此类元素的空格可能会使该元素对架构无效。
关于xml - xsl :strip-space is not removing the carriage return,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14050522/
我该使用哪个工具在HL7文本文件中查找回车符,如何识别它? 谢谢。 最佳答案 使用Notepad++并打开“显示行尾”。 关于carriage-return - 如何在HL7消息中查看回车?,我们在S
我陷入无用答案的argument over on SuperUser.com中,发现自己正挑战另一位海报者以头脑 Storm 的方式回答问题。他没有让我接受,但是现在我很好奇。 程序要做的就是将CRL
我正在尝试理解回车符 (\r)。所以我写了下面的代码。如果我运行下面的代码,我得到的输出是“go”。 方法一: #include int main() { printf("chi\r
我使用的是Python2.7.13(在Kali 4.9.0AMD64中),并且我已经尝试了我能找到的print()语句的所有变体(使用未来正确的导入语句),每次都以换行符OK结束。以下是代码:。我试过
我有这样的邮件: Hello, Please note we did ... at 16h15 Actions done: Rebuilding etc sincerely Mr. 每封邮件中的操作都
关闭。这个问题需要details or clarity .它目前不接受答案。 想改进这个问题吗? 通过 editing this post 添加细节并澄清问题. 关闭 7 年前。 Improve t
我在通过 Ajax 请求加载的网页中使用文本区域。请求的结果是由 \n 分隔的数字列表 结果如下: 111000333 414141411 在 Chrome 中,它可以正常工作,但在 IE7 中,回
我有以下 bash 脚本: #!/bin/bash FILE="p.txt" while read line; do export http_proxy="http://$line"
我有一个包含换行符(“\r”)的传入文本字符串。 当我输出它时: System.out.println(myString) , 回车被解释。 但是,当我将字符串设置为标签的内容时,它会忽略回车。 如何
Windows 回车符是 \r\n,而 Unix 中回车符是 \n,\r\n 是否被视为两个字符? 最佳答案 这是两个字符: \r 为回车符; \n 是换行符。 两个字符组合起来代表 Windows
如果有两个关键字,那么它们必须有自己的含义。所以我想知道它们有何不同以及它们的代码是什么。 最佳答案 换行表示向前移动一行。代码为\n。 回车表示将光标移动到行首。代码为\r。 Windows 编辑器
我的 SQL08-R2 数据库中有一个 20 行的小表,其中有一个 nvarchar(max) 字段。在此字段中,我编写了带有各种 CR/LF 的文本(见下图): 出于某种原因,当我创建 RDL 文件
我正在尝试使用批处理文件从 .tsv 文件中删除回车符。这就是我的 .tsv 文件的样子,第一行是列行 * **[CR] 和 [LF] 这些行中显示的内容是手动添加的以获得想法 Class Nam
假设我有以下查询: insert into myTable values ("TEST 1 TEST 2") 然后我选择要输出到 Excel 工作表的描述: select description fr
我有一个很长的文本(实际上是一个 HTML 页面)(几乎是一整本书),其中有很多东西,包括一些代码。这些段落要么包含在“pre”标签中,要么包含在“code”标签中。最大的问题是有些线条太长了,当我打
事实如下: Wordpress 主题父级:Pytheas(我使用的是子主题) 网站:http://longgame.org 我是初学者。我仍在学习 CSS 的基础知识。 我的问题: 在首页上,有一组五
这是 xml 文件。 “CategoryName”元素中的空格和回车是有意的。 item 1 it
我创建了一个 PROC REPORT,其中有许多列位于输入数据集中,还有一些列在 COMPUTE block 中创建。有些列是使用 cats() 创建的,用于连接其他列的值等。 是否可以使用 ods
考虑以下代码,假设输入字符是“Z”,在 UNICODE 中等于 90。 //********************************* // Read a character from the
我有在远程 Linux 服务器上运行的 C++ 代码,可通过 MobaXterm 访问。这个过程需要一段时间并且是多线程的,所以我添加了一个进度打印机制,如下所示: void update_progr
我是一名优秀的程序员,十分优秀!