XPath expression and xsl:when

Discussion in 'XML' started by gimme_this_gimme_that@yahoo.com, Apr 26, 2005.

  1. Guest

    What xpath expression would return the category-item having uid sps002
    ?


    <category-list>
    <category>
    <uid>GRIDS_MAIN_CATEGORY_UID</uid>
    <uid-type>Categories</uid-type>
    <category-item-list>
    <category-item>
    <uid>sps0002</uid>
    <uid-type>Grids</uid-type>
    </category-item>
    <category-item>
    <uid>sps0005style0003</uid>
    <uid-type>Grids</uid-type>
    </category-item>
    </category>
    <category>
    <uid>GRIDS_MAIN_CATEGORY_UID</uid>
    <uid-type>Categories</uid-type>
    <category-item-list>
    <category-item>
    <uid>sps0002</uid>
    <uid-type>Grids</uid-type>
    </category-item>
    <category-item>
    <uid>sps0005style0003</uid>
    <uid-type>Grids</uid-type>
    </category-item>
    </category>
    </category-list>

    I've tried the following Xpath expression ... :

    <xsl:when
    test="'sps0002'=//category-list/category/category-item-list/category-item/uid">
    <xsl:value-of select="./uid"/>

    Which doesn't work. (Help!)

    But actually, what I'd really like is an Xpath expression
    that would fetch this node directly without using a xsl:when.

    What I'm actually doing is checking if a node with an id of sps002
    exists in a JDOM Element using it's the JDOM XPath object. This returns
    either an Element or an Attribute. But right now I'm having to
    fetch all the category-item Elements and iterate through them to
    determine
    if one with an sps002 id exists.

    Thanks.
    , Apr 26, 2005
    #1
    1. Advertising


  2. > What xpath expression would return the category-item having uid sps002


    /category-list/category/category-item-list/category-item[uid='sps2002']

    <xsl:when
    test="'sps0002'=//category-list/category/category-item-list/category-item/uid">


    That tests if there us any uid anywhere in the document that has this
    value, so it will be always true or always false depending on whether
    such a node exists.

    <xsl:value-of select="./uid"/>

    so this will select the uid child of the current node whether or not
    this is the node taht has the specified uid.

    David
    David Carlisle, Apr 26, 2005
    #2
    1. Advertising

  3. Guest

    Man .. The people on this list are *so* helpful. Thanks.
    , Apr 26, 2005
    #3
    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,971
    jan V
    Jul 29, 2005
  2. GIMME
    Replies:
    3
    Views:
    11,958
    vforvikash
    Dec 29, 2008
  3. kurt hansen
    Replies:
    1
    Views:
    1,041
    David Carlisle
    Sep 7, 2004
  4. Replies:
    1
    Views:
    3,600
    A. Bolmarcich
    May 27, 2005
  5. Tjerk Wolterink
    Replies:
    2
    Views:
    611
    Florent Georges
    Dec 24, 2005
Loading...

Share This Page