0

I am completely new with XSLT, thank you in advance for your understanding. I need to prepare an xml which will be sent to Adobe InDesign server. In html files (which represent my input that I need to transform to xml and send to Adobe InDesign by using XSLT transformation), I've got the following list:

<li>IV <span><span>nitroglycerin</span></span> may be of short-term benefit by decreasing&#xa0;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>

The main template that I am using for the transformation is:

<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>

But with the solution, I got this unwanted effect:

<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>

So, each "i" or "span" tag (from the input) creates a new spacing, which should not appear between the characters in "μg" or "1B", for example. I probably need to somehow rewrite my select, right? I wanted to select descendant-or-self::*/text(), but I didn't want to include descendant::li. I'm not sure how to do that.

Desired output is the following one:

<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>

Thank you in advance for any help.

UPDATE: Let me explain the issue better. This is an input list that I need to transform:

<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&#xa0;<i>inotropic</i>&#xa0;abnormality, due to myocardial infarction (MI) or dilated or ischemic cardiomyopathy (CM), resulting in diminished systolic emptying (ejection fraction &lt;45%).</li> 
           <li>Diastolic dysfunction: a&#xa0;<i>compliance</i>&#xa0;abnormality, due to hypertensive CM, in which ventricular relaxation is impaired (ejection fraction &gt;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> 

What I am getting is:

 <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, due to myocardial infarction (MI) or dilated or ischemic cardiomyopathy (CM), resulting in diminished systolic emptying (ejection fraction &lt;45%).</Content>
                <Br/>
             </CharacterStyleRange>
          </ParagraphStyleRange>
          <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BL2">
             <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/$ID/[No character style]">
                <Content>Diastolic dysfunction: a  compliance  abnormality, due to hypertensive CM, in which ventricular relaxation is impaired (ejection fraction &gt;45%), resulting in decreased filling.</Content>
                <Br/>
             </CharacterStyleRange>
          </ParagraphStyleRange>

A desired result should not contain additional spacing between "italic" and "span" tags (the words "inotropic" and "compiliance" for example). And also, I do not want to have "inotropic" and "compiliance" words within the text:"Two potential pathophysiologic conditions lead to the clinical findings of HF, namely systolic and/or diastolic heart dysfunction. inotropic compliance", because those come from the descendants of "li" elements, and don't belong to the first "li". So, what I would like to get is:

<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, due to myocardial infarction (MI) or dilated or ischemic cardiomyopathy (CM), resulting in diminished systolic emptying (ejection fraction &lt;45%).</Content>
                    <Br/>
                 </CharacterStyleRange>
              </ParagraphStyleRange>
              <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BL2">
                 <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/$ID/[No character style]">
                    <Content>Diastolic dysfunction: a compliance abnormality, due to hypertensive CM, in which ventricular relaxation is impaired (ejection fraction &gt;45%), resulting in decreased filling.</Content>
                    <Br/>
                 </CharacterStyleRange>
              </ParagraphStyleRange>

Thank you for any help once again.

nean0502
  • 17
  • 5
  • It is not clear what the requirement is, here, for that sample, it seems a simple `` would output the complete text content of the `li` and you would get the "desired output". So I think you need to describe your possible input and wanted output structures in more detail, the current use of `value-of` seemed to be needed for your previous requirement but it is hard to understand from a single sample what the general transformation task is. – Martin Honnen Aug 11 '20 at 13:26
  • Thank you @Martin for your suggestions and help. Please take a look at the "Update" part of the question. – nean0502 Aug 11 '20 at 14:42

0 Answers0