Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: [xsl] Correct way to test for no match

From: Wendell Piez <wapiez@------------.--->
To: xsl-list@-----.------------.---
Date: 10/1/2009 9:45:00 PM
Dan,

At 04:04 PM 10/1/2009, you wrote:
>I have a structure where I need to match values between w element 
>attributes. These elements are in different parst of the document. 
>Problem I'm trying to solve is when there is a typo in one of the 
>attributes and there is no match. I thought this would do it, but it's not
><xsl:when 
>test="ancestor::ipb/figure/subfig/graphic[@boardno=$sht_num]/@boardno">
>
>same with this
>
><xsl:when 
>test="ancestor::ipb/figure/subfig/graphic[@boardno=$sht_num]/@boardno = ''">
>
>Any suggestions?

I think you probably want 
"ancestor::ipb/figure/subfig/graphic/@boardno=$sht_num" as a positive 
test -- this will be true if there is a match (there exists a 
graphic/@boardno in that place whose value is $sht_num).

This is a somewhat more direct version of your first effort, which is 
true when there are ancestor::ipb/figure/subfig/graphic elements 
whose @boardno = $sht_num, by virtue of the fact that they 
(necessarily) have a @boardno. But I'm not sure you want a positive 
test: your description suggests you want to know when there isn't.

Your second attempt can be true only if $sht_num is "", and never 
otherwise. (It will also fail if no graphic elements are found on that path.)

If you want a negative test, which will come back true if there is no 
graphic whose @board_no is $sht_num, the way to do that is

test="not(ancestor::ipb/figure/subfig/graphic/@boardno=$sht_num)"

Or, of course, you can use the xsl:otherwise clause.

Good luck,
Wendell

>Here is the doc structure:
>
><ipb>
>   <figure>
>     <subfig>
>       <graphic boardno='a'/>
>     </subfig>
>   </figure>
>   <table>
>     <row>
>       <entry><ipbilus><xref shtref='b'/></ipbilus>
>       </entry>
>     </row>
>   </table>
></ipb>
>
>$sht_num is set to xref/@shtref so b never finds a on graphic


======================================================================
Wendell Piez                            mailto:wapiez@m...
Mulberry Technologies, Inc.                http://www.mulberrytech.com
17 West Jefferson Street                    Direct Phone: 301/315-9635
Suite 207                                          Phone: 301/315-9631
Rockville, MD  20850                                 Fax: 301/315-8285
----------------------------------------------------------------------
   Mulberry Technologies: A Consultancy Specializing in SGML and XML
======================================================================


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe@l...>
--~--



transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent