Where does HTML 'id' attribute map to in the DOM?

The Application Programming Interface and the OASIS Open Document Format

Where does HTML 'id' attribute map to in the DOM?

Postby _savage » Fri Dec 07, 2018 11:51 pm

Suppose I have a simple HTML file like so:
Code: Select all   Expand viewCollapse view
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title>Title</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <link href="../style/stylesheet.css" type="text/css" rel="stylesheet"/>
  </head>
  <body class="b">
    <p id="p-001" class="par">Content</p>
    <p class="par">Some bla</p>
    <!-- A reference to a paragraph in a neighboring file. -->
    <p id="id=p-003" class="par">…<a href="../text/page-2.html#p-021" class="link">Link</a>…</p>
    …
    <!-- An internal reference to a paragraph in this file. -->
    <p id="id=p-009" class="par">…<a href="#p-001" class="link">Top</a>…</p>
    …
  </body>
</html>

Notice how some paragraphs (and in HTML potentially many/most elements) have an “id” attribute here. The third paragraph then contains a link to a paragraph in a different file.

Loading this file into Office and browsing around its DOM, I am unable to find where the “id” attribute is stored for the paragraph. Not quite sure which interface or service would give me access to that value—if any. Some help would be good, short of digging into the source code for the HTML filter…
Mac 10.14 using LO 6.2.5.2, Gentoo Linux using LO 6.2.4.2.0 headless.
_savage
 
Posts: 168
Joined: Sun Apr 21, 2013 12:55 am

Re: Where does HTML 'id' attribute map to in the DOM?

Postby YODA » Sat Dec 08, 2018 2:47 pm

I personally would use a dedicated html editor like Blue Griffon available at http://bluegriffon.org/ instead.
Openoffice4.16 on windows 10 Libreoffice Version: 6.1.3.2 (x64)
YODA
 
Posts: 59
Joined: Fri Aug 10, 2018 4:06 am

Re: Where does HTML 'id' attribute map to in the DOM?

Postby RoryOF » Mon Dec 10, 2018 12:25 pm

In an administrative query the OP asked if "he could delete postings that were irrelevant to him".

I replied as follows
You may only delete your own postings, which we discourage, as it is antisocial and contrary to the spirit of the Forum.

If you feel a posting is irrelevant to you simply ignore it; in OO there are often many ways to achieve a given target - your "irelevancy" may be someone else's lifeline.


I agree with YODA that a dedicated HTML editor may be best; OO does not generate good HTML code.
Apache OpenOffice 4.1.6 on Xubuntu 18.04.3 (mostly 64 bit version) and very infrequently on Win2K/XP
User avatar
RoryOF
Moderator
 
Posts: 29435
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Where does HTML 'id' attribute map to in the DOM?

Postby _savage » Mon Dec 10, 2018 2:22 pm

I wasn’t asking about producing HTML code, but about reading HTML code into Office. To answer the above question, it seems that HTML elements with an `id` attribute produce a bookmark in the DOM.
Mac 10.14 using LO 6.2.5.2, Gentoo Linux using LO 6.2.4.2.0 headless.
_savage
 
Posts: 168
Joined: Sun Apr 21, 2013 12:55 am

Re: Where does HTML 'id' attribute map to in the DOM?

Postby Villeroy » Mon Dec 10, 2018 9:41 pm

YOU are the developer of your program. Lookup the Open Document Format specification and the content.xml of an example document where you inserted a bookmark.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04, no OpenOffice, LibreOffice 6.x
User avatar
Villeroy
Volunteer
 
Posts: 27096
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Where does HTML 'id' attribute map to in the DOM?

Postby bradleyross » Fri Aug 30, 2019 2:11 am

If you interested in the DOM and the ECMAScript/JavaScript methods for working with it, I would look at http://www.w3schools.com. No two elements in the same document can have the same id value, and the element is located by using document.getElementById(id_value) ( https://www.w3schools.com/js/js_htmldom_elements.asp ) where id_value is the text string that is the value of the id value of the element. The DOM object for an html element is an instantiation of Element.prototype ( https://www.w3schools.com/jsref/dom_obj_all.asp ) and it has a defined set of methods and properties. However, JavaScript uses weak typing, which means that the relationships between superclasses, subclasses, and instantiations are much looser than in Java. I'm not sure it this helps.
I am using version 6.0.4.2 of LibreOffice on MacOS Mojave (version 10.14.6)
bradleyross
 
Posts: 3
Joined: Thu Aug 29, 2019 7:55 pm


Return to UNO API and ODF

Who is online

Users browsing this forum: No registered users and 0 guests