p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

xslt thread: TWO XML DOCS CONTINUED


Message #1 by "Claudio Pallone" <pallone@l...> on Fri, 20 Sep 2002 22:47:52
Hi Lisa,

Yes please, I would appreciate if you could offer more help. It is not 
clear to me how to do that.
I think I understand this code: <xsl:variable 
name=3D"lookup"select=3D"document('AllSurveys.xml')"/>
Basically we use it to load the AllSurveys.xml. One question though, 
could I change the path like:

document('../XMLDOC/AllSurveys.xml')   ???????

Now after this doc is loaded how do i compare its nodes with the other 
xml?

<xsl:for-each select=3D"$lookup/Survyes>
	if the children of the Document element Surveys (AllSurveys.xml) =3D 
children of document element Surveys 	(ThisUserSurvey.xml ) 
		write them to the output
	end if.

I do not understand how to do that!

Cheers,

Claudio


>Subject: Re: TWO XML DOCS CONTINUED
>From: "Lisa Slater Nicholls" <lisa@s...>
>Date: Sat, 21 Sep 2002 01:58:01
>X-Message-Number: 2

>>
>So, I think it would be better to pass the ThisUserSurvey.xml as a =3D
parameter to this specific transformation.
[...]
 How do I do something like this:

<xsl:for-each select=3D3D"document('ThisUserSurvey.xml')">
<<

I'm not entirely sure that this is the best way, from what you're 
saying,
Claudio.  If the larger document is on disk, then you could put it in as 
a
top-level variable like this:

<xsl:variable name=3D"lookup"select=3D"document('AllSurveys.xml')"/>

Now it can be compiled into a template object for all transforms.  At
runtime, make the ThisUserSurvey.xml document your source.

If this seems backwards to you, you can do it the other way around
(ThisUserSurvey can be the lookup and you run the transform on
AllSurveys) -- but then you can't compile the larger document into the
template, you have to load the changing, single user documents up into 
an
xsl:param for each transform.

It's hard to say which would give you better performance -- for one 
thing,
I don't know the relative sizes of these documents! <s>

Meanwhile, to answer your question, you refer to the loaded document (no 

matter which one it is)like this: $lookupSurveys. You can use XPath on
this, just as you would for the normal document.  For example, you could 

say:

<xsl:for-each select=3D"$lookup/root/survey[@class=3D'myuserclass']">

This example is not taken from the XML that you show because, to be
honest, I'm not taking the time to look at them. <s> If this explanation 

doesn't help enough, I'll try again when I have more time.

>L<


BMRB International
http://www.bmrb.co.uk +44 (0)20 8566 5000
____________________________________________________________
This message (and any attachment) is intended only for the recipient and 
may contain confidential and/or privileged material. If you have 
received this in error, please contact the sender and delete this 
message immediately. Disclosure, copying or other action taken in 
respect of this email or in reliance on it is prohibited. BMRB 
International Limited accepts no liability in relation to any personal 
emails, or content of any email which does not directly relate to our 
business.

  Return to Index