Add incremental id inside a tag

Questions about XML that are not covered by the other forums should go here.
fbrzvnrnd
Posts: 11
Joined: Fri Dec 02, 2011 1:11 am

Add incremental id inside a tag

Post by fbrzvnrnd »

Hi,
I'm working on a xhtml file (an ebook). Is there a way to add a incremental id to all the tag (for example, cite)? I have a lot of <cite> tags inside the xhtml file and I was trying to automatically add a id for each <cite>. Is this possible?

Thank you.

f.
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Re: Add incremental id inside a tag

Post by sorin_ristache »

Hello,

Do the cite elements already exist in the XHTML file? If yes you could add an id attribute to each cite element with an XSLT stylesheet applied to the XHTML file. The values of the id attributes are decided by the XSLT stylesheet so you can generate them as incremental number values if you want.

I assume that you want to add the id attributes for referring to them later from other elements in other files of the e-book. Maybe it is difficult to identify the exact cite element that will be target of a reference when you will want to create the references that will point to these id values? Why do you want to auto-generate the id values instead of inserting manually a suggestive value in each id attribute?


Regards,
Sorin
fbrzvnrnd
Posts: 11
Joined: Fri Dec 02, 2011 1:11 am

Re: Add incremental id inside a tag

Post by fbrzvnrnd »

Thank you for the answer. Actually I do not know XSLT, I usually work with XHTML and XQUERY to create my ebooks. I'll try to study a little of XSLT to understand how to manage id in my XHTML documents.

One of our ebook is a magazine, and I add a "Citation's Index" to add more navigation inside the ebook. Actually I wrote a python regex script to add incremental id, but I was looking for a more polite way to do it.

f.
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Re: Add incremental id inside a tag

Post by sorin_ristache »

Thank you for letting us know. Where do you get the content that will go in the e-book? Do you extract the content from a database using XQuery? Or do you have the content as XHTML files already and you just edit the XHTML files (add some id atributes, modify the formatting, etc) and after that you just assemble the XHTML files as an ePub (zip archive)? I just want to see how Oxygen could help you in the editing phase before assembling the e-book. Maybe it would help you an Oxygen feature for generating automatically a unique ID value for an id attribute (like the id attribute of the cite element) when editing the XHTML files? We have such a feature for Docbook XML and TEI P5 documents for which some built-in scenarios are provided for transforming them to ePub but not for XHTML documents.


Thank you,
Sorin
fbrzvnrnd
Posts: 11
Joined: Fri Dec 02, 2011 1:11 am

Re: Add incremental id inside a tag

Post by fbrzvnrnd »

Actually I work in XHTML+CSS to build the ebooks. When I have all the XHTML done, I begin to "XQUERY the document" to build the Summary, Index, Toc, Citation's Index, and other navigation tools. After, I add the new XHTML code to the previous one.
When this work is done I use Prince to build a 8''PDF, and after I had to split the original XHTML to create the ePub and after the mobi version.
Actually I use Sigil to split and create the toc and content: after I open the ePub with Oxygen again to change the XML Sigil created. Honestly, I'd like to remove Sigil in the process 'cause Sigil add unwanted tags to my XHTML.
In fact, I was looking in the Oxygen scenarios a way to create the ePub from XHTML, but I see there is not still this option.

Add unique id value to a selected element@class could be a nice feature, like a scenario to build a ePub from a XHTML source too.

f.
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Re: Add incremental id inside a tag

Post by sorin_ristache »

We will consider your request for a future version of Oxygen.


Thank you for the details,
Sorin
Post Reply