[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
Russ,
At 02:02 PM 4/16/2009, you wrote:
The fact that you get all your GenTable elements when your count is >= 0, but none of them when your count >= 1, indicates that your count is 0 for all of them. In turn, this suggests your conditionals are wrong in some systematic way.
I'll rephrase your XPath in a way that is more or less the same, but a bit more legible. (I say "more or less" since one thing I'm doing is removing the normalize-space() munging; if you need it you can put it back but it complicates things for purposes of explanation. But none of my other changes are meaningful.)
So ... it's collecting all GenTable elements that have at least four entry children meeting the following criterion: they must all have at least one Emphasis child of @type='bold' and with a value (whitespace-normalized, as you had it) of "Address Offset", "Physical Address", "Instance", "Description" or "Type".
But evidently you have none, and indeed you haven't got any GenTable elements with even one entry child meeting this test.
Just guessing wildly (sorry, I didn't save your data sample), I expect that the relations among the elements isn't right. Do GenTable elements have entry children (a table with entries but not rows)? Do entry elements have Emphasis children?
Maybe instead of 'child::entry' you want 'descendant::entry' (shorthand: './/entry') or '*/entry' (short for 'child::*/child::entry') or 'row/entry'.
Additionally, there's (at least) one other thing you can do to make the path more concise, even as it stands:
... and, were you able to use XPath 2.0 (and putting the normalize-space() back):
//GenTable[count(entry
[Emphasis[@type='bold']
[normalize-space(.)=('Address Offset', 'Physical Address', 'Instance',
'Description', 'Type') ] )
>= 4]
Re: [xsl] Big long xpath, almost there, but not quite
Subject: Re: [xsl] Big long xpath, almost there, but not quite From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx> Date: Thu, 16 Apr 2009 14:38:18 -0400 |
Russ,
At 02:02 PM 4/16/2009, you wrote:
I want to thank everybody for their help on this. Michael Kay, thaks for your help very much. I entered the following Xpath. It is getting there, but it still is not quite right.
//GenTable[count(entry[Emphasis[normalize-space(.) = 'Address Offset' and @type='bold'] or
Emphasis[normalize-space(.)='Physical Address' and @type='bold'] or
Emphasis[normalize-space(.)='Instance' and @type='bold'] or
Emphasis[normalize-space(.)='Description' and @type='bold'] or
Emphasis[normalize-space(.)='Type' and @type='bold'] ]) >= 4]
When i use this, as i would like at least 4 entry element that match the conditions above, hopefully 5, i would think this should do the trick and return the GenTable elements that contain them.
When i run it, however, i get no GenTable elements. When i remove the count() function, i get no GenTable elements. When i change the 4 9the minimum match value, to something smaller like 1) i get no GenTable elements. When i change the number 4 to 0, i get ALL the GenTable elements.
The fact that you get all your GenTable elements when your count is >= 0, but none of them when your count >= 1, indicates that your count is 0 for all of them. In turn, this suggests your conditionals are wrong in some systematic way.
I'll rephrase your XPath in a way that is more or less the same, but a bit more legible. (I say "more or less" since one thing I'm doing is removing the normalize-space() munging; if you need it you can put it back but it complicates things for purposes of explanation. But none of my other changes are meaningful.)
//GenTable[count(child::entry [child::Emphasis[@type='bold'][.='Address Offset'] or child::Emphasis[@type='bold'][.='Physical Address'] or child::Emphasis[@type='bold'][.='Instance'] or child::Emphasis[@type='bold'][.='Description'] or child::Emphasis[@type='bold'][.='Type'] ] ) >= 4]
So ... it's collecting all GenTable elements that have at least four entry children meeting the following criterion: they must all have at least one Emphasis child of @type='bold' and with a value (whitespace-normalized, as you had it) of "Address Offset", "Physical Address", "Instance", "Description" or "Type".
But evidently you have none, and indeed you haven't got any GenTable elements with even one entry child meeting this test.
Just guessing wildly (sorry, I didn't save your data sample), I expect that the relations among the elements isn't right. Do GenTable elements have entry children (a table with entries but not rows)? Do entry elements have Emphasis children?
Maybe instead of 'child::entry' you want 'descendant::entry' (shorthand: './/entry') or '*/entry' (short for 'child::*/child::entry') or 'row/entry'.
Additionally, there's (at least) one other thing you can do to make the path more concise, even as it stands:
//GenTable[count(entry [Emphasis[@type='bold'] [(.='Address Offset') or (.='Physical Address') or (.='Instance') or (.='Description') or (.='Type') ] ) >= 4]
... and, were you able to use XPath 2.0 (and putting the normalize-space() back):
//GenTable[count(entry
[Emphasis[@type='bold']
[normalize-space(.)=('Address Offset', 'Physical Address', 'Instance',
'Description', 'Type') ] )
>= 4]
Cheers, Wendell
====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx 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 ======================================================================
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Big long xpath, almost th, David Carlisle | Thread | [xsl] is there a way to extract the, Catherine Winston |
Re: [xsl] Big long xpath, almost th, David Carlisle | Date | [xsl] is there a way to extract the, Catherine Winston |
Month |