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

Re: how to select elements based on optional container

Subject: Re: how to select elements based on optional container argument
From: "Nick Shepherd" <nick@xxxxxxxxxxxxxxxx>
Date: Tue, 21 Aug 2007 18:12:20 -0400
Re:  how to select elements based on optional container
maybe it would help if I had the appropriate logic matched to the
appropriate condition O.o

corrected below :)

<xsl:apply-templates match="container">

	<xsl:choose>
		<xsl:when test="@select &gt; 0">
			<xsl:for-each select="item">
				<xsl:if test="position() &lt;= @select">
					<xsl:comment>Do your dirty business here</xsl:comment>
				</xsl:if>
			</xsl:for-each>
		</xsl:when>
		<xsl:otherwise>
			<xsl:for-each select="item">
				<xsl:comment>Same dirty Business</xsl:comment>
			</xsl:for-each>
		</xsl:otherwise>
	</xsl:choose>

</xsl:apply-templates>

On 8/21/07, Nick Shepherd <nick@xxxxxxxxxxxxxxxx> wrote:
> the following isn't tested and there may be a more elegant solution
> but this is probably how I would handle a situation like this:
>
> <xsl:apply-templates match="container">
>
>         <xsl:choose>
>                 <xsl:when test="@select &gt; 0">
>                         <xsl:for-each select="item">
>                                 <xsl:comment>Same dirty Business</xsl:comment>
>                         </xsl:for-each>
>                 </xsl:when>
>                 <xsl:otherwise>
>                         <xsl:for-each select="item">
>                                 <xsl:if test="position() &lt;= @select">
>                                         <xsl:comment>Do your dirty business here</xsl:comment>
>                                 </xsl:if>
>                         </xsl:for-each>
>                 </xsl:otherwise>
>         </xsl:choose>
>
> </xsl:apply-templates>
>
> hope that helps :)
>
> Nick
>
> On 8/21/07, Andreas Kemkes <a5sk4s@xxxxxxxxx> wrote:
> > XSLT 1.0 is a constraint.
> >
> > I'm having trouble with a select expression to select the marked elements (<!--X-->) in the following XML:
> >
> > <container select="2">
> >   <item>...</item><!--X-->
> >   <item>...</item><!--X-->
> >
> >   <item>...</item>
> >
> > </container>
> > <container>
> >
> >   <item>...</item><!--X-->
> >
> >   <item>...</item><!--X-->
> >
> >
> >   <item>...</item><!--X-->
> >
> >
> > </container>
> >
> > <container select="1">
> >
> >   <item>...</item><!--X-->
> >   <item>...</item>
> >
> >   <item>...</item>
> >
> >   <item>...</item>
> >
> > </container>
> >
> > In the case of a no select attribute all items in the container should be in the node set.
> > If there is a attribute select="n", only the first "n" items should be in the node set.
> > The expression needs to work across all containers.
> >
> > There is the additional constraint that only items with parent container are to be selected.
> >
> >
> > Where could I start to look for code examples that solves a similar problem?
> >
> > Thanks in advance for your help.
> >
> >
> >
> >
> >       ____________________________________________________________________________________
> > Shape Yahoo! in your own image.  Join our Network Research Panel today!   http://surveylink.yahoo.com/gmrs/yahoo_panel_invite.asp?a=7

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.