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

Subject: Re: [xsl] questions about preceding::processing-instruction
From: "Imsieke, Gerrit, le-tex gerrit.imsieke@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 10 Apr 2017 13:30:33 -0000
On 10.04.2017 15:12, Erik Zander erik.zander@xxxxxxxxxxxxxxxxxxxx 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 donbt 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 GeschC$ftsfC<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.imsieke@xxxxxxxxx, http://www.le-tex.de

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

GeschC$ftsfC<hrer: Gerrit Imsieke, Svea Jelonek,
Thomas Schmidt, Dr. Reinhard VC6ckler

Current Thread