1

我正在使用 CCD XML 文档,它包含如下数据:

<tr ID="encounter17" >
    <td>09/18/2012</td>
    <td ID="type41">Office Visit</td>
    <td>Family Practice</td>
    <td>
        <paragraph>REDACTED</paragraph>
    </td>
    <td />
</tr>
<tr ID="encounter18" styleCode="altRow">
    <td>09/17/2012</td>
    <td ID="type42">Office Visit</td>
    <td>Family Practice</td>
    <td>
        <paragraph>REDACTED</paragraph>
    </td>
    <td />
</tr>

我正在尝试使用“标准”CCD.xsl 将其呈现为 HTML,Derived from HL7 Finland R2 Tyylitiedosto: Tyyli_R2_B3_01.xslt Updated by Calvin E. Beebe, Mayo Clinic - Rochester Mn.

带有 IDencounter17的元素会渲染,带有 ID 的元素encounter18不会渲染。查看输出xsltproc是因为 XSLT 无法识别该styleCode属性。仅Bold, Italic, Underline受支持。

如何更改此 XSLT 以使其容忍未知的 styleCode?

<!--    Stylecode processing
  Supports Bold, Underline and Italics display-->
<xsl:template match="//n1:*[@styleCode]">

<xsl:if test="@styleCode='Bold'">
    <xsl:element name='b'>
        <xsl:apply-templates/>
    </xsl:element>
</xsl:if>

<xsl:if test="@styleCode='Italics'">
    <xsl:element name='i'>
        <xsl:apply-templates/>
    </xsl:element>
</xsl:if>

<xsl:if test="@styleCode='Underline'">
    <xsl:element name='u'>
        <xsl:apply-templates/>
    </xsl:element>
</xsl:if>

<xsl:if test="contains(@styleCode,'Bold') and contains(@styleCode,'Italics') and not (contains(@styleCode, 'Underline'))">
    <xsl:element name='b'>
        <xsl:element name='i'>
            <xsl:apply-templates/>
        </xsl:element>
    </xsl:element>
</xsl:if>

<xsl:if test="contains(@styleCode,'Bold') and contains(@styleCode,'Underline') and not (contains(@styleCode, 'Italics'))">
    <xsl:element name='b'>
        <xsl:element name='u'>
            <xsl:apply-templates/>
        </xsl:element>
    </xsl:element>
</xsl:if>

<xsl:if test="contains(@styleCode,'Italics') and contains(@styleCode,'Underline') and not (contains(@styleCode, 'Bold'))">
    <xsl:element name='i'>
        <xsl:element name='u'>
            <xsl:apply-templates/>
        </xsl:element>
    </xsl:element>
</xsl:if>

<xsl:if test="contains(@styleCode,'Italics') and contains(@styleCode,'Underline') and contains(@styleCode, 'Bold')">
    <xsl:element name='b'>
        <xsl:element name='i'>
            <xsl:element name='u'>
                <xsl:apply-templates/>
            </xsl:element>
        </xsl:element>
    </xsl:element>
</xsl:if>

我已经尝试添加:

<xsl:if test="not (contains(@styleCode,'Italics')) and not (contains(@styleCode,'Underline')) and not (contains(@styleCode, 'Bold'))">
    <xsl:apply-templates/>
</xsl:if>

这似乎只是呈现元素,它不会“落入”处理<tr>标签的 XSLT 部分。

4

1 回答 1

2

多么可怕的代码!在 2.0 中,您希望这样做:

<xsl:template match="n1:*[contains(@styleCode,'Bold')]" priority="100">
  <b><xsl:next-match/></b>
</xsl:template>

<xsl:template match="n1:*[contains(@styleCode,'Italic')]" priority="99">
  <i><xsl:next-match/></i>
</xsl:template>

<xsl:template match="n1:*[contains(@styleCode,'Underline')]" priority="98">
  <u><xsl:next-match/></u>
</xsl:template>

基本上就是这样。这将忽略任何不在列表中的样式代码。

您可以在 1.0 中使用 xsl:apply-imports 执行相同的操作,但是这三个规则需要位于单独的样式表模块中。

于 2012-09-27T17:16:03.140 回答