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

Problem with selecting nodes

Subject: Problem with selecting nodes
From: "Denis Kranjcec" <denis.kranjcec@xxxxxx>
Date: Mon, 8 Oct 2001 16:49:12 +0200
color ccc
Hello everyone!

I have problem that I don't know how to solve (as usually :-)

In my application user should choose attributes which he wants to be
displayed, e.g. key1 and key3
Than my XSL should select only element ccc with key="key1" or key="key3"
with highest priority.
In my example that should be

in element bbb i="1":
<ccc key="key3" priority="3">
	<color>FF0000</color>
</ccc>

in element bbb i="2":
<ccc key="key1" priority="1">
	<color>0000FF</color>
</ccc>

because user has chosen only key1 and key3

Here is my sample XML:

<?xml version="1.0" encoding="UTF-8"?>
<aaa>
	<bbb i="1">
		<ccc key="key1" priority="1">
			<color>0000FF</color>
		</ccc>
		<ccc key="key2" priority="2">
			<color>00FF00</color>
		</ccc>
		<ccc key="key3" priority="3">
			<color>FF0000</color>
		</ccc>
	</bbb>
	<bbb i="2">
		<ccc key="key1" priority="1">
			<color>0000FF</color>
		</ccc>
		<ccc key="key2" priority="2">
			<color>00FF00</color>
		</ccc>
	</bbb>
</aaa>


I have tried with this XSL:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:param name="key1"  select="1"/>
	<xsl:param name="key2"  select="0"/>
	<xsl:param name="key3"  select="1"/>

	<xsl:template match="/">
		<xsl:apply-templates select="aaa/bbb"/>
	</xsl:template>

	<xsl:template match="bbb">
		<xsl:apply-templates select="ccc[($key1 and @key='key1') or ($key2 and
@key='key2')
			or ($key3 and @key='key3')]">
		</xsl:apply-templates>
	</xsl:template>

</xsl:template>

which select only elements bbb with atribut key which user has selected,
but doesn't select only element bbb with highest priority.
Result is:

in element bbb i="1":
<ccc key="key1" priority="1">
	<color>0000FF</color>
</ccc>

<ccc key="key3" priority="3">
	<color>FF0000</color>
</ccc>

in element bbb i="2":
<ccc key="key1" priority="1">
	<color>0000FF</color>
</ccc>


Any suggestions are apprecited.
Thanks in advance,
Denis Kranjcec


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


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.