[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] testing preceding sibling always evaluates true


Subject: Re: [xsl] testing preceding sibling always evaluates true
From: Hank Ratzesberger <hankr@xxxxxxxx>
Date: Fri, 29 Jul 2011 11:09:53 -0700

Hello Jeff,

I believe the issue is (and I would like some clarification), is that
axis steps always return nodes in document order so

preceding-sibling::w:p[1]

will always return the first paragraph with its TableCaption child.

I believe the work around for this, to collect the nodes in search
order, is to make them a set,

(preceding-sibling::w:p)[1]


or possibly, to get the last, not the first, since the last would be the closest to the context node

preceding-sibling::w:p[last()]

I'm not sure if there is a standard pattern for this -- getting
just the single sibling preceding the context.

Cheers,
Hank

On 7/29/11 10:11 AM, Jeff Wilson wrote:
Good Morning,

I'm trying to test the first preceding-sibling of my match to
determine what type of table I'm formatting.

This is the XSL that is testing, but it always comes back true and
all tables are formatted as Numbered tables:

<xsl:template match="/pkg:package/pkg:part/pkg:xmlData/w:document/
w:body/w:tbl">
	<xsl:choose>
		<xsl:when test="preceding-sibling::w:p[1]/w:pPr/w:pStyle
[@w:val='TableCaption']">
			<xsl:call-template name="NumberedTable"/>
		</xsl:when>
		<xsl:otherwise>
			<xsl:call-template name="TabularText"/>
		</xsl:otherwise>
	</xsl:choose>
</xsl:template>

given this xml:
...
<w:p w14:paraId="69005124" w14:textId="77777777" w:rsidR="001D446A"
w:rsidRDefault="001D446A" w:rsidP="001D446A">
	<w:pPr>
		<w:pStyle w:val="TableCaption"/>
	</w:pPr>
	<w:r>
		<w:t>Table 14.1: External data formats Inventor can import or
export</w:t>
	</w:r>
</w:p>
<w:tbl>
...
...
<w:p w14:paraId="5EA14AF4" w14:textId="77777777" w:rsidR="001D446A"
w:rsidRDefault="001D446A" w:rsidP="001D446A">
	<w:pPr>
		<w:pStyle w:val="Para"/>
	</w:pPr>
	<w:r>
		<w:t>As you can see from the following tabular text:</w:t>
	</w:r>
</w:p>
<w:tbl>
...


-- Louis (Hank) Ratzesberger hankr@xxxxxxxx Scripps Orbit and Permanent Array Center Mailing Address: Mail Code 0225 9500 Gilman Drive University of California, San Diego La Jolla, CA 92093-0225 858-822-4472 IGPP/SIO Location: Bldg T-31 8860 Biological Grade


Current Thread
Keywords
xsl