OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   RE: [xsl] Comparing XML, xsl:normalize-space and schemaTron

[ Lists Home | Date Index | Thread Index ]

> If I have the following XML instance document (notice the spaces) :-
> 
> <compare>
> 	<compareWith>   A</compareWith>
> 	<comparisonValues>
> 		<value>B</value>
> 		<value>   A   </value>
> 		<value>A </value>
> 	</comparisonValues>
> </compare>
> 
> and I use this expression :-
> 
> normalize-space(/compare/comparisonValues/value[3]) = 
> normalize-space(/compare/compareWith)
> 
> the result is true.
> 
> If I remove [3] it is an error ('too many items')

So presumably you are using XPath 2.0. In 1.0, it would simply take the
first node in the node-set.

> This seems OK (although it would be nice if I *could* use 
> normalize-space on 
> all of the nodes returned)

In 2.0, use /compare/compareWith/normalize-space(.) or

for $c in /compare/compareWith return normalize-space($c)

> I have also tried (successfully) using xsl:key + the key() 
> function to 
> create a set of the values in 1 document and then, using key(), check 
> whether the value of a node in the other document exists in 
> that set. This 
> worked and I was able to do the compare using 
> normalized-space values, but I 
> am a bit wary of whether this approach is costly in terms of 
> performance - 
> can anyone comment ??

Measure it and see. Keys usually improve performance provided you use them
more than once (well, say more than 5 times).

Michael Kay
http://www.saxonica.com/






 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS