xsl-list
[Top] [All Lists]

Re: which is faster?

2005-02-04 05:26:16

  
  <xsl:for-each select = //embededMalware/malwareFamily">
  <xsl:if test 
="document('/global/malwareFamilies.xml')/malwareFamilies/malwareFamily[(_at_)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

[(_at_)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[(_at_)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
________________________________________________________________________

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



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