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

RE: Problem finding set difference on string values

Subject: RE: Problem finding set difference on string values
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Tue, 1 Jan 2008 10:52:15 -0000
RE:  Problem finding set difference on string values
It might be that your input file contains CRLF rather than LF line endings.
The unparsed-text() function does not normalize line endings, and the regex
\n matches LF only. Use normalize-space() after tokenizing, or use \r?\n (or
perhaps even \s+) as the regex in tokenize().

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

> -----Original Message-----
> From: Mukul Gandhi [mailto:gandhi.mukul@xxxxxxxxx] 
> Sent: 01 January 2008 10:20
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  Problem finding set difference on string values
> 
> Hi all,
>    I am facing some problem calculating set difference on 
> string values.
> 
> The problem details are below.
> 
> I have a text file, data.txt which contain information as below:
> abc
> pqr
> mno
> uvw
> (here, each data element is delimited by a newline)
> 
> My XSLT 2.0 stylesheet is following:
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>                         version="2.0">
> 
>  <xsl:output method="text" />
> 
>  <xsl:variable name="list1"
> select="tokenize(unparsed-text('data.txt'), '\n')" />  
> <xsl:variable name="list2" select="('abc', 'pqr', 'ok')" />
> 
>  <xsl:template match="/">
>    <xsl:for-each select="$list2[not(. = $list1)]">
>      <xsl:value-of select="." /><xsl:text>&#xa;</xsl:text>
>    </xsl:for-each>
>  </xsl:template>
> 
> </xsl:stylesheet>
> 
> I want to find elements in 'list2' which are not present in text file.
> 
> I am expecting answer:
> ok
> 
> But the output produced is:
> abc
> pqr
> ok
> 
> What am I doing wrong?
> 
> I would appreciate help for this problem ...
> 
> I am using Saxon 9-b.
> 
> --
> Regards,
> Mukul Gandhi

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.