[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: [xsl] Comparing XML, xsl:normalize-space and schemaTron
> 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/
|
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
|