This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: FW: xpath expression needed
- To: xsl-list at lists dot mulberrytech dot com
- Subject: Re: FW: [xsl] xpath expression needed
- From: Manu KY <manu_kry at yahoo dot com>
- Date: Sat, 06 Oct 2001 21:37:43 +0530
- Reply-To: xsl-list at lists dot mulberrytech dot com
hi guys,
this should do the trick.
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="doc">
<xsl:for-each select="level1">
<xsl:if test="field2/text()='some'">
<matchField1>
<xsl:element name="field1">
<xsl:value-of select="field1"/>
</xsl:element>
</matchField1>
</xsl:if>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
PS: i have added doc element as the document element node.
Manu
>I have a very similar issue, except the nodes (in my case attributes) I want
>to match doesn't have a definite value. Let me try to make this clearer.
>
><level1 name='a' type='1'>
> <field1>value1</field1>
> <field2>some</field2>
> <field3>value3</field3>
></level1>
><level1 name='b' type='1'>
> <field1>value1</field1>
> <field2>some</field2>
> <field3>value3</field3>
></level1>
><level1 name='c' type='2'>
> <field1>value1</field1>
> <field2>someother</field2>
> <field3>value3</field3>
></level1>
>
>I want to match all nodes whose following-sibling::level1 has the same value
>for @type. So in this case, only the first 'level1' node would be matched.
>
>How about:
>
>level1[@type = following-sibling::level1/@type]
>
>Would that work?
>
>-----Original Message-----
>From: Sanjay Pandey/Towers Perrin [mailto:pandeys@towers.com]
>Sent: Thursday, September 20, 2001 3:14 PM
>To: xsl-list@lists.mulberrytech.com
>Subject: [xsl] xpath expression needed
>
>
>
>Hi List,
>
>I have a XML as follows
>
><level1 name = 'a'>
> <field1>value1</field1>
> <field2>some</field2>
> <field3>value3</field3>
></level1>
><level1 name='b'>
> <field1>value1</field1>
> <field2>some</field2>
> <field3>value3</field3>
></level1>
><level1 name='c'>
> <field1>value1</field1>
> <field2>someother</field2>
> <field3>value3</field3>
></level1>
>
>I want to get all the occurrences of "field1" whose first following-sibling
>"field2" has a value = "some". In this case it should return me 2nodes
>(except the last one, where the value would be "someother")
>
>Hope I am clear.
>
>Thanks,
>Sanjay
>
>
>
> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
>
> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list