xsl-list
[Top] [All Lists]

interesting? problem

2003-07-07 11:16:22
Hi,
Can anyone help me over this problem i had with a stylesheet. suppose i have an 
xml like this:

<xml>
<path>
<f>
<i>1</i><t>1</t>
</f>
<f>
<i>2</i><t>2</t>
</f>
<f>
<i>3</i><t>3</t>
</f>
</path>
<path>
<f>
<i>1</i><t>2</t>
</f>
<f>
<i>2</i><t>1</t>
</f>
</path>
<path>
<f>
<i>1</i><t>4</t>
</f>
<f>
<i>3</i><t>3</t>
</f>
<f>
<i>4</i><t>2</t>
</f>
</path>
</xml>

what i want to find is a path node that contain i= 1 and t = 1 where i and t is 
in the same node (i.e. in the
same f node) so the result i want from the above xml is:
<xml>
<path>
<f>
<i>1</i><t>1</t>
</f>
<f>
<i>2</i><t>2</t>
</f>
<f>
<i>3</i><t>3</t>
</f>
</path>
</xml>

and i was wondering, is it possible to get the above with ONE query statement?
something like this:
ex. 1
<xsl:template match="xml">
<xml> <xsl:copy-of select="path[f/i = '1' and f/t = '1']"/>
</xml>
</xsl:template>

obviously this doesn't work as this query will copy the first two path nodes.

i know this will work if i go down to the bottom level and do something like 
this:
ex. 2
<xsl:template match="xml">
<xsl:for-each select="path">
        <xsl:for-each select ="f[i='1' and t='1']">
        <xsl:copy-of select="../."/>    
        </xsl:for-each>
</xsl:for-each>
</xsl:template>

but i want to get the correct results without going down to the bottom level, so i was wondering, whether it is possible to query the node at the xml level (like ex. 1)
i hope this is not confusing and i really appreicate your time.

Thanks in advance

regards
Kit

_________________________________________________________________
使用 MSN Messenger,與朋友在線上聊天: http://messenger.microsoft.com/tc

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



<Prev in Thread] Current Thread [Next in Thread>