Welcome to Software Development on Codidact!
Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.
How to establish a relationship between HTML elements (tags)? (i.e., how can one element refer to another one)
Should I use the data-*
attributes for this or is there a more idiomatic way?
For context, I'm trying to convert annotated legal PDF documents to HTML. Certain parts of these documents are crossed out when a new amendment is added, timestamped, and a "sticky note" directs readers to the section in the new amendment that supersedes it. My goal is to create a sort of "time machine" (or version controlled) document where one specifies a date, and the document will be rendered with only the parts that would have been in effect at that time.
For example, if this was a quote from one of the PDFs:
From Wikipedia's Gall's Law article.
Complex systems are the best way to start a project.(Seeamendment 1
, 7/30/2024)(
amendment 1
, 7/30/2024) A complex system that works is invariably found to have evolved from a simple system that worked. A complex system designed from scratch never works and cannot be patched up to make it work. You have to start over with a working simple system.
My naive initial solution would be something like this:
<p data-date-added="3/9/2021" data-superseded-by-amendment="1">
Complex systems are the best way to start a project.
</p>
<!-- ... lots of other stuff ... -->
<p data-date-added="7/30/2024" data-amendment-id="1">
A complex system that works is invariably found
to have evolved from a simple system that worked.
A complex system designed from scratch never works
and cannot be patched up to make it work. You have
to start over with a working simple system.
</p>
3 answers
attribute data-* can be used for custom data storage or semantic elements like id, class, aria.
<p data-date-added="3/9/2021" data-superseded-by-amendment="1">
Complex systems are the best way to start a project.
</p>
<p data-date-added="7/30/2024" data-amendment-id="1">
A complex system that works is invariably found to have evolved from a simple system that worked...
</p>
Flexible method, can be parsed with JavaScript for dynamic behavior.
0 comment threads
I'm not sure how much this helps or inspires you, but there's an XML schema for the US Code and for bills and amendments to change it. See xml.house.gov and the GitHub repository for United States Legislative Markup. They may already have XSLT transformations to HTML for current-version and/or diff modes.
I'm not sure I would have thought of it but for your mention of "legal documents." It can't get much more legal than that.
2 comment threads