xsl-list
[Top] [All Lists]

Re: [xsl] Can this all fit into one Xpath expression?

2009-04-14 15:11:56
At 2009-04-14 14:02 -0500, russurquhart1(_at_)verizon(_dot_)net wrote:
I have a structure with conditions something like this:

//GenTable/table/tgroup/tbody/row/entry[Emphasis = 'Address Offset'] and Emphasis[(_at_)type='bold']

//GenTable/table/tgroup/tbody/row/entry[Emphasis = 'Physical Address'] and Emphasis[(_at_)type='bold']

//GenTable/table/tgroup/tbody/row/entry[Emphasis = 'Instance'] and Emphasis[(_at_)type='bold']

//GenTable/table/tgroup/tbody/row/entry[Emphasis = 'Description'] and Emphasis[(_at_)type='bold']

//GenTable/table/tgroup/tbody/row/entry[Emphasis = 'Type'] and Emphasis[(_at_)type='bold']

If a GenTable element has four or the five entry elements, that match these conditions, i want to set GenTable[(_at_)role='Register'] and GenTable[(_at_)columns='1'].

Can this be squeezed into one hairy Xpath expression.

In XPath 2.0 you can use sequence notation and have:

//GenTable/table/tgroup/tbody/row/entry[Emphasis[ . = ( 'Address Offset',
                                                        'Physical Address',
                                                        'Instance',
                                                        'Description',
                                                        'Type' ) ]
                                                [(_at_)type='bold']
                                       ]

That would select the entry element that has the emphasis you seek ... then in XSLT or XQuery you construct the end result by constructing the element and attribute nodes you need. It doesn't handle nested emphasis, only emphasis that is a direct child of the entry. If you need to identify an entry with emphasis anywhere inside of it you need to modify the above to read:

  ... entry[.//Emphasis[ ....

I'm not sure to what you are referring when you say "I want to set ...." ... are you using XPath in, perhaps, a DOM implementation?

I hope this helps.

. . . . . . . . . Ken

--
XSLT/XSL-FO/XQuery training in Los Angeles (New dates!) 2009-06-08
Training tools: Comprehensive interactive XSLT/XPath 1.0/2.0 video
Video lesson:    http://www.youtube.com/watch?v=PrNjJCh7Ppg&fmt=18
Video overview:  http://www.youtube.com/watch?v=VTiodiij6gE&fmt=18
G. Ken Holman                 mailto:gkholman(_at_)CraneSoftwrights(_dot_)com
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/s/
Male Cancer Awareness Nov'07  http://www.CraneSoftwrights.com/s/bc
Legal business disclaimers:  http://www.CraneSoftwrights.com/legal


--~------------------------------------------------------------------
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(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

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