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

RE: Comparing One element's text to multiple elements'

Subject: RE: Comparing One element's text to multiple elements' text
From: "Daniel Joshua" <daniel.joshua@xxxxxxxxxxxx>
Date: Fri, 7 May 2004 12:43:42 +0800
xsl if compare text
Yup... I solved it by using...

      <xsl:if test="value2[option=../value1]">

Thanks for your help Kenny... just needed something to kickstart my brain.


Regards,
Daniel


-----Original Message-----
From: Kenny Akridge [mailto:kenny@xxxxxxxxxxxxxxxxx]
Sent: Friday, 07 May, 2004 12:40 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: RE:  Comparing One element's text to multiple elements'
text


I see.  Yes, if you also have other elements, then you would need to use
value2/option instead of value2/*.  It seems like you have a handle on the
problem though.

Take care,
Kenny Akridge

-----Original Message-----
From: Daniel Joshua [mailto:daniel.joshua@xxxxxxxxxxxx]
Sent: Friday, May 07, 2004 12:28 AM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: RE:  Comparing One element's text to multiple elements' text

Thanks Kenny... that worked. But your solution will also select other
elements besides 'option'.

I forgot [ ] is only for attributes. Ooops!

Btw, the match="root" problem was added when I simplified everything for
this mail. :p


Regards,
Daniel



-----Original Message-----
From: Kenny Akridge [mailto:kenny@xxxxxxxxxxxxxxxxx]
Sent: Friday, 07 May, 2004 12:09 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: RE:  Comparing One element's text to multiple elements'
text


The first problem you have is [*].  You should change this to value2/*. This
means it will check all children of value2.

The next problem is the context of your template.  You are looking at "/".
In this case, you are testing value1 = value2/*.  The problem is that "/" is
not the same as <root>.  So you can do one of two things:

  <xsl:template match="root">
    <xsl:if test="value1 = value2/*">
      <xsl:text>true</xsl:text>
    </xsl:if>
  </xsl:template>

or

  <xsl:template match="/">
    <xsl:if test="//value1 = //value2/*">
      <xsl:text>true</xsl:text>
    </xsl:if>
  </xsl:template>


Good luck to you.

-Kenny Akridge
-----Original Message-----
From: Daniel Joshua [mailto:daniel.joshua@xxxxxxxxxxxx]
Sent: Thursday, May 06, 2004 11:49 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject:  Comparing One element's text to multiple elements' text

Hi,

I would like to compare one element's text value to a group of multiple
elements' text values. I tried, but I think I am not comparing the text
portion correctly.

Simplified XML:

<?xml version="1.0" encoding="iso-8859-1"?>
<?xml-stylesheet type="text/xsl" href="test.xsl"?>
<root>
  <value1>ABC</value1>
  <value2>
    <option>ABC</option>
    <option>DEF</option>
    <option>HIJ</option>
  </value2>
</root>

Simplified XSL:

<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

  <xsl:template match="/">
    <xsl:if test="value1 = value2/option[*]">
      <xsl:text>true</xsl:text>
    </xsl:if>
  </xsl:template>

</xsl:stylesheet>


Regards,
Daniel

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.