xsl-list
[Top] [All Lists]

Re: interesting? problem

2003-07-07 12:10:02
At 2003-07-07 18:16 +0000, =?big5?B?qkwgpGyq5A==?= wrote:
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)
...
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.

Yes, it is quite straightforward, but you are not considering that what you want is a path where an f child exists where the two conditions are true within that child. When you think of it that way, you'll get the right result, as shown below.

I hope this helps.

......................... Ken

t:\ftemp>type kit.xml
<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>

t:\ftemp>type kit.xsl
<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
                version="1.0">

<xsl:template match="xml">
  <xml>
    <xsl:copy-of select="path[f[i = '1' and t = '1']]"/>
  </xml>
</xsl:template>

</xsl:stylesheet>
t:\ftemp>saxon kit.xml kit.xsl
<?xml version="1.0" encoding="utf-8"?><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>
t:\ftemp>


--
Upcoming hands-on courses: in-house corporate training available;
North America public:  XSL-FO Aug 4,2003; XSLT/XPath Aug 12, 2003

G. Ken Holman                mailto:gkholman(_at_)CraneSoftwrights(_dot_)com
Crane Softwrights Ltd.         http://www.CraneSoftwrights.com/s/
Box 266, Kars, Ontario CANADA K0A-2E0   +1(613)489-0999 (F:-0995)
ISBN 0-13-065196-6                      Definitive XSLT and XPath
ISBN 0-13-140374-5                              Definitive XSL-FO
ISBN 1-894049-08-X  Practical Transformation Using XSLT and XPath
ISBN 1-894049-11-X              Practical Formatting Using XSL-FO
Member of the XML Guild of Practitioners:    http://XMLGuild.info
Male Breast Cancer Awareness http://www.CraneSoftwrights.com/s/bc


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



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