[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Union of StepPattern

Subject: RE: Union of StepPattern
From: "Michael Kay" <mhkay@xxxxxxxxxxxx>
Date: Fri, 16 Feb 2001 00:16:20 -0000
RE:  Union of StepPattern
> I have a situation where I need to remove the DIVs from within an LI
> element. We have decided that when we encounter a DIV within
> an LI we are
> going to replace it with a training BR if the next valid
> sibling is another
> DIV. Otherwise we'll do nothing. Can I do the following:
>
> 	<xsl:template match="DIV[parent::LI]">

That's fine, though most people write match="LI/DIV" which means the same.

> 		<xsl:varible name="following-valid"
> select="following-sibling::DIV|following-sibling::P|following-
> sibling::OL|fo
> llowing-sibling::UL" />
> 		<xsl:apply-templates select="*|comment()|pi()|text()"/>
> 		<xsl:if test="$following-valid[1] =
> following-sibling::DIV[1]">
> 			<br />
> 		</xsl:if>
> 	</xsl:template>
>
> > Whether this works depends on whether the select in the
> variable returns
> > everything in document order

Technically the value of the variable is a unordered node-set, and the
filter expression $following-valid[1] selects the node in this node-set that
comes first in document order. So in effect, yes, you're OK.

But the "=" test is wrong: it compares the string-values of the nodes, not
their identity. To compare identity, use generate-id(X)=generate-id(Y), or
count(X|Y)=1. Except that in this case, I think you can simply say <xsl:if
test="$following-valid[1][self::DIV]">.

Mike Kay
>


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.