02-26-2015, 02:34 PM | #1 |
Head of lunatic asylum
Posts: 349
Karma: 77620
Join Date: Jun 2012
Location: UTC +1
Device: Tolino Vision 3HD
|
XPath Tutorial - vbq (very basic question)
Hola!
I have now tried the whole afternoon to understand the XPath Tutorial and read some not so compelling things about XML-files etc. - no luck. I have also created the Sample-ebook. Please tell me where/how I need to make such a document/text or in which form to bring so with the given search pattern in the tutorial eg. // h: h2 or // * [@ class = "chapter"] I can somehow make a hit. Sometimes the formulation of a question is already a problem. Last edited by chaot; 02-26-2015 at 02:42 PM. |
02-26-2015, 02:44 PM | #2 |
Ex-Helpdesk Junkie
Posts: 19,422
Karma: 85397180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
|
That searchpattern is designed to match all h2 tags (regex: <h2( [^>]*)?>), as well as all tags of class "chapter" (regex: <\w+ class="chapter">)
|
02-27-2015, 05:07 AM | #3 |
Head of lunatic asylum
Posts: 349
Karma: 77620
Join Date: Jun 2012
Location: UTC +1
Device: Tolino Vision 3HD
|
The Sample ebook says: A very short ebook to demonstrate the use of XPath.
How can I let this 'Very short ebook' demonstrate me the use of XPath? No matter what search term // h: h2 or // * [@ class = "chapter"] or <h2( [^>]*)?> or <\w+ class="chapter"> the result is: No matches were found for ... That specific question needs more a practical answer. |
02-27-2015, 05:27 AM | #4 |
Grand Sorcerer
Posts: 12,155
Karma: 73448616
Join Date: Nov 2007
Location: Toronto
Device: Nexus 7, Clara, Touch, Tolino EPOS
|
You don't use the XPATH settings in the regular search area.
Try clicking on Tools | Table of Contents | Edit Table of Contents and then there is a button Generate ToC from XPath |
02-27-2015, 09:44 AM | #5 |
Wizard
Posts: 1,071
Karma: 412718
Join Date: Jan 2009
Location: Valley Forge, PA, USA
Device: Kindle Paperwhite
|
XPath has some other uses, but all I've used it for is making table of contents (screen shot)
In the F&R you can only use Regular Expressions http://manual.calibre-ebook.com/regexp.html Using eschwartz's RE you can find H2's with class="chapter" in the sample book (pic 2) I guess I'm not understanding why you were looking to use XPath. Sorry, but maybe you could provide a little more about what you were looking to do? Last edited by phossler; 02-27-2015 at 09:56 AM. |
02-27-2015, 10:51 AM | #6 |
Ex-Helpdesk Junkie
Posts: 19,422
Karma: 85397180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
|
@chaot -- as PeterT said.
And the regex did not work because you were in normal mode, not regex mode. The S&R can take regexes, like the translation I supplied, if treated correctly. xpath is totally different. |
02-27-2015, 02:08 PM | #7 | ||||
Head of lunatic asylum
Posts: 349
Karma: 77620
Join Date: Jun 2012
Location: UTC +1
Device: Tolino Vision 3HD
|
The original to start with, see A very short ebook.
Quote:
So you are quite right to mention the 'path': without Edit book window we wouldn't know the correct 'key phrases' to use (see Edit the ToC in ... (Start) after Fix HTML + Beautify current file) In a (very) small ebook creating the ToC its enough to fill the libprs500 window only HTML tags with tag names (like a, br, div, h1, h2 etc.) and ignore the attribute and value inputs. That's probably in bigger ebooks not to ignore in order to obtain a really sophisticated ToC (at moment I don't know). Here results the same if using only //h:h1 or (full expression) //h:h1[re:test(@class, "bookTitle", "i")] - tested. See Create ToC from XPath and the result Edit the ToC in ...(vers A). Note: The HTML tags div and h2 get id-numbers (both h2 different ones), but the HTML tag h1 gets none. Can you say something about? It's possible to customize the ToC, see Edit the ToC in ...(vers B) Quote:
Quote:
As a sailor I like to navigate, preferably in new territories. Quote:
Correct treatment, very important. There are some between us you'll explain dozen times the theory or even better once the practice. XPath Tutorial is great (as far as I can tell). Only a small but not unimportant hint is missing: where you can do something with it. ToC or 'Table of content' isn't mentioned even once. My pictures show details, always different ones. Last edited by chaot; 03-02-2015 at 04:57 AM. Reason: corrected language |
||||
02-27-2015, 04:57 PM | #8 |
Ex-Helpdesk Junkie
Posts: 19,422
Karma: 85397180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
|
For regex, usage is as described at the end of the tutorial, in the section "I think I’m beginning to understand these regular expressions now... how do I use them in calibre?"
XPath instructions start here: http://manual.calibre-ebook.com/conv...le-of-contents and link to the XPath tutorial. For a more general and in depth explanation of the power of regexes, my favorite site remains this one: http://www.regular-expressions.info/ |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Nested TOC / Xpath question | halfgone | Conversion | 0 | 02-13-2012 07:46 PM |
Xpath question: Two Expressions for Level 1 | redcloud111 | Calibre | 2 | 01-28-2012 12:46 AM |
two 'basic tutorial' questions | affa | Sigil | 12 | 04-21-2011 02:38 PM |
XPath question | krischik | Calibre | 0 | 01-16-2010 08:22 AM |
Basic tutorial please (for Dummies) | captaingeorges | Bookeen | 6 | 03-02-2008 02:28 PM |