0

XML:

<?xml version="1.0" encoding="utf-8"?>
<NewDataSet>
 <inc_incident>
  <inc_traumatriagecriteria>
    <TTC_ID>1    </TTC_ID>
    <TraumaTriageCriteria>(M)echanism: Ejection</TraumaTriageCriteria>
  </inc_traumatriagecriteria>
  <inc_traumatriagecriteria>
    <TTC_ID>2    </TTC_ID>
    <TraumaTriageCriteria>(M)echanism: Fatality</TraumaTriageCriteria>
  </inc_traumatriagecriteria>
  <inc_traumatriagecriteria>
    <TTC_ID>3    </TTC_ID>
    <TraumaTriageCriteria>(P)hysiologic: GCS</TraumaTriageCriteria>
  </inc_traumatriagecriteria>
  <inc_traumatriagecriteria>
    <TTC_ID>4    </TTC_ID>
    <TraumaTriageCriteria>(A)natomic: Crushed</TraumaTriageCriteria>
  </inc_traumatriagecriteria>
 </inc_incident>
</NewDataSet>

XSL:

<fo:table-body>
 <xsl:for-each select="inc_traumatriagecriteria">
  <fo:table-row>
   <fo:table-cell>
    <fo:block>
    <xsl:if test="contains(TraumaTriageCriteria, '(M)')">
      <xsl:value-of select="text()">    </xsl:value-of>
        </xsl:if>
   </fo:block>
    </fo:table-cell>
   <fo:block>
    <xsl:if test="contains(TraumaTriageCriteria, '(A)')">
   </xsl:if>
   </fo:block>
    </fo:table-cell>
   <fo:block>
     <xsl:if test="contains(TraumaTriageCriteria, '(P)')">
     </xsl:if>
   </fo:block>
</fo:table-cell>

使用 xsl:if test="contains(TraumaTriageCriteria, '(A)')" 我得到这样的结果:

| 语言 | 人工智能 | 电脑 |
==================================================== ==============
|(M)机构:弹射 | | |
-------------------------------------------------- ----------------
|(M)机制:致死性 | | |
-------------------------------------------------- ---------------
| |(A)解剖学:压碎 |(P)生理学:GCS |
-------------------------------------------------- -----------------

但希望我的桌子看起来像这样:

| 语言 | 人工智能 | 电脑 |
=================================================
|(M)机制:弹射|(A)解剖学:压碎|(P)生理学:GCS|
-------------------------------------------------

有什么建议吗?

4

2 回答 2

1

好吧,不用看,我发现您的 XSL 是错误的(请参阅以下文档副本中的注释):

  </fo:block>
  </fo:table-cell>
  <fo:block> <-- You are inserting a block with no table cell -->
   <xsl:if test="contains(TraumaTriageCriteria, '(A)')">
   </xsl:if> <-- No content in this if -->
   </fo:block>
   </fo:table-cell> <!-- No table cell created before this end table-cell -->
   <fo:block> <!-- again no table-cell here -->
   <xsl:if test="contains(TraumaTriageCriteria, '(P)')">
   </xsl:if> <!-- There is no content in this if -->
   </fo:block>
   </fo:table-cell> <!-- again no starting table-cell before this end -->

您应该将您的 FO 输出到一个漂亮的、符合解析标准的 XML 编辑器,并查看所有错误并更正它们。

于 2013-08-29T20:02:54.813 回答
0
                        <!--TRAUMA TRIAGE-->
          <xsl:if test="inc_incident/inc_situation/InjuryPresent = &quot;Yes&quot;">
            <xsl:for-each select="inc_incident">
              <fo:table start-indent="((8.5in - 0.5in - 0.5in) - 520pt) div 2" end-indent="((8.5in - 0.5in - 0.5in) - 520pt) div 2" background-color="silver" border-spacing="0" padding="0" text-align="center" width="520pt" table-layout="fixed" space-before.optimum="1pt" space-after.optimum="2pt">
                <fo:table-column />
                <fo:table-column />
                <fo:table-column />
                <fo:table-header>
                  <fo:table-row>
                    <fo:table-cell background-color="#5454A5" border-style="solid" border-width="1pt" border-color="silver" padding-start="0pt" padding-end="0pt" padding-before="0pt" padding-after="0pt" number-columns-spanned="3" text-align="center" display-align="center">
                      <fo:block>
                        <fo:inline color="white" font-family="Verdana, Arial, sans-serif" font-size="8pt" font-weight="bold">Trauma Triage</fo:inline>
                      </fo:block>
                    </fo:table-cell>
                  </fo:table-row>
                  <fo:table-row>
                    <fo:table-cell background-color="#eeeeee" border-style="solid" border-width="1pt" border-color="silver" padding-start="0pt" padding-end="0pt" padding-before="0pt" padding-after="0pt" display-align="center" text-align="center">
                      <fo:block>
                        <fo:inline font-family="Verdana, Arial, sans-serif" font-size="8pt" font-weight="bold">(M)echanism Of Injury</fo:inline>
                      </fo:block>
                    </fo:table-cell>
                    <fo:table-cell background-color="#eeeeee" border-style="solid" border-width="1pt" border-color="silver" padding-start="0pt" padding-end="0pt" padding-before="0pt" padding-after="0pt" display-align="center" text-align="center">
                      <fo:block>
                        <fo:inline font-family="Verdana, Arial, sans-serif" font-size="8pt" font-weight="bold">(A)natomic Injury(ies)</fo:inline>
                      </fo:block>
                    </fo:table-cell>
                    <fo:table-cell background-color="#eeeeee" border-style="solid" border-width="1pt" border-color="silver" padding-start="0pt" padding-end="0pt" padding-before="0pt" padding-after="0pt" display-align="center" text-align="center">
                      <fo:block>
                        <fo:inline font-family="Verdana, Arial, sans-serif" font-size="8pt" font-weight="bold">(P)hysiologic Criteria</fo:inline>
                      </fo:block>
                    </fo:table-cell>
                  </fo:table-row>
                </fo:table-header>
                <fo:table-body>
                  <xsl:for-each select="inc_traumatriagecriteria">
                    <fo:table-row>
                      <fo:table-cell background-color="white" border-style="solid" border-width="1pt" border-color="silver" padding-start="0pt" padding-end="0pt" padding-before="0pt" padding-after="0pt" display-align="center" text-align="start">
                        <fo:block>
                          <xsl:if test="contains(TraumaTriageCriteria, '(M)')">
                            <xsl:for-each select="TraumaTriageCriteria">
                              <fo:inline font-family="Verdana, Arial, sans-serif" font-size="8pt">
                                <xsl:apply-templates />
                              </fo:inline>
                            </xsl:for-each>
                          </xsl:if>
                        </fo:block>
                      </fo:table-cell>
                      <fo:table-cell background-color="white" border-style="solid" border-width="1pt" border-color="silver" padding-start="0pt" padding-end="0pt" padding-before="0pt" padding-after="0pt" display-align="center" text-align="start">
                        <fo:block>
                          <xsl:if test="contains(TraumaTriageCriteria, '(A)')">
                            <xsl:for-each select="TraumaTriageCriteria">
                              <fo:inline font-family="Verdana, Arial, sans-serif" font-size="8pt">
                                <xsl:apply-templates />
                              </fo:inline>
                            </xsl:for-each>
                          </xsl:if>
                        </fo:block>
                      </fo:table-cell>
                      <fo:table-cell background-color="white" border-style="solid" border-width="1pt" border-color="silver" padding-start="0pt" padding-end="0pt" padding-before="0pt" padding-after="0pt" display-align="center" text-align="start">
                        <fo:block>
                          <xsl:if test="contains(TraumaTriageCriteria, '(P)')">
                            <xsl:for-each select="TraumaTriageCriteria">
                              <fo:inline font-family="Verdana, Arial, sans-serif" font-size="8pt">
                                <xsl:apply-templates />
                              </fo:inline>
                            </xsl:for-each>
                          </xsl:if>
                        </fo:block>
                      </fo:table-cell>
                    </fo:table-row>
                  </xsl:for-each>
                </fo:table-body>
              </fo:table>
            </xsl:for-each>
          </xsl:if>
于 2013-09-05T23:34:30.110 回答