[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: which is faster?

Subject: Re: which is faster?
From: tom.kirkpatrick@xxxxxxxxxxxx
Date: Fri, 4 Feb 2005 12:38:54 +0000
xsl varaiable
so...

<xsl:for-each select = //embededMalware/malwareFamily">
<xsl:if test 
="document('/global/malwareFamilies.xml')/malwareFamilies/malwareFamily[@id 
= current()/@id]">
...
</xsl:if>

<xsl:value-of select = "@id"/>
</xsl:for-each>

I would think that current()/@id in the predictate holds the same value as 
<xsl:value-of select = "@id"/>. Is that correct?





David Carlisle <davidc@xxxxxxxxx>
04/02/2005 12:26
Please respond to xsl-list

 
        To:        xsl-list@xxxxxxxxxxxxxxxxxxxxxx
        cc: 
        Subject:        Re:  which is faster?




<xsl:for-each select = //embededMalware/malwareFamily">
<xsl:if test 
="document('/global/malwareFamilies.xml')/malwareFamilies/malwareFamily[@id
= current()/@id]">

<xsl:call-template name="displayPrevalenceReport">
<xsl:with-param name="malwareFamilyId" select="@id"/>
<xsl:with-param name="items" select="5"/>
<xsl:with-param name="method" select="'lite'"/>
</xsl:call-template>

</xsl:if>
</xsl:for-each>

the problem seems to lay within my use of current()/@id in the predictate
and/or @id as the malwareFamilyId parameter.

If instead, I store the @id attribute in a variable, and then use that
variable throuought the for-each loop it all works ok. Why is this? Surely
the context hasn't changed along the way has it? Looking at that, to me it
looks as if
document('/global/malwareFamilies.xml')/malwareFamilies/malwareFamily is
the current contxt throughought the for-each loop,


No the current node for each iteration of the for-each is a
malwareFamily  element from the current document.

document('/global/malwareFamilies.xml')/malwareFamilies/malwareFamily

is the current node only within the [] at the end of your test
expression.

so where you have

[@id  = current()/@id]

@id referes to the id of an element in malwareFamilies.xml and
current()/@id refers to the id element of the malwareFamily element in
the current document that you are for-eaching over.

It is equivalent to

<xsl:for-each select = //embededMalware/malwareFamily">
<xsl:varaiable name="thisid" select="@id"/>
<xsl:if test 
="document('/global/malwareFamilies.xml')/malwareFamilies/malwareFamily[@id
= $thisid]">

You said that you used a variable to make things work but you didn't say
where.

David


________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________




-- 
Tom David Kirkpatrick
Virus Bulletin Web Developer, Virus Bulletin

Tel: +44 1235 555139
Web: www.virusbtn.com

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.