Subject: Re: [xsl] targeting the 'first' instance of the same element in variable structures From: "Martin Honnen martin.honnen@xxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Tue, 2 Jul 2024 11:16:52 -0000 |
On 02/07/2024 13:05, Jean-Paul Rehr rehrjb@xxxxxxxxx wrote: > At first Martin's solutionB <xsl:template match="(div//head)[1]"> > looked like it would work. But then I started to test the various > documentsB I have to work with, in particular at the most problematic. > Below is an actual fragment, but I've put it in this Fiddle > <https://martin-honnen.github.io/cheerpj3-saxonhe12-fiddle/?code=%3C%3Fxml+ve rsion%3D%221.0%22+encoding%3D%22utf-8%22%3F%3E%0A%3Cxsl%3Astylesheet+xmlns%3A xsl%3D%22http%3A%2F%2Fwww.w3.org%2F1999%2FXSL%2FTransform%22%0A++version%3D%2 23.0%22%0A++xmlns%3Axs%3D%22http%3A%2F%2Fwww.w3.org%2F2001%2FXMLSchema%22%0A+ +exclude-result-prefixes%3D%22%23all%22%0A++expand-text%3D%22yes%22%3E%0A++%0 A++%3Cxsl%3Atemplate+match%3D%22%28div%2F%2Fhead%29%5B1%5D%22%3E%0A++++%3Cxsl %3Acomment%3EMatched+%7Bnode-name%28%29%7D%3C%2Fxsl%3Acomment%3E%0A++++%3Cxsl %3Anext-match%2F%3E%0A++%3C%2Fxsl%3Atemplate%3E%0A%0A++%3Cxsl%3Aoutput+method %3D%22xml%22+indent%3D%22no%22%2F%3E%0A%0A++%3Cxsl%3Amode+on-no-match%3D%22sh allow-copy%22%2F%3E%0A%0A++%3Cxsl%3Atemplate+match%3D%22%2F%22+name%3D%22xsl% 3Ainitial-template%22%3E%0A++++%3Cxsl%3Acopy%3E%0A++++++%3Cxsl%3Aapply-templa tes%2F%3E%0A++++++%3Cxsl%3Acomment%3ERun+with+%7Bsystem-property%28%27xsl%3Ap roduct-name%27%29%7D+%7Bsystem-property%28%27xsl%3Aproduct-version%27%29%7D+a t+%7Bcurrent-dateTime%28%29%7D%3C%2Fxsl%3Acomment%3E%0A++++%3C%2Fxsl%3Acopy%3 E%0A++%3C%2Fxsl%3Atemplate%3E%0A%0A%3C%2Fxsl%3Astylesheet%3E%0A&input=%3Croot %3E%0A++%3Cdiv+xml%3Aid%3D%22michael-meld-dist-div-5Ehm2la0%22%3E%0A%09%09%3C div+xml%3Aid%3D%22michael-meld-dist-div-1k784804%22+type%3D%22fulltext%22%3E% 0A%09%09%09%3Cdiv+xml%3Aid%3D%22michael-meld-dist-div-23IEC0ec%22+type%3D%22p rologus%22%3E%0A%09%09%09%09%09%3Chead%3EPREFATIO%3Cnote+type%3D%22source%22% 3EIndicem+analyticum%2C+qui+ex+vetusta+exemplari+Ms.+in+ceteris+editionibus+h oc+loco+legitur%2C+ad+calcem+voluminis+tomi+rejecimus.%3C%2Fnote%3E%0A%09%09% 09%09%09%3C%2Fhead%3E%0A%09%09%09%09%09%3Cp+xml%3Aid%3D%22michael-meld-dist-p -k78i0214%22%3EQuisquis+ad+divine+pagine+lectionem+erudiendus+accedit%2C+in+p rincipio+considerare+debet%2C+que+sit+illius+Scripture+materia%2C+circa+quam+ versatur+ejus+tractatus.+Est+autem+illius%0A%09%09%09%09%09%09principalis+mat eria%2C+opus+restaurationis.%3C%2Fp%3E%0A%09%09%09%09%09%3Cdiv+xml%3Aid%3D%22 michael-meld-dist-div-02847i24%22+sameAs%3D%22michaelis_0001%22+type%3D%22dis tinctio%22%3E%0A%09%09%09%09%09%09%3Chead%3EOpus+conditionis+et+restaurationi s%3C%2Fhead%3E%0A%09%09%09%09%09%09%3Cp+xml%3Aid%3D%22michael-meld-dist-p-0M0 t4368%22%3ESunt+enim+duo+opera+%3A+opus+conditionis%2C+et+opus+restaurationis .+Opus+conditionis+est%2C+quo+factum+est+ut+essent%2C+que+non+erant%3B+opus+r estaurationis+est%2C+per+quod+meliorata+sunt%2C+que%0A%09%09%09%09%09%09%09pe rierant.+Opere+conditionis+factus+est+mundus+cum+suis+elementis%3B+opere+rest aurationis%2C+Verbi+incarnatio+cum+suis+sacramentis.+%3C%2Fp%3E%0A%09%09%09%0 9++%3C%2Fdiv%3E%0A%09%09%09++%09%3Cdiv+xml%3Aid%3D%22michael-meld-dist-div-qA 5X66Ks%22+sameAs%3D%22michaelis_0002%22+type%3D%22distinctio%22%3E%0A%09%09%0 9%09%09++%3Chead%3ESacre+Scripture+prestantia%3C%2Fhead%3E%0A%09%09%09%09%09+ +%3Cp+xml%3Aid%3D%22michael-meld-dist-p-E1v5wA1j%22%3EEx+quo+manifestum+est%2 C+quod+Scriptura+cunctis+aliis+precellit%2C+tum+materie+dignitate%2C+tum+prof unditate%2C+et+subtilitate.+Et+si+quis+diligenter+attendit%2C+potest+perciper e+quod+omnes%0A%09%09%09%09%09%09+artes%2C+tam+liberales%2C+quam+naturales%2C +ei+tanquam+domine+famulantur.+%3C%2Fp%3E%0A%09%09%09%09++%3C%2Fdiv%3E%0A%09% 09%09%3C%2Fdiv%3E%0A%09%09%3C%2Fdiv%3E%0A%09%3C%2Fdiv%3E%0A%3C%2Froot%3E%0A&c ode-type=XSLT&input-type=XML>. > As we can see it matched two items...it should only match the first. > In bold below are what the template matched, in red bold what should > be exclusively matched. Is there some know root or parent container for the outer div like e.g. B <xsl:template match="(/*/div//head)[1]"> ? Or can the outer div appear at any level/with any nesting and parent container?
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] targeting the 'first' ins, David Birnbaum djbpi | Thread | Re: [xsl] targeting the 'first' ins, Jean-Paul Rehr rehrj |
Re: [xsl] targeting the 'first' ins, Jean-Paul Rehr rehrj | Date | Re: [xsl] targeting the 'first' ins, David Carlisle d.p.c |
Month |