Tuesday, 15 February 2011

xpath - How to trim the XSLT use attribute expression -



xpath - How to trim the XSLT use attribute expression -

i new xslt , have got special requirement. xml file looks below.

<results> <result> <price> <lineprices> <productid>productid:1000</productid> <uom>kg</uom> <quantity>0</quantity> </lineprices> <lineprices> <productid>productid:1002</productid> <uom>each</uom> <quantity>0</quantity> </lineprices> </price> </result> <result> <productlist> <productid>1000</productid> <relevance>0.9</relevance> <sponsored>0</sponsored> </productlist> <productlist> <productid>1001</productid> <relevance>0.8</relevance> <sponsored>0</sponsored> </productlist> </result> </results>

i have write xslt keys match pattern. have written key productlist shown below.

<xsl:key name="productsidforproduct" match="productlist" use="productid" />

in similar way trying write key lineprices shown below.

<xsl:key name="productsidprice" match="result/lineprices" use="productid" />

however returns 'productid:1000' in utilize attribute. trying trim 'productid:' utilize attribute value. how can write trim look extract '1000' 'productid:1000' within xpath expression?

just utilize substring-after():

substring-after(productid,':')

xslt xpath

No comments:

Post a Comment