Quick XSLT Question

Discussion in 'XML' started by Mike King, Jul 29, 2004.

  1. Mike King

    Mike King Guest

    Does the following code have any defined behavior in XSLT or XPath? I have
    tried this before and it didn't do what I thought it should do. Instead, I
    had to use the local-name() function and compare it with a string
    representing the element of interest.

    <xsl:if test=". = SomeElement">
    </xsl:if>
    Mike King, Jul 29, 2004
    #1
    1. Advertising

  2. "Mike King" <> writes:

    > Does the following code have any defined behavior in XSLT or XPath? I have
    > tried this before and it didn't do what I thought it should do. Instead, I
    > had to use the local-name() function and compare it with a string
    > representing the element of interest.
    >
    > <xsl:if test=". = SomeElement">
    > </xsl:if>



    it tests if the string value of the current node is equal to the string
    value of its SomeElement child so if the current element is x it would
    be true on

    <x><a/><b/><SomeElement>aaa</SomeElement></x>

    as they both have string value aaa.

    You probably wanted

    test="self::SomeElement"

    which tests if the current node is a SomeElement element.

    david
    David Carlisle, Jul 29, 2004
    #2
    1. Advertising

  3. Mike King

    Mike King Guest

    > it tests if the string value of the current node is equal to the string
    > value of its SomeElement child so if the current element is x it would
    > be true on
    >
    > <x><a/><b/><SomeElement>aaa</SomeElement></x>
    >
    > as they both have string value aaa.
    >
    > You probably wanted
    >
    > test="self::SomeElement"
    >
    > which tests if the current node is a SomeElement element.
    >
    > david



    Thank you very much!
    Mike King, Jul 29, 2004
    #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. Stylus Studio
    Replies:
    0
    Views:
    649
    Stylus Studio
    Aug 3, 2004
  2. Benjamin Hillsley
    Replies:
    3
    Views:
    1,673
    Dimitre Novatchev
    Sep 25, 2003
  3. ted
    Replies:
    1
    Views:
    619
    Laurens
    Jan 26, 2004
  4. JKop
    Replies:
    11
    Views:
    871
  5. Replies:
    18
    Views:
    2,752
    Joseph Kesselman
    Oct 4, 2006
Loading...

Share This Page