[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Finding paths in Visio XML exports - recursion q
G. Ken Holman wrote:
At 2008-09-27 20:20 +0100, Steven Davies wrote:Now, I can use an XPath expression to find the first node in the document easily enough (it has a certain property in its data set to "1") and the only way I've been able to find all connected shapes from this one is to use 3 for-each loops: the first over all <Connect>s beginning at the shape itself, the second nested loop over all other endpoints of the <Connect> (there will only ever be one) and the third over all <Shape>s connected to the <Connect>: Thanks, that really helped. Now I have the following XPath in one loop instead of the three for-each loops: <xsl:for-each select="../v:Shape[@ID=../../v:Connects/v:Connect[@FromSheet=../v:Connect[@ToSheet=current()/@ID and @FromCell='BeginX']/@FromSheet and @FromCell='EndX']/@ToSheet]"> This basically does the same as the three loops but in one statement - however, it now takes a very long time to run - over a minute as opposed to about a second. This isn't a major issue as it won't be run very frequently but do you know why this performance hit might have happened? Inside the innermost xsl:for-each I recursively call the template which works very well for a straight flow in Visio. However, there can be infinite loops in the flow so I have to first test whether the <Shape> has already been output before recursing. This works. Sorry, I'm not too brilliant at explaining things..I mean that for every new connected shape the template is called recursively so that when it gets to the end of a branch the template 'un-recurses' however many times there are objects in the branch. Does anyone have an idea how to get around this? Yes, I thought that might happen! I've created a sample Visio document and uploaded it along with a PDF of what it looks like: http://www.steev.me.uk/~steven/simpleVisio.xml http://www.steev.me.uk/~steven/simpleVisio.pdf The XSL file I'm using is at: http://www.steev.me.uk/~steven/testplans.xsl It seems to work now but if anybody knows why there's such a performance penalty for using the XPath above I'd be very grateful to hear why! Thanks again, Steve
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|