[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Automatically generate xpath

Subject: Re: Automatically generate xpath
From: "Jay Bryant" <jay@xxxxxxxxxxxx>
Date: Mon, 30 Jan 2006 16:23:02 -0600
tool to generate xpath
Take a look at Saxon (my favorite XSLT processor). Saxon includes an
extension function called evaluate-node. That function reads an XPath
expression from a source document and then evaluates it at runtime - very
handy for this sort of thing.

HTH

Jay Bryant
Bryant Communication Services


----- Original Message ----- 
From: "Liron" <magilam@xxxxxxxxxxxxxxxx>
To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Sent: Monday, January 30, 2006 3:19 PM
Subject:  Automatically generate xpath


> 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

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.