使用Xsl stylessheet将XML转换为Html

时间:2017-10-02 17:04:48

标签: html xml xslt

我遇到了瓶颈,

我有一个包含以下结构的XML文件。

 <content>
    <procedure>
    <commonInfo>
    <title>           <inlineSignificantData significantParaDataType="psd51">TASK 72-31-00-030-001</inlineSignificantData> LP Compressor (LPC) Fan Module - Disassemble</title>
    <para/>
    <commonInfoDescrPara>
    <title>General</title>
    <para>This TASK gives the procedure to disassemble the LP Compressor (Fan) Module.</para>
    <para>Fig/item numbers in parentheses in the procedure agree with those used in the IPC. Only the primary Fig/item numbers are used. For the service bulletin alpha variants refer to the IPC.</para>
    <para>Apply the approved penetrating oils before the removal of threaded parts and parts having an interference fit. Let the parts soak before removal. For the approved penetrating oils and procedures, refer to the SPM <dmRef><dmRefIdent><dmCode assyCode="00" disassyCode="00" disassyCodeVariant="A" infoCode="240" infoCodeVariant="A" itemLocationCode="D" modelIdentCode="IHIX1" subSubSystemCode="4" subSystemCode="6" systemCode="70" systemDiffCode="00"/></dmRefIdent></dmRef>.</para>
    <para>Refer to <internalRef internalRefId="fig-0001" internalRefTargetType="figure"/> for a sectional view of a LP compressor (fan) module.</para>
    </commonInfoDescrPara>
</commonInfo>
<preliminaryRqmts>
<reqCondGroup>
<noConds/></reqCondGroup>
<reqSupportEquips><supportEquipDescrGroup><supportEquipDescr id="seq-0001"><name>Removal puller</name><identNumber><manufacturerCode>VENDOR1</manufacturerCode><partAndSerialNumber><partNumber>SE 201</partNumber></partAndSerialNumber></identNumber><reqQuantity>1</reqQuantity>
</supportEquipDescr>
</preliminaryRqmts>
</procedure>
  </content>

我有XSL文件,将其转换为Html

&LT;

xsl:template match="content">
    <ol class="ata-list">
      <xsl:apply-templates select="description|procedure"/>
    </ol>-->
  </xsl:template>

我想在这里做的是,我不想在<ol> </ol>标签内打印以下xml。

<commonInfo>
<title>           <inlineSignificantData significantParaDataType="psd51">TASK 72-31-00-030-001</inlineSignificantData> LP Compressor (LPC) Fan Module - Disassemble</title>
</commonInfo>

相反,我想打印标签上方的详细信息

<dev>
apply template <commonInfo>
<dev>

<ol class="ata-list">
      <xsl:apply-templates select="procedure"/> with out the common tags
    </ol>-->

我该如何实现这一目标? pelase帮助

1 个答案:

答案 0 :(得分:0)

尝试使用模式:

<xsl:template match="content">
    <dev>
       <xsl:apply-templates select="procedure/commonInfo" mode="ci"/>
    </dev>
    <ol class="ata-list">
      <xsl:apply-templates select="description|procedure" mode="dp"/>
    </ol>
  </xsl:template>

然后为两种处理模式设置不同的模板规则(将mode="x"属性添加到相关的xsl:templatexsl:apply-templates元素。)