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

Re: node positioning problem

Subject: Re: node positioning problem
From: Spencer Tickner <spencertickner@xxxxxxxxx>
Date: Wed, 30 Mar 2005 12:50:46 -0800
xsl positioning
Hi Michael,

Thank you very much, solved my problem and gave me some things to think about.

Cheers,

Spence


On Wed, 30 Mar 2005 19:54:31 +0100, Michael Kay <mike@xxxxxxxxxxxx> wrote:
> This
> 
>         <xsl:for-each select="child::BBB">
>             <xsl:if test="position() = 1">
>                 <xsl:copy-of select="BBB"/>
>             </xsl:if>
>         </xsl:for-each>
> 
> could be replaced by
> 
> <xsl:copy-of select="BBB[1]"/>
> 
> In this:
> 
> <xsl:when test="not(count(preceding-sibling::*[name()=name(current())])+1) =
> 1">
> 
> you know that the name of the current element is BBB, so it's the same as
> 
> test="not(count(preceding-sibling::BBB)+1) = 1"
> 
> which probably should be corrected to:
> 
> test="not(count(preceding-sibling::BBB)+1 = 1)"
> 
> or better still
> 
> test="not(preceding-sibling::BBB)"
> 
> XSLT can be verbose, but it doesn't have to be!
> 
> Michael Kay
> http://www.saxonica.com/
> 
> 
> > -----Original Message-----
> > From: Spencer Tickner [mailto:spencertickner@xxxxxxxxx]
> > Sent: 30 March 2005 19:14
> > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> > Subject:  node positioning problem
> >
> > Hi everyone, thanks for the help and all the great responses I've
> > gleened from ya.
> >
> > Here we go I got an xml file like so
> >
> > <!-- AA2 exists -->
> > <AAA>
> >     <AAA1></AAA1>
> >     <AAA2></AAA2>
> >     <BBB></BBB>
> >     <CCC></CCC>
> >     <BBB></BBB>
> > </AAA>
> > <!-- AA2 does not exist -->
> > <AAA>
> >     <AAA1></AAA1>
> >     <BBB></BBB>
> >     <BBB></BBB>
> >     <CCC></CCC>
> > </AAA>
> >
> > Ok, now in a quick pseudo what I need is
> >
> > <!-- If AA2 does exist -->
> > <h4>AAA1 AAA2</h4>
> > <h6>BBB</h6>
> > <h6>BBB</h6>
> >
> > <!-- If AA2 does not exist -->
> > <h4>AA1 BBB</h4>
> > <h6>BBB</h6>
> >
> > Here are my current templates
> >
> > <!-- This template works fine and dandy -->
> > <xsl:template match="AAA">
> >     <h4>
> >     <xsl:copy-of select="AAA1"/>
> >     <xsl:choose>
> >     <xsl:when test="AAA2"/>
> >         <xsl:copy-of select="AAA2"/>
> >     </xsl:when>
> >     <xsl:otherwise>
> >         <xsl:for-each select="child::BBB">
> >             <xsl:if test="position() = 1">
> >                 <xsl:copy-of select="BBB"/>
> >             </xsl:if>
> >         </xsl:for-each>
> >      </xsl:otherwise>
> >      </xsl:choose>
> >      <h4>
> >      <xsl:apply-templates/>
> > </xsl:template>
> >
> > <!-- This is where I get confused -->
> > <xsl:template match="BBB">
> >         <h6>
> >       <xsl:choose>
> >         <!-- If there is an AAA2 we always put down BBB -->
> >       <xsl:when test="parent::AAA/AAA2">
> >               <xsl:copy-of select="BBB"/>
> >       </xsl:when>
> >
> >        <!-- This doesn't work but it should skip the first BBB and
> > grab the rest -->
> >       <xsl:when
> > test="not(count(preceding-sibling::*[name()=name(current())])+1)
> > = 1">
> >               <p class="sub">(<xsl:copy-of
> > select="subsectionnumber"/>)&#160;
> >               <xsl:copy-of select="subsectiontext"/></p>
> >       </xsl:when>
> >       </xsl:choose>
> >        </h6>
> >       <xsl:apply-templates/>
> > </xsl:template>
> >
> > Ok, I think that about covers it, thanks for any help or
> > advice you can offer
> >
> > Spencer

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.