xsl-list
[Top] [All Lists]

Automatically generate xpath

2006-01-30 15:09:25
Hello all,

I'm looing for some tool (an open source library would be better) that can generate a xpath out of a set of xpaths with some rules like exclusion and inclusion
I want to provide an example to what I mean. consider the following html:

<html>
  <body>
     <table>
        <tr><td><font>
        <a href="about:blank"><b>Text1</b></a>
        <a href="about:blank"><b>Text2</b></a>
        <a href="about:blank"><b>Text3</b></a>
        </font></td></tr>
        <tr><td><font>
        <a href="about:blank"><b>Text4</b></a>
        <a href="about:blank"><b>Text5</b></a>
        <a href="about:blank"><b>Text6</b></a>
        </font></td></tr>
      </table>
      <table>
        <tr><td><font>
        <a href="about:blank"><b>Text7</b></a>
        <a href="about:blank"><b>Text8</b></a>
        <a href="about:blank"><b>Text9</b></a>
        </font></td></tr>
        <tr><td><font>
        <a href="about:blank"><b>Text10</b></a>
        <a href="about:blank"><b>Text11</b></a>
        <a href="about:blank"><b>Text12</b></a>
        </font></td></tr>
     </table>
  </body>
</html>

I want to provide this tool the following xpaths:
/html/body/table[1]/tr[1]/td/font/a[1]/b/text() (this selects Text1) and
/html/body/table[2]/tr[2]/td/font/a[3]/b/text() (this selects Text12)
and get an output that looks something like:

/html/body/table/tbody/tr/td/font/a[((count(preceding-sibling::a) = 0) and (ancestor::table[1][count(preceding-sibling::table)=0]) and (ancestor::tr[1][count(preceding-sibling::tr)=0])) or ((count(preceding-sibling::a) = 2) and (ancestor::table[1][count(preceding-sibling::table)=1]) and (ancestor::tr[1][count(preceding-sibling::tr)=1]))]/b/text()

which will return me Text1 and Text12 (I have no idea how to make this simpler, if someone know of a way, I'd appreciate it)

I'd also like to have the ability to exclude certain elements from a supplied xpath in a kind of a reversed way.

If anyone knows of a solution or such a tool I'd really appreciate it

Thank you
Liron
--~------------------------------------------------------------------
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>