GithubHelp home page GithubHelp logo

Comments (10)

johnfactotum avatar johnfactotum commented on May 27, 2024 1

It's "stepsToXpath", not "stepToXpath". Steps here means the parsed CFI steps, an array of objects in the form { type, index, id }, where type is either "element" or "text" (see he parseStep method).

from epub.js.

rakshithpanjady avatar rakshithpanjady commented on May 27, 2024

Can anyone help me on this ?

from epub.js.

rakshithpanjady avatar rakshithpanjady commented on May 27, 2024

Can anyone help me on this ?

from epub.js.

rakshithpanjady avatar rakshithpanjady commented on May 27, 2024

I need a help on this , Please anyone guide me on this ?

from epub.js.

johnfactotum avatar johnfactotum commented on May 27, 2024

Step 1. Use Document.evaluate() to get the nodes (you can get the Document object from contents.document, either in the content hook or by calling rendition.getContents()).

Step 2. Construct a Range and use cfiFromRange() (or use cfiFromElement() if your target node is an Element) to get a CFI.

Step 3. Use rendition.display() to display the CFI.

from epub.js.

rakshithpanjady avatar rakshithpanjady commented on May 27, 2024

Is there any method to generate xpath ?

from epub.js.

johnfactotum avatar johnfactotum commented on May 27, 2024

Short answer: Don't. Use CFI instead.

Long answer: Firstly, generating XPaths has nothing to do with Epub.js. Second, XPath isn't designed to be used as an identifier. If you want identifiers, you should use CFI. Finally, if you still want to use XPath for whatever reason, there are virtually an infinite number of ways to get XPaths of any given node, depending on what you want to do. The most common approach is:

  1. Get the name of the element node. This is what goes after /.
  2. Enumerate all previous sibling elements and count the number of elements with the same name (including the element itself). This is what you'd put between [ and ].
  3. Repeat from step 1 with the parent element until you reach the document element, and concatenate the results.

from epub.js.

rakshithpanjady avatar rakshithpanjady commented on May 27, 2024

Can you tell me stepToXpath(steps) , what does step means here and how to generate it ?

from epub.js.

johnfactotum avatar johnfactotum commented on May 27, 2024

I don't know anything about "stepToXpath(steps)". Where does this function even come from?

In general, a step in XPath just means an expression that moves you towards the desired result. In practice you can just think of it as everything that comes after a /.

from epub.js.

panjadyboy avatar panjadyboy commented on May 27, 2024

![IMG20230922112134.jpg](https://github.com/futurepress/epub.js/assets/115630669/60c07ecf-5859-45ab-b264-06dc452af9c3
In epubjs there is a method named as stepToXpath(steps) , it is taking steps as parameter

from epub.js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.