Css 如何使用XSL在XML中的特定td中保留新行和空白

Css 如何使用XSL在XML中的特定td中保留新行和空白,css,xml,xslt,Css,Xml,Xslt,我试图仅为使用XSL在XML中具有随机id的特定td保留新行和空白 所以基本上我想在td中保留新行,它有一些大文本,如下所示 <?xml version="1.0" encoding="utf-8"?> <?xml-stylesheet type='text/xsl' href=new.xsl'?> <document> <div> <table width="100%" border="1">

我试图仅为使用XSL在XML中具有随机id的特定td保留新行和空白

所以基本上我想在td中保留新行,它有一些大文本,如下所示

<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type='text/xsl' href=new.xsl'?>
  <document>
    <div>
      <table width="100%" border="1">
        <thead>
          <tr>
            <th>ID</th>
            <th>Date</th>
            <th>Data Source</th>
          </tr>
        </thead>
        <tbody>
          <tr>
            <td>123123</td>
            <td>03/20/2018 04:49:40 PM MST</td>
            <td>Test Source</td>
          </tr>
          <tr>
            <td id="random_id_notes" colspan="3">Patient Information Name: Test, FIRST NAME Age: 108 Years DOB: 01/11/1911 Sex: Female First Para# Him boisterous invitation dispatched had connection inhabiting projection. By mutual an mr danger garret edward an. Diverted as strictly exertion
              addition no disposal by stanhill. This call wife do so sigh no gate felt. You and abode spite order get. Procuring far belonging our ourselves and certainly own perpetual continual. It elsewhere of sometimes or my certainty. Lain no as five
              or at high. Everything travelling set how law literature. Sec para# But why smiling man her imagine married. Chiefly can man her out believe manners cottage colonel unknown. Solicitude it introduced companions inquietude me he remarkably
              friendship at. My almost or horses period. Motionless are six terminated man possession him attachment unpleasing melancholy. Sir smile arose one share. No abroad in easily relied an whence lovers temper by. Looked wisdom common he an be
              giving length mr. Good #Third Para Home Call park out she wife face mean. Invitation excellence imprudence understood it continuing to. Ye show done an into. Fifteen winding related may hearted colonel are way studied. County suffer twenty
              or marked no moment in he. Meet shew or said like he. Valley silent cannot things so remain oh to elinor. Far merits season better tended any age hunted.

            </td>
          </tr>
        </tbody>
      </table>
    </div>
  </document>

如果希望保留空白,我将避免使用
indent=“yes”

在XSLT 3.0中,您可以使用
suppress indentation=“td”
覆盖特定元素类型的indent=“yes”,但即使这样,您也无法对特定元素实例执行此操作

然而,我不是100%确定这是你的问题。事实上,我不是100%确定我理解你的要求。您是否希望XML中每行文本开头的12个空格在呈现的HTML中可见

其他一些评论:

(a) 我不知道“n1”名称空间前缀想要实现什么

(b) 禁用输出转义不是魔法仙子灰尘。除非你确切知道它的作用,否则不要使用它。在您的特定情况下,没有什么可以转义的,因此禁用转义没有任何效果


(c) 在XML中使用
mm/dd/yyyy
日期会给您的生活带来不必要的困难。

您能提供一些输入XML和xslt的优化源吗?感谢您提供您的想法1。“n1”是公司使用的名称空间,我实际上想做的是在这张图片中,您显示的图像中的文本似乎与您的XML输入没有什么关系。@VimalTom按照Kay博士的想法,如果您用于显示需求的图像来自HTML页面,那么您将需要一个元素
<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:n1="urn:hl7-org:v3" xmlns:in="urn:lantana-com:inline-variable-data" xmlns:sdtc="urn:hl7-org:sdtc">
    <xsl:output method="html" indent="yes" version="4.01" encoding="ISO-8859-1" doctype-system="http://www.w3.org/TR/html4/strict.dtd" doctype-public="-//W3C//DTD HTML 4.01//EN"/>
    <xsl:template match="n1:td">
            <span class="content_span">
                <xsl:apply-templates select="@styleCode"/>
                  <xsl:value-of select="." disable-output-escaping="yes"/>
            </span>
        </xsl:template>
 .content_span{
 font-family: Verdana, Tahoma, sans-serif; 
 display: inline; 
 white-space: pre;
}