Hi Rick,
1) You are looking for elements that are simultaneously processing
instructions. You need to replace * with node().
2) The immediately preceding sibling might be a whitespace-only text node.
Try this (untested):
preceding-sibling::node()[empty(self::text()[not(normalize-space())])][1][self::processing-instruction()]
Gerrit
On 08.05.2023 15:32, rick@xxxxxxxxxxxxxx wrote:
Hi All,
I have this XML:
<?xml version="1.0" encoding="UTF-8"?>
<manual>
B B <?Fm Document GN800042-VGRShreddingMill_UM_cover.fm?>
B B <cover/>
B B <?Fm Document BP00001.fm?>
B B <chapter/>
B B <?Fm Document BP00010.fm?>
B B <chapter/>
B B <?Fm Document GN800042.fm?>
B B <chapter/>
B B <?Fm Document SC00019.fm?>
B B <chapter/>
B B <chapter/>
</manual>
For each chapter element, I want to grab the immediately preceding
processing-instruction. The third message in my code doesnbt return it.
The second one does, but it doesnbt insure that the
processing-instruction is the first preceding-sibling. Thanks in advance
for your help.
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
B B B xmlns:xs="http://www.w3.org/2001/XMLSchema"
B B B xmlns:math="http://www.w3.org/2005/xpath-functions/math"
B B B exclude-result-prefixes="xs math"
B B B version="3.0" expand-text="yes">
B B B B <xsl:output indent="yes"/>
B B B B <xsl:template match="/">
B B B B B B B <xsl:apply-templates/>
B B B </xsl:template>
B B B B <xsl:template match="/*/*">
B B B B B B B <xsl:message>{local-name(.)}</xsl:message>
<xsl:message>{preceding-sibling::processing-instruction()[1]}</xsl:message>
<xsl:message>{preceding-sibling::*[1][self::processing-instruction()]}</xsl:message>
B B B </xsl:template>
B B B B <xsl:mode on-no-match="shallow-skip"/>
</xsl:stylesheet>
Rick
XSL-List info and archive <http://www.mulberrytech.com/xsl/xsl-list>
EasyUnsubscribe <http://lists.mulberrytech.com/unsub/xsl-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 / Managing Directors:
Gerrit Imsieke, Svea Jelonek, Thomas Schmidt
|