Problem with 'Or' operator in '<xsl:if>' statement

Problem with 'Or' operator in '<xsl:if>' statement

Post by Diego TERCER » Thu, 24 Apr 2003 18:41:10



Hi everyone,

I'm using MSXML 3.0 to do XML -> HTML transformations.

I have documents of type 'Contenu' (content) wich may be articles
(Contenu/Article) or Dossiers (Contenu/Dossier).

Any of these contents have an issue origin (Contenu/*/Origine/Parution)

For some of those articles or dossiers I would like to display their Teaser
(Contenu/*/Accroche/Parag).
Only for those articles for which issue origin is '01net' or '01net.'

So here's my <xsl:if> statement (I only want to get those teasers that have
some text content). (I'm in a 'Contenu' context) so
the '*' applies to either an 'Article' or 'Dossier'
    <xsl:if test="*/Accroche/Parag[*/Origine/Parution = '01net.' Or
*/Origine/Parution = '01net']/text())">

But I get the following error :

a.. Error type :
msxml3.dll (0x80004005)
Expected token ']' found 'NAME'. */Accroche/Parag[*/Origine/Parution =
'01net.' -->Or <--*/Origine/Parution = '01net']/text())

The funny thing is that when I rewrite the test expression using 'And'
operators and negations, it works ! :
<xsl: if test="not(*/Accroche/Parag[*/Origine/Parution != '01net' And
*/Origine/Parution != '01net.']/text())">

Can someone explain to me why it works using 'And' and negation (not()) but
doesn't work using 'Or' operator ?

Greetings,
Diego Tercero
Design & programming engineer
Eurocortex
http://www.eurocortex.fr
16, avenue de l'Europe
31520 Ramonville - France
Tl: 33 (0) 5 62 88 33 83
Fax: 33 (0) 5 62 88 33 46

 
 
 

Problem with 'Or' operator in '<xsl:if>' statement

Post by Oleg Tkachenk » Thu, 24 Apr 2003 19:05:55



> I have documents of type 'Contenu' (content) wich may be articles
> (Contenu/Article) or Dossiers (Contenu/Dossier).

> Any of these contents have an issue origin (Contenu/*/Origine/Parution)

> For some of those articles or dossiers I would like to display their Teaser
> (Contenu/*/Accroche/Parag).
> Only for those articles for which issue origin is '01net' or '01net.'

> So here's my <xsl:if> statement (I only want to get those teasers that have
> some text content). (I'm in a 'Contenu' context) so
> the '*' applies to either an 'Article' or 'Dossier'
>     <xsl:if test="*/Accroche/Parag[*/Origine/Parution = '01net.' Or
> */Origine/Parution = '01net']/text())">

> But I get the following error :

> a.. Error type :
> msxml3.dll (0x80004005)
> Expected token ']' found 'NAME'. */Accroche/Parag[*/Origine/Parution =
> '01net.' -->Or <--*/Origine/Parution = '01net']/text())

> The funny thing is that when I rewrite the test expression using 'And'
> operators and negations, it works ! :
> <xsl: if test="not(*/Accroche/Parag[*/Origine/Parution != '01net' And
> */Origine/Parution != '01net.']/text())">

> Can someone explain to me why it works using 'And' and negation (not()) but
> doesn't work using 'Or' operator ?

There is no "And" or "Or" opeartors in XPath, there are "and" and "or".
Remember - all things are case-sensitive in XML.

--
Oleg Tkachenko
http://www.tkachenko.com/blog
Multiconn Technologies, Israel

 
 
 

Problem with 'Or' operator in '<xsl:if>' statement

Post by Diego TERCER » Thu, 24 Apr 2003 19:09:08


You're right... that was the problem.
I always forget it.
Thanks/



> > I have documents of type 'Contenu' (content) wich may be articles
> > (Contenu/Article) or Dossiers (Contenu/Dossier).

> > Any of these contents have an issue origin (Contenu/*/Origine/Parution)

> > For some of those articles or dossiers I would like to display their
Teaser
> > (Contenu/*/Accroche/Parag).
> > Only for those articles for which issue origin is '01net' or '01net.'

> > So here's my <xsl:if> statement (I only want to get those teasers that
have
> > some text content). (I'm in a 'Contenu' context) so
> > the '*' applies to either an 'Article' or 'Dossier'
> >     <xsl:if test="*/Accroche/Parag[*/Origine/Parution = '01net.' Or
> > */Origine/Parution = '01net']/text())">

> > But I get the following error :

> > a.. Error type :
> > msxml3.dll (0x80004005)
> > Expected token ']' found 'NAME'. */Accroche/Parag[*/Origine/Parution =
> > '01net.' -->Or <--*/Origine/Parution = '01net']/text())

> > The funny thing is that when I rewrite the test expression using 'And'
> > operators and negations, it works ! :
> > <xsl: if test="not(*/Accroche/Parag[*/Origine/Parution != '01net' And
> > */Origine/Parution != '01net.']/text())">

> > Can someone explain to me why it works using 'And' and negation (not())
but
> > doesn't work using 'Or' operator ?

> There is no "And" or "Or" opeartors in XPath, there are "and" and "or".
> Remember - all things are case-sensitive in XML.

> --
> Oleg Tkachenko
> http://www.tkachenko.com/blog
> Multiconn Technologies, Israel