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

Re: question on preceding nodes

Subject: Re: question on preceding nodes
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Mon, 31 Mar 2003 19:12:53 -0500
xsl node test preceding
Hi John,

The XPath Location Path in the test

<xsl:when test="preceding::/*/*/C[@name=current()/@name]">

isn't correct. It shouldn't parse at all (you should get a compile-time error).

Try, simply,

preceding::C[@name=current()/@name]

Since any location path step must be constructed as

axisname::nodetest[optionalpredicate]

and yours has no node test, but rather '/*/*/C' which looks like a location path on its own (composed of three steps, child:: axis implicit in each step, node tests '*', '*' and 'C'). If this use of jargon suggests to you that studying the anatomy of XPath may be worth the time spent -- you're right.

And in general you need to clean up, as in something like

<xsl:template match="C">
  <xsl:value-of select="@name"/>
  <xsl:if test="preceding::C[@name=current()/@name]">
   <xsl:text>_</xsl:text>
    <xsl:value-of select="../@number"/>
  </xsl:if>
</xsl:template>

I hope that helps--

Cheers,
Wendell

At 06:07 PM 3/31/2003, you wrote:
<xsl:template match="C">
    <xsl:for-each select="C">
        <xsl:choose>
        <xsl:when test="preceding::/*/*/C[@name=current()/@name]">
            <xsl:value-of select="current()/@name"/>_<xsl:value-of
select="../BOX/@number"/>
        </xsl:when>
        <xsl:otherwise>
            <xsl:value-of select="current()/@name"/>
        </xsl:otherwise>
    </xsl:for-each>
</xsl:template>

but this never produces the "_2" in "pen_2".

Any tip?


======================================================================
Wendell Piez                            mailto:wapiez@xxxxxxxxxxxxxxxx
Mulberry Technologies, Inc.                http://www.mulberrytech.com
17 West Jefferson Street                    Direct Phone: 301/315-9635
Suite 207                                          Phone: 301/315-9631
Rockville, MD  20850                                 Fax: 301/315-8285
----------------------------------------------------------------------
  Mulberry Technologies: A Consultancy Specializing in SGML and XML
======================================================================


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.