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

RE: Problem with Position()?

Subject: RE: Problem with Position()?
From: "Geert Josten" <geert.josten@xxxxxxxxxxx>
Date: Sat, 13 Oct 2007 18:46:06 +0200
RE: Problem with Position()?
Dear Alice,

The problem lies in the fact that white-space is counted as contents of
the book element as well. You haven't specified a DTD nor a Schema that
states otherwise, so white-space is considered significant. Contents of
the book element is numbered as follows:

Book:
1. white-space
2. first p element
3. white-space
4. second p element
5. white-space

You can circumvent this problem by not using <xsl:apply-templates />,
which selects node() implicitly, which means: process all contents,
including character data and (significant) white-space as well. Instead,
you can use the select attribute of xsl:apply-templates and force to
evaluate only elements:

<xsl:apply-templates select="*" />

Or even stronger, only p child elements:

<xsl:apply-templates select="p" />

Kind regards,
Geert

>


Drs. G.P.H. Josten
Consultant



Daidalos BV
Source of Innovation
Hoekeindsehof 1-4
2665  JZ  Bleiswijk
Tel.: +31 (0) 10 850 1200
Fax: +31 (0) 10 850 1199
www.daidalos.nl
KvK 27164984


De informatie - verzonden in of met dit emailbericht - is afkomstig van
Daidalos BV en is uitsluitend bestemd voor de geadresseerde. Indien u dit
bericht onbedoeld hebt ontvangen, verzoeken wij u het te verwijderen. Aan dit
bericht kunnen geen rechten worden ontleend.


> From: Abel Braaksma [mailto:abel.online@xxxxxxxxx]
> Sent: zaterdag 13 oktober 2007 18:25
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: Re: Problem with Position()?
>
> Jay Bryant wrote:
> >
> > Try changing the test to use the preceding-sibling axis, thus:
> >
> > <xsl:when test="count(preceding-sibling::p) = 0">
> >
> > That test catches the first p in a series of neighboring p elements.
> >
>
>
> Be aware that with large input files and with a
> not-too-optimizing processor, this test might perform
> quadratic. If that happens, you can try changing it to:
>
> <xsl:when test="not(preceding-sibling::p[1])">
>
> which will behave the same but is easier optimized by the processor.
>
> A note to the OP: in your xsl:otherwise statement you have na
> added xsl:if which seems redundant there because it tests for
> the inverse of the xsl:when. If so intended, you can remove it.
>
> Cheers,
> -- Abel Braaksma

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.