This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Selecting /getting only one node value out of the many identical values


I am  not sure if this is basic question but even a hint in the form of
statement  / query may be of help.

I have an XML like this


<?xml version="1.0" encoding="UTF-8"?>
<clothes>
<category name="shirts">
	<sno times="1">
		<brand>Arrow</brand>
		<size>X-L</size>
		<color>red</color>	</sno>

	<sno times="2">
		<brand>Arrow</brand>
		<size>Med</size>
		<color>blue</color>	</sno>

	<sno times="3">
		<brand>Arrow</brand>
		<size>L</size>
		<color>red</color>	</sno>

	<sno times="4">
		<brand>Lee</brand>
		<size>X-L</size>
		<color>green</color>	</sno>
</category>
</clothes>

this XML is genereted based on query from a user and comes from a database.
I want to display to the user only  the available "brands"  of shirts
Ie. output shall be only
"Arrow" and "Lee" in my case. and the user can then  further query on the
subitems like "size" and "color". SO I want a
< Select "brand"  from "clothes/category/sno" where "there is no repetiion"
>  (:-)
sort of query. I hope I could make myself clear.
what XSL query can I write for this!
Thanks for the attenttion


Tapan Nanawati
tapan_nanawati@yahoo.com
91-11-6685274 (o)
91-98112-98982 (m)
New Delhi - INDIA
------------------------------
God is real, unless declared integer.


$-----Original Message-----
$From: owner-xsl-list@lists.mulberrytech.com
$[mailto:owner-xsl-list@lists.mulberrytech.com]On Behalf Of Zeynep Gunal
$Sent: Thursday, March 01, 2001 10:44 PM
$To: 'xsl-list@lists.mulberrytech.com'
$Subject: [xsl] selecting only one among many matching nodes..
$
$
$Hi,
$
$I have an XML that looks like this (I simplified the real one):
$
$<AAA>
$   <code>123</code>
$   <BBB>
$      <str1>abc</str1>
$      <str2>def</str2>
$      <str3>ghi</str3>
$   <BBB>
$   <CCC>
$      <type>1</type>
$      <code>123</code>
$      <ret>5</ret>
$      <DDD>
$         <str1>abc</str1>
$         <str2>def</str2>
$         <str3>ghi</str3>
$      </DDD>
$   </CCC>
$   <CCC>
$      <type>3</type>
$      <code>123</code>
$      <ret>3</ret>
$      <DDD>
$         <str1>abc</str1>
$         <str2>def</str2>
$         <str3>ghi</str3>
$      </DDD>
$   </CCC>
$   <CCC>
$      <type>2</type>
$      <code>123</code>
$      <ret>1</ret>
$      <DDD>
$         <str1>ABC</str1>
$         <str2>DEF</str2>
$         <str3>GHI</str3>
$      </DDD>
$   </CCC>
$   <CCC>
$      <type>0</type>
$      <code>123</code>
$      <ret>4</ret>
$      <DDD>
$         <str1>abc</str1>
$         <str2>def</str2>
$         <str3>ghi</str3>
$      </DDD>
$   </CCC>
$</AAA>
$
$I need to find the smallest 'ret' value where:
$
$AAA/code = AAA/CCC/code         and
$AAA/BBB/str1 = AAA/CCC/DDD/str1 and
$AAA/BBB/str2 = AAA/CCC/DDD/str2 and
$AAA/BBB/str3 = AAA/CCC/DDD/str3
$
$which is here 3.
$
$I am using XSLT, and I have been struggling for hours now, I searched the
$archives, I found one similar question, but no answer and I could
$not find a
$solution myself either. The only way I can think of doing it is using
$something like do-while, but such an element/function is not supported by
$XSLT.
$
$Is there a solution?
$
$Thanks in advance,
$
$Zeynep
$
$ XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]