Xpath question

Discussion in 'XML' started by mikael petterson, Sep 16, 2003.

  1. Hi,

    I am selecting all <raisesException>-tags. The output must look like this;

    throws TestFailedException, CorruptHardwareException,
    TemporarySwFailureException;

    throws
    TestFailedExceptionCorruptHardwareExceptionTemporarySwFailureException, ;

    I need to have a comma ( ,) between all exceptions until the last were I
    only have a semicolon ( ;).

    Any hints?

    //Mikael

    This is the xsl I have:
    ==============
    <xsl:for-each select="raisesException"><xsl:value-of select="@name"/>
    <xsl:if
    test="raisesException[not[position()=last()]]"><xsl:text>,</xsl:text></xsl:i
    f>
    </xsl:for-each>;
     
    mikael petterson, Sep 16, 2003
    #1
    1. Advertising

  2. In article <bk70d5$f6d$>,
    mikael petterson <> wrote:

    % This is the xsl I have:
    [or part of it at any rate]

    % <xsl:for-each select="raisesException"><xsl:value-of select="@name"/>
    % <xsl:if
    % test="raisesException[not[position()=last()]]"><xsl:text>,</xsl:text></xsl:i
    % f>

    1st problem: you want not(position()=last()), rather than not[...].
    2nd problem: that's all you want in the test

    <xsl:for-each select="raisesException">
    <xsl:value-of select="@name"/>
    <xsl:if test="not(position()=last())"><xsl:text>,</xsl:text></xsl:if>
    </xsl:for-each>
    <xsl:text>;
    </xsl:text>

    --

    Patrick TJ McPhee
    East York Canada
     
    Patrick TJ McPhee, Sep 16, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Marvin_123456

    "Memory leak" in javax.xml.xpath.XPath

    Marvin_123456, Jul 29, 2005, in forum: Java
    Replies:
    4
    Views:
    1,976
    jan V
    Jul 29, 2005
  2. Alastair Cameron
    Replies:
    1
    Views:
    7,418
    SQL Server Development Team [MSFT]
    Jul 8, 2003
  3. Anna
    Replies:
    0
    Views:
    529
  4. goog
    Replies:
    0
    Views:
    512
  5. Tjerk Wolterink

    XPath: efficiency in xpath expressions

    Tjerk Wolterink, Nov 13, 2004, in forum: XML
    Replies:
    1
    Views:
    1,644
    Richard Tobin
    Nov 13, 2004
Loading...

Share This Page