问题描述
我对XSLT完全陌生,在此先感谢您的理解。我需要准备一个将发送到Adobe InDesign服务器的xml。在html文件中(代表我的输入,我需要将其转换为xml并通过XSLT转换发送至Adobe InDesign),我得到以下列表:
<li>IV <span><span>nitroglycerin</span></span> may be of short-term benefit by decreasing preload and afterload by dilating peripheral capacitance and resistance vessels on vascular smooth musculature (IV 10 to 20 <i>μ</i>g/min,increase up to 200 <i>μ</i>g/min) <span>1</span><span>B</span>.</li>
我用于转换的主要模板是:
<xsl:template match="li[not(descendant::p) and not(ancestor::section[@class='references' or @class='References'])]" mode="li-pass1">
<xsl:variable name="depth" select="count(ancestor::li) + 1"/>
<xsl:variable name="listType">
<xsl:choose>
<xsl:when test="parent::ol">
<xsl:value-of select="'NL'"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="'BL'"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/{$listType}{if ($depth eq 1) then '' else $depth}">
<Content>
<xsl:value-of select="(text() | descendant::span/text() | descendant::i/text())/normalize-space()"/>
</Content>
<Br/>
</ParagraphStyleRange>
</xsl:template>
<Content>IV nitroglycerin may be of short-term benefit by decreasing preload and afterload by dilating peripheral capacitance and resistance vessels on vascular smooth musculature (IV 10 to 20 μ g/min,increase up to 200 μ g/min) 1 B .</Content>
因此,每个“ i”或“ span”标签(来自输入)都会创建一个新的间距,例如,该间距不应出现在“μg”或“ 1B”中的字符之间。我可能需要以某种方式重写我的选择,对不对?我想选择后代或自身:: * / text(),但我不想包括后代:: li。我不确定该怎么做。
所需的输出如下:
<Content>IV nitroglycerin may be of short-term benefit by decreasing preload and afterload by dilating peripheral capacitance and resistance vessels on vascular smooth musculature (IV 10 to 20 μg/min,increase up to 200 μg/min) 1B.</Content>
在此先感谢您的帮助。
更新: 让我更好地解释这个问题。这是我需要转换的输入列表:
<ul>
<li>Two potential pathophysiologic conditions lead to the clinical findings of HF,namely systolic and/or diastolic heart dysfunction.
<ul>
<li>Systolic dysfunction: an <i>inotropic</i> abnormality,due to myocardial infarction (MI) or dilated or ischemic cardiomyopathy (CM),resulting in diminished systolic emptying (ejection fraction <45%).</li>
<li>Diastolic dysfunction: a <i>compliance</i> abnormality,due to hypertensive CM,in which ventricular relaxation is impaired (ejection fraction >45%),resulting in decreased filling.</li>
<li>In an attempt to adopt a more pragmatic classification system,one that has been accepted by both the European and American HF guidelines,the terms HF with reduced,midrange,or preserved LVEF (HFrEF,HFmrEF,and HFpEF,respectively) have been adopted recently.</li>
</ul> </li> </ul>
我得到的是:
<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BL">
<CharacterStyleRange AppliedCharacterStyle="CharacterStyle/$ID/[No character style]">
<Content>Two potential pathophysiologic conditions lead to the clinical findings of HF,namely systolic and/or diastolic heart dysfunction. inotropic compliance</Content>
<Br/>
</CharacterStyleRange>
</ParagraphStyleRange>
<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BL2">
<CharacterStyleRange AppliedCharacterStyle="CharacterStyle/$ID/[No character style]">
<Content>Systolic dysfunction: an inotropic abnormality,resulting in diminished systolic emptying (ejection fraction <45%).</Content>
<Br/>
</CharacterStyleRange>
</ParagraphStyleRange>
<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BL2">
<CharacterStyleRange AppliedCharacterStyle="CharacterStyle/$ID/[No character style]">
<Content>Diastolic dysfunction: a compliance abnormality,resulting in decreased filling.</Content>
<Br/>
</CharacterStyleRange>
</ParagraphStyleRange>
期望的结果不应在“斜体”和“ span”标签之间包含额外的空格(例如,单词“ inotropic”和“ compliance”)。而且,我也不想在文本中使用“正性”和“顺应性”两个词:“两种潜在的病理生理状况会导致HF的临床发现,即收缩性和/或舒张性心脏功能障碍。来自“ li”元素的后代,并且不属于第一个“ li”。所以,我想得到的是:
<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BL">
<CharacterStyleRange AppliedCharacterStyle="CharacterStyle/$ID/[No character style]">
<Content>Two potential pathophysiologic conditions lead to the clinical findings of HF,namely systolic and/or diastolic heart dysfunction.</Content>
<Br/>
</CharacterStyleRange>
</ParagraphStyleRange>
<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BL2">
<CharacterStyleRange AppliedCharacterStyle="CharacterStyle/$ID/[No character style]">
<Content>Systolic dysfunction: an inotropic abnormality,resulting in diminished systolic emptying (ejection fraction <45%).</Content>
<Br/>
</CharacterStyleRange>
</ParagraphStyleRange>
<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BL2">
<CharacterStyleRange AppliedCharacterStyle="CharacterStyle/$ID/[No character style]">
<Content>Diastolic dysfunction: a compliance abnormality,resulting in decreased filling.</Content>
<Br/>
</CharacterStyleRange>
</ParagraphStyleRange>
再次感谢您的帮助。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)