Re: Problem with "preceding" and "following" axis steps
John Lumley <john-JkSD5nQpfvpWk0Htik3J/[email protected]> Sun, 15 Nov 2020 17:57:10 +0000
| Newsgroups | gmane.text.xml.saxon.help |
|---|---|
| Message-ID | <[email protected]> |
Firstly may we assume there are multiple ITEMs each with a TXT with (some/most) having QUOTE.[START|END] ? If so then for all except the first and last in the document I think SaxonJS is behaving correctly. The text() node children of TXT all have a following QUOTE.START, albeit in a following TXT, and a preceding QUOTE.END, albeit in a preceding TXT. The preceding and following axes range over the whole of the document, not just the children of the parent node. And in a predicate preceding means ‘and there is an X that precedes this node in the document’, not ‘this node precedes an X’; similarly for the following axis. I suspect you want the predicate [preceding-sibling::QUOTE.START and following-sibling::QUOTE.END], which limits the scope to siblings of the node, though I haven’t had the opportunity to ask the XSLT processor oracle. John Lumley john-JkSD5nQpfvpWk0Htik3J/[email protected] > On 15 Nov 2020, at 17:09, 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 1(4) and of those referred to in the first paragraph 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