Subject: Re: [xsl] problems with xslt on "open" catalog-formats like ecXML oder xCBL From: "J.Pietschmann" <j3322ptm@xxxxxxxx> Date: Mon, 28 Apr 2003 18:12:36 +0200 |
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.
You could use a key :-) <xsl:key name="items-by-length" match="ITEM" use="KEYVALUE[KEY='length']/VALUE"/>
Use as <xsl:for-each select="key('items-by-length','100')> <xsl:value-of select="KEYVALUE[KEY='price']/VALUE"/> </xsl:for-each>
Note that the above will not work on the XML you supplied with the mail because of the whitespace surrounding all values.
<KEY> Suplier Name </KEY>
I hope your original XML is more like <KEYVALUE> <KEY>Suplier Number</KEY> <VALUE>123</VALUE> </KEYVALUE>
If not, you'll have to use normalize-space() a lot: <xsl:key name="items-by-length" match="ITEM" use="normalize-space(KEYVALUE[normalize-space(KEY)='length']/VALUE)"/> ... <xsl:for-each select="key('items-by-length','100')> <xsl:value-of select="normalize-space(KEYVALUE[ normalize-space(KEY)='price']/VALUE)"/> </xsl:for-each>
Note that normalize-space may have the unwanted side effect of normalizing spaces within keys and values too.
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] problems with xslt on "open" , Hayk, Matthias | Thread | AW: AW: [xsl] two nodes (or attribu, Zink, Juergen |
[xsl] Transform XML to HTML, Andreas Grytz | Date | [xsl] japanese sorting, Paul Hermans |
Month |