XSL-FO, группировка элементов в таблицы
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="содержит (TraumaTriageCriteria, '(A)')" я получаю результат, подобный этому:
| МВД | AI | ПК | =============================================================== |(M) механизм: выброс | | | ------------------------------------------------------------------ |(M) механизм: летальность | | | ----------------------------------------------------------------- | |(A) натомический: дробленый |(P) физиологический: GCS | -------------------------------------------------------------------
но хотел бы, чтобы мой стол выглядел так:
| МВД | AI | ПК | ================================================= |(M) механизм: выброс | (A) натомический: измельченный |(P) физиологический: GCS | -------------------------------------------------
Любое предложение?
2 ответа
Ну, не глядя, я вижу, что 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-редактор и посмотреть на все ошибки и исправить их.
<!--TRAUMA TRIAGE-->
<xsl:if test="inc_incident/inc_situation/InjuryPresent = "Yes"">
<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>