Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xslt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xml 如何保持空白作为_Xml_Xslt_Printing_Xhtml_Xslt 1.0 - Fatal编程技术网

Xml 如何保持空白作为

Xml 如何保持空白作为,xml,xslt,printing,xhtml,xslt-1.0,Xml,Xslt,Printing,Xhtml,Xslt 1.0,我有如下xml元素 <requestBody type="String"><![CDATA[Today, the XXXXXXXX XXXXXXXXXX XXXX (#XXXXXXX) Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 15

我有如下xml元素

<requestBody type="String"><![CDATA[Today, the XXXXXXXX XXXXXXXXXX XXXX (#XXXXXXX) Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.

Thanks,

XXXXXXXXXX
Test Administrator

XXXXXXXX XXXXXXXXXX XXXX
#### Address
CITY, ST  12345
Direct:  123-123-1234
Main Office:   123-123-1234
Fax:   123-123-1234
E-mail:   XXXXXXXXXX



Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book, please visit www.WEBADDRESS.com<http://www.WEBADDRESS.com>.

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.]]>
</requestBody>

当我应用
时,它将删除此元素中的所有空格,并将连接的字符串打印为:

Today, the XXXXXXXX XXXXXXXXXX XXXX (#XXXXXXX) Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. Thanks, XXXXXXXXXX Test Administrator XXXXXXXX XXXXXXXXXX XXXX #### Address CITY, ST 12345 Direct: 123-123-1234 Main Office: 123-123-1234 Fax: 123-123-1234 E-mail: XXXXXXXXXX Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book, please visit www.WEBADDRESS.com<http://www.WEBADDRESS.com>. Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.
今天,XXXXXXXXXXXXXXXXXXXXXXXXXXXX(#XXXXXXXX)Lorem Ipsum只是印刷和排版行业的虚拟文本。自16世纪以来,Lorem Ipsum一直是行业标准的虚拟文本,当时一位不知名的印刷商拿起一个打印工具,将其拼凑成一本打印样本书。Lorem Ipsum只是印刷和排版行业的虚拟文本。自16世纪以来,Lorem Ipsum一直是行业标准的虚拟文本,当时一位不知名的印刷商拿起一个打印工具,将其拼凑成一本打印样本书。谢谢,XXXXXXXXXX考试管理员XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX。自16世纪以来,Lorem Ipsum一直是行业标准的虚拟文本。当一位不知名的印刷商拿起一个打印槽,将其拼凑成一本打印样本书时,请访问www.WEBADDRESS.com。Lorem Ipsum只是印刷和排版行业的虚拟文本。自16世纪以来,Lorem Ipsum一直是行业标准的虚拟文本,当时一位不知名的印刷商拿起一个打印工具,将其拼凑成一本打印样本书。
有人能告诉我如何在不删除空格的情况下获取元素内容吗


提前谢谢。

@Harishfysx,正如John Bollinger在评论中指出的那样,不清楚您是在描述实际的文件输出,还是在浏览器中的呈现——因为您包括
xhtml
标记,我们(读者)必须假设您可能在谈论浏览器屏幕呈现,它在一些重要的方面忽略了空格

如果您谈论的是文件输出,那么您的代码或XSL处理器正在做一些有趣的事情。如果我应用以下模板:

<xsl:template match="requestBody">
    <xsl:value-of select="."/>
</xsl:template>
<xsl:output method="text"/>
由于我可以很容易地生成保留空白的输出,因此我必须假设您的问题是而不是XSL,而是您的浏览器在默认浏览器模式下显示此文本,该模式折叠每个空白字符串(空格、制表符、换行符的多个实例)转换为单个空格字符


正如John所建议的,使用
元素,或者使用CSS定义
空白:pre,如果您希望在屏幕右端的线条处进行严格布局,或
空白:预换行,如果您希望保留空白,但浏览器换行太长,无法在页边距内显示。

您查看了吗?您没有提供格式良好的XML元素--没有开始标记,内容似乎应该包含CDATA节,但没有开始分隔符,也可以。无论如何,我认为你对问题的描述是错误的
xsl:value of
不会像您所描述的那样删除或压缩空白,但在大多数元素的主体中,一个或多个文本空白字符的所有运行意味着与[X]HTML中的单个空格相同。我认为您的问题是呈现问题,而不是XSLT问题。如果你需要保存文本格式,你可以考虑让你的转换把文本放进<代码> <代码>元素。它在开始时有标签。@ JunBurrnor,打开标签和CDATA启动在那里,但是格式化被边缘化了,所以它们没有渲染。我已经搞定了。谢谢你们,艾里克伦德,约翰·博林格和所有人……你们真是太棒了。
<xsl:output method="text"/>