在我的xml有三个部分标题,都在h1位置,但我想第一部分作为h1位置和remaning必须是h2位置和我的xml文件是
<section>
<title>DESCRIPTION</title>
<p>The A380 is available with two types of turbofan engines, the
Rolls-Royce Trent 900 (variants A380-841, −842 and −843F) or the Engine
Alliance GP7000 (A380-861 and −863F). Noise reduction was an important
requirement in the A380 design, and particularly affects engine design.</p>
<p>Landing gears<ul>
<li>
<p>Nose Landing Gear</p>
</li>
<li>
<p>Wing Landing Gear (Bogie Type, 4 Wheels - 4 Braked)</p>
</li>
<li>
<p>Body Landing Gear (Bogie Type, 6 Wheels - 4 Braked)</p>
</li>
</ul>
</p>
</section>
<section>
<title>Wing Landing Gear</title>
<p>Each wing landing gear has a leg assembly and
a four-wheel bogie beam. The WLG leg includes a Bogie Trim Actuator
(BTA) and an oleo-pneumatic shock absorber.</p>
</section>
<section>
<title>Body Landing Gear</title>
<p>The two body landing gears have a six-wheel bogie
beam and a leg assembly that includes an oleo- pneumatic shock absorber.
A two-piece drag-stay assembly mechanically locks the leg in the extended
position.</p>
<fig>
<title>Landing gear</title>
<image align="center" href="../ICN-HSXWB-A-791111-H-F0302-00001-A-001-01.tif"/>
</fig>
</section>
我使用xslt作为
<xsl:template match="*[contains(@class,' topic/section ')][@spectitle != ''
and not(*[contains(@class, ' topic/title ')])]"
mode="dita2xslfo:section-heading"
priority="10">
<fo:block xsl:use-attribute-sets="section.title">
<xsl:call-template name="commonattributes"/>
<xsl:variable name="spectitleValue" as="xs:string" select="string(@spectitle)"/>
<xsl:variable name="resolvedVariable">
<xsl:call-template name="insertVariable">
<xsl:with-param name="theVariableID" select="$spectitleValue"/>
</xsl:call-template>
</xsl:variable>
<xsl:sequence
select="if (not(normalize-space($resolvedVariable)))
then $spectitleValue
else $resolvedVariable"
/>
</fo:block>
<xsl:template match="*[contains(@class,' topic/section ')]">
<fo:block xsl:use-attribute-sets="section">
<xsl:call-template name="commonattributes"/>
<xsl:apply-templates select="." mode="dita2xslfo:section-heading"/>
<xsl:apply-templates/>
</fo:block>
</xsl:template>
请指导我这件事。谢谢
答案 0 :(得分:0)
这是我可以发送的最小模板。
Col 1,Col 2,Col 3
4444,Drowsy,bit drowsy
45888,Blurred see - hazy,little seeing vision
45933,Excessive upper pain,pain problems
112397013,air,agony
76948002,pain,agony
元素都不匹配,因为所有输入XML文件的section元素都有title元素。相反,我为H1和H2添加了两个xsl:attribute-set,并根据section元素位置应用它们。
section
可能你想进行更复杂的转换,但我希望这个例子有助于你的开发。
答案 1 :(得分:0)
您可以使用position()功能来实现此目的:
<xsl:choose>
<xsl:when test="position() = 1">
<!--attributes for H1 go here-->
<xsl:attribute name="font-size">24</xsl:attribute>
</xsl:when>
<xsl:otherwise>
<!--attributes for H2 go here-->
<xsl:attribute name="font-size">18</xsl:attribute>
</xsl:otherwise>
</xsl:choose>