xsl-list
[Top] [All Lists]

Re: [xsl] how to create variable by comparing two variables using [not]

2018-10-14 15:48:50


On 14 Oct 2018, at 21:16, Dave Lang emaildavelang(_at_)gmail(_dot_)com 
<xsl-list-service(_at_)lists(_dot_)mulberrytech(_dot_)com> wrote:

I think I did a poor job of explaining what I'm trying to do.

I have two lists of jpg names: $jpg_few and $jpg_many.

I know that there are jpg names in $jpg_many that are not in jpg_few, but 
that's okay, I'm not interested in them.

I'm trying to find what jpg names are in $jpg_few that are NOT in $jpg_many.

I thought I had tokenized $jpg_few and $jpg_many when I created them.

When I try to create a new variable by using a "not" expression with $jpg_few 
and $jpg_many, I get an error message re: "A sequence of more than one item 
is not allowed as the first argument of fn:tokenize()".

That error can only come from an expression that calls tokenize(). It's 
therefore clearly not your declaration of jpgs_in_xml_not_directories that's at 
fault.


I tried doing string-join to $jpg_few and $jpg_many before putting them in 
the expression but that didn't work either.

Here's the expression I'm trying to use to create a variable that shows which 
jpg names from $jpg_few are NOT in $jpg_many.

<xsl:variable name="jpgs_in_xml_not_directories" select="($jpg_few)[not(. = 
$jpg_many)]"/>

I think the problem is that I'm trying to do something with $jpg_few and 
$jpg_many that I can't do because they're strings or something, but this is 
where I get in over my head. 

It's a good idea to add a type declaration to your variables, e.g. 
as="xs:string*". This will help anyone reading your code (including you) to see 
what you think should be in the value of the variable, and if your assumptions 
are wrong then it will often lead to more focussed diagnostics.

Michael Kay
Saxonica
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--

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