Re: Problem with "preceding" and "following" axis steps

Alan Painter <[email protected]> Sun, 15 Nov 2020 19:19:56 +0100
Newsgroups gmane.text.xml.saxon.help
Message-ID <CAN+GtW3oWBbVmMB=U_3Ovn_DUNFmV6yBbmVHx4c_OujE_wKu7g@mail.gmail.com>
You could try this for the QUOT.START and QUOT.END

(The snippet that you provided does not contain ARTICLE/DEFINITION elements
hence only selecting QUOT.START elements herein.)

  <xsl:template match="/" name="xsl:initial-template">
    <xsl:for-each select="//QUOT.START">
      <xsl:sequence select="following-sibling::text()[. &lt;&lt;
current()/following-sibling::QUOT.END[1]]" />
    </xsl:for-each>
  </xsl:template>


On Sun, Nov 15, 2020 at 6:09 PM Till Gerken <[email protected]> wrote:

> Hi,
>
> I have a question regarding the use of "preceding" and "following". I am
> trying to extract information from Formex documents.
>
> I noticed that there is a difference between Saxon-JS and libxslt and I am
> not sure if it's my XSLT or if it's a specific Saxon-JS behavior.
>
> Here is a snippet from the source XML that I am processing:
>
> <ITEM>
>   <NP>
>     <NO.P>(1)</NO.P>
>     <TXT><QUOT.START CODE="2018" ID="QS0006" REF.END="QE0006"/>medical device<QUOT.END CODE="2019" ID="QE0006" REF.START="QS0006"/> means any instrument, apparatus, appliance, software, implant, reagent, material or other article intended by the manufacturer to be used, alone or in combination, for human beings for one or more of the following specific medical purposes:</TXT>
>     <P>
>       <LIST TYPE="DASH">
>         <ITEM>
>           <P>diagnosis, prevention, monitoring, prediction, prognosis, treatment or alleviation of disease,</P>
>         </ITEM>
>         <ITEM>
>           <P>diagnosis, monitoring, treatment, alleviation of, or compensation for, an injury or disability,</P>
>         </ITEM>
>         <ITEM>
>           <P>investigation, replacement or modification of the anatomy or of a physiological or pathological process or state,</P>
>         </ITEM>
>         <ITEM>
>           <P>providing information by means of <HT TYPE="ITALIC">in vitro</HT> examination of specimens derived from the human body, including organ, blood and tissue donations,</P>
>         </ITEM>
>       </LIST>
>     </P>
>     <P>and which does not achieve its principal intended action by pharmacological, immunological or metabolic means, in or on the human body, but which may be assisted in its function by such means.</P>
>     <P>The following products shall also be deemed to be medical devices:</P>
>     <P>
>       <LIST TYPE="DASH">
>         <ITEM>
>           <P>devices for the control or support of conception;</P>
>         </ITEM>
>         <ITEM>
>           <P>products specifically intended for the cleaning, disinfection or sterilisation of devices as referred to in Article&#xA0;1(4) and of those referred to in the first paragraph&#xA0;of this point.</P>
>         </ITEM>
>       </LIST>
>     </P>
>   </NP></ITEM>
>
>
> Here are the XSLT instructions I am using:
>
>     <xsl:template match="/">
>       <xsl:text>{</xsl:text>
>       <xsl:apply-templates select="//ARTICLE[STI.ART[contains(translate(text(), 'ABCDEFGHIJKLMNOPQRSTUVWXYZÄÖÜÉÈÊÀÁÂÒÓÔÙÚÛÇÅÏÕÑŒ', 'abcdefghijklmnopqrstuvwxyzäöüéèêàáâòóôùúûçåïõñœ'),'definitions')]]" mode="DEFINITIONS" />
>       <xsl:text>}</xsl:text>
>     </xsl:template>
>
>     <xsl:template match="ARTICLE" mode="DEFINITIONS">
>       <xsl:apply-templates select=".//LIST/ITEM/NP/TXT[QUOT.START]" mode="DEFINITIONS"/>
>     </xsl:template>
>     <xsl:template match="TXT" mode="DEFINITIONS">
>       <xsl:text>"</xsl:text>
>       <xsl:value-of select="text()[following::QUOT.START and preceding::QUOT.END]"/>
>       <xsl:text>": "</xsl:text>
>       <xsl:apply-templates />
>       <xsl:text>",</xsl:text>
>     </xsl:template>
>
>
> My issue is with the statement "<xsl:value-of
> select="text()[following::QUOT.START and preceding::QUOT.END]"/>"
>
> libxslt only returns the word between QUOT.START and QUOT.END, in the
> example above that would be "medical device". (my desired result)
>
> Saxon-JS however returns the text of the entire TXT tag. (not my desired
> result)
>
> Is there an error in my XSLT or did I come across an
> implementation-specific behavior of Saxon-JS? In case of the latter, what
> would be the right way to extract only the piece between QUOT.START and
> QUOT.END?
>
> Thanks!
>
> Till
>
> _______________________________________________
> saxon-help mailing list archived at http://saxon.markmail.org/
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/saxon-help

_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[email protected]
https://lists.sourceforge.net/lists/listinfo/saxon-help