Guidance on use of xml:id

28 views
Skip to first unread message

Peter Seibel

unread,
Jun 8, 2025, 12:52:15 PM6/8/25
to PreTeXt support
Is it considered good form to put an xml:id on any element that can take one? Or only on ones that you need to cross reference with xref or whatever? If they're only used for cross references it seems like it'd be easier to add them only when needed since (I assume) they have to be globally unique (within a book) right?

Rob Beezer

unread,
Jun 8, 2025, 2:13:51 PM6/8/25
to pretext...@googlegroups.com
Brief, on fone Yes, only on targets, which is mostly cross-referencing.

We now have @label which can be used liberally to get nice filenames and nice fragment identifiers, etc

Peter Seibel

unread,
Jul 3, 2025, 10:54:17 AM7/3/25
to PreTeXt support
Can someone point me to the documentation of @label? I can't find it in the guide.

Sean Fitzpatrick

unread,
Jul 3, 2025, 11:25:53 AM7/3/25
to PreTeXt support
The documentation hasn't fully caught up with some of the changes over the last year.
To the best of my knowledge:
- Anything that can be an activity in Runestone should have a label (unless you never want your book to be on Runestone)
     * any of the interactive exercise types we interited from Runestone (label goes on the exercise)
     * WeBWorK exercises (label on the exercise)
     * videos (label on the video element)
- Generated assets: a label should go on <latex-image>, <asymptote>, etc.; these are used for file names
- Any division that becomes its own .html file for the chunking level you're using: chapter, section, frontmatter, backmatter, index, titlepage, colophon

There are some outliers. Right now, WeBWorK exercises are structured as
<exercise label="foo">
  <webwork xml:id="bar">
    contents....
  </webwork>
</exercise>
The label is used for the Runestone database, and the xml:id is used to name the WeBWorK exercise. I'm not sure if this will change at some point.

I have a pull request in to document labels for generated images, but it's on hold because right now this isn't supported for Mermaid.
There are probably other outliers, given the size of PreTeXt.

Rob Beezer

unread,
Jul 3, 2025, 9:42:17 PM7/3/25
to pretext...@googlegroups.com
Lagging. I wish I could say, "I'll get right on it."

@xml:id - names of targets, usually indicated in an @ref. Values should never
be visible to readers.

@label - string used for various names, like filenames, JS identifiers,
Runestone database keys, etc. Often seen by readers.

Now, if you have an @xml:id and not a @label, we often use the value of @xml:id
when we really wanted a @label. Violating visibility claims above. For reasons
of backward-compatibility.

Rob
> --
> You received this message because you are subscribed to the Google Groups
> "PreTeXt support" group.
> To unsubscribe from this group and stop receiving emails from it, send an email
> to pretext-suppo...@googlegroups.com <mailto:pretext-
> support+u...@googlegroups.com>.
> To view this discussion visit https://groups.google.com/d/msgid/pretext-
> support/715f66a3-b8a6-4446-aa93-c3cbbc5449cfn%40googlegroups.com <https://
> groups.google.com/d/msgid/pretext-support/715f66a3-b8a6-4446-aa93-
> c3cbbc5449cfn%40googlegroups.com?utm_medium=email&utm_source=footer>.

Reply all
Reply to author
Forward
0 new messages