[xsl] problems with xslt on "open" catalog-formats like ecXML oder xCBL

Subject: [xsl] problems with xslt on "open" catalog-formats like ecXML oder xCBL
From: "Hayk, Matthias" <Matthias.Hayk@xxxxxxxxxx>
Date: Mon, 28 Apr 2003 14:19:31 +0200
Hello,

I am dealing with a product catalog delivered in the xml-standard ecXML 3.0
from Requisite. From this product catalog i want to create a dynamic
web-navigation with to select our different products with a web-client.
One specific item on that xml-format is, that using that xml-format you can
design your own structure for your catalog. to achieve this, the attributes
for a product are not fix xml-elements, which are declared in a dtd or
schema-file. all "own" attributes are stored in key/value elements to a
product.

for example

<!-- A new Product comes with an ITEM-Element-Tag and the action attribute
holds the action to do for that product -->
<ITEM action = "ADD">
	<KEYVALUE>
		<KEY>
			Suplier Name
		</KEY>
		<VALUE>
			abc enterprises
		</VALUE>
	</KEYVALUE>
	<KEYVALUE>
		<KEY>
			Suplier Number
		</KEY>
		<VALUE>
			123
		</VALUE>
	</KEYVALUE>
	<KEYVALUE>
		<KEY>
			PartNum
		</KEY>
		<VALUE>
			4711
		</VALUE>
	</KEYVALUE>
	<KEYVALUE>
		<KEY>
			length
		</KEY>
		<VALUE>
			100
		</VALUE>
	</KEYVALUE>
	<KEYVALUE>
		<KEY>
			price
		</KEY>
		<VALUE>
			123.45
		</VALUE>
	</KEYVALUE>

This brings some difficulties when making a selection on the product catalog
with xslt
When i want to get the prices for all products with a length of 100 i CAN'T
make an XPATH /XLST like this

	<xsl:for-each select="//ITEM[length=100]">
		the price for <xsl:value-of select="partnum"/> is
<xsl:value-of select="price"/>
	<xsl:for-each>

because there are not length-attribute and partnum or price elements. 

my actual way is:

	<xsl:for-each
select="//ITEM/KEYVALUE/KEY[text()='length']/following-sibling::*[text()='10
0']/../..">
		the price for <xsl:value-of
select="KEYVALUE/KEY[text()='partnum']/following-sibling::*"/> is
<xsl:value-of select="KEYVALUE/KEY[text()='price']/following-sibling::*"/>
	<xsl:for-each>

MY QUESTIONS now are:

a) is there a more elegant way to select product-items based on the values
of specific product-attributes defined in the KEYVALUE/KEY and
KEYVALUE/VALUE strucutres. it works but gets more complex when there is more
than one search-condition for the selection

b) i want to sort the product-items in that for-loop based on the values. So
i want to sort the products with length of 100 on their price-value.
I didn't found a working <xsl:sort> selection for it.

regards
matthias hayk





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


Current Thread