xsl-list
[Top] [All Lists]

Re: [xsl] questions about preceding::processing-instruction

2017-04-10 08:30:40


On 10.04.2017 15:12, Erik Zander 
erik(_dot_)zander(_at_)studentlitteratur(_dot_)se wrote:
Hi All!

I have an optimization problem concerning preceding::processing-instruction.

First some background in my xml I have processing instructions like <?anchor xml:id="orgPage.7"/?> representing the start of a page.

And I have a template that matches on *text().*

In the template matching on text() I want to know the page number.

To get this I have in the text template declared a variable as

<xsl:variablename="currentPage"select="substring-before(substring-after(((./preceding::processing-instruction('anchor'))[last()]), 'Page.'), '&quot;')"/>

Which works (although I don’t see why as I had the understanding that preceding:: returned in reverse document order) but it takes up a great deal of the processing time.

So my questions are:

Is there a better (faster/smarter) way to get the page from the processing instruction.

Maybe put all of them into a global variable and then do something like ($all-page-anchors[. &lt;&lt; current()])[last()]


And is it the expected behavior that calling preceding:processing-instruction() gives me

<?anchor xml:id="orgPage.1"/?>

<?anchor xml:id="orgPage.2"/?>

<?anchor xml:id="orgPage.3"/?>

<?anchor xml:id="orgPage.4"/?>

I have this behavior in both Saxon 9.6.0.7 and Marklogic.

This is because the ( ) around the expression effects that the nodes will be put in document order. See the note after https://www.w3.org/TR/xpath20/#dt-numeric-predicate

Gerrit


Regards

Erik Zander

XSL-List info and archive <http://www.mulberrytech.com/xsl/xsl-list>
EasyUnsubscribe <-list/225679> (by email <>)

--
Gerrit Imsieke
Geschäftsführer / Managing Director
le-tex publishing services GmbH
Weissenfelser Str. 84, 04229 Leipzig, Germany
Phone +49 341 355356 110, Fax +49 341 355356 510
gerrit(_dot_)imsieke(_at_)le-tex(_dot_)de, http://www.le-tex.de

Registergericht / Commercial Register: Amtsgericht Leipzig
Registernummer / Registration Number: HRB 24930

Geschäftsführer: Gerrit Imsieke, Svea Jelonek,
Thomas Schmidt, Dr. Reinhard Vöckler
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--

<Prev in Thread] Current Thread [Next in Thread>