[Home] [By Thread] [By Date] [Recent Entries]
Oleg, first off, kudos on the thought you're bringing to bear on what you
say is a new subject.
I have the following data (leaves in parallel branches): mystruct/myarray1[i]/myvar/var2 and mystruct/myarray2[i]/myvar/var3 You're approaching this procedurally, it seems, whereas you'd be better served using XSL's natural declarative model. Like with SQL, for example. Thus, rather than trying to pick through and find a specific node or value in imperative fashion, try to "describe" to the processor what you're looking for. For example, with this XML input: <mystruct>
<myarray>
<myvar>22</myvar>
<myvar>2</myvar>
<myvar>3</myvar>
<myvar>5</myvar>
<myvar>77</myvar>
<myvar>78</myvar>
<myvar>1</myvar>
</myarray>
</mystruct>This XSL will find the fist <myvar> node whose value is 1 less than it's immediately succeeding <myvar> sibling: <?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output indent="yes" method="xml" omit-xml-declaration="yes"/> <xsl:template match="/"> <node> <xsl:copy-of select="mystruct/myarray/myvar[. = following-sibling::myvar[1] - 1][1]"/> </node> </xsl:template> </xsl:stylesheet> Yields: <node> <myvar>2</myvar> </node> You should be able to do something similar for your problem. Regards, --A
_________________________________________________________________ Express yourself instantly with MSN Messenger! Download today - it's FREE! http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
|

Cart



