xsl-list
[Top] [All Lists]

[xsl] questions about preceding::processing-instruction

2017-04-10 08:12:07
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:variable name="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.

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.

Regards
Erik Zander
--~----------------------------------------------------------------
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>