Troubles with datafile/pre/@source

23 views
Skip to first unread message

Peter Seibel

unread,
Jul 19, 2025, 2:08:09 PM7/19/25
to PreTeXt support

Given this markup:

  <datafile label="turtleClasses" filename="turtleClasses.jar" editable="no" hide="yes">
    <pre source="_static/code/turtleClasses.java" />
  </datafile>

  <datafile label="turtleClasses2" filename="turtleClasses2.jar" editable="no" hide="yes">
    <pre source="_static/code/turtleClasses2.java" />
  </datafile>

My build complains about:

error: processing with /Users/peter/.ptx/2.23.0/core/xsl/pretext-html.xsl has failed

critical: Cannot resolve URI /Users/peter/Runestone/books/BHSawesome2/pretext/generated/datafile/turtleClasses2.xml

critical: Failed to build.  Exiting...

----------------------------------------------------

And yet:

BHSawesome2 (bhsawesome2-reorg) $ ls /Users/peter/Runestone/books/BHSawesome2/pretext/generated/datafile/turtleClasses2.xml

/Users/peter/Runestone/books/BHSawesome2/pretext/generated/datafile/turtleClasses2.xml

Any idea what I'm doing wrong here?

Rob Beezer

unread,
Jul 19, 2025, 2:20:39 PM7/19/25
to pretext...@googlegroups.com
Maybe not a complete answer. But there is no situation I can think of where an
author should be referencing "_static". Try removing it?

On 7/19/25 11:08, Peter Seibel wrote:
> Given this markup:
>
>   <datafile label="turtleClasses" filename="turtleClasses.jar" editable="no"
> hide="yes">
>     <pre source="_static/code/turtleClasses.java" />
>   </datafile>
>
>   <datafile label="turtleClasses2" filename="turtleClasses2.jar" editable="no"
> hide="yes">
>     <pre source="_static/code/turtleClasses2.java" />
>   </datafile>
>
> My build complains about:
>
> error: processing with /Users/peter/.ptx/2.23.0/core/xsl/pretext-html.xsl has failed
>
> critical: Cannot resolve URI /Users/peter/Runestone/books/BHSawesome2/pretext/
> generated/datafile/turtleClasses2.xml
>
> critical: Failed to build.  Exiting...
>
> ----------------------------------------------------
>
> And yet:
>
> BHSawesome2(bhsawesome2-reorg) $ ls /Users/peter/Runestone/books/BHSawesome2/
> pretext/generated/datafile/turtleClasses2.xml
>
> /Users/peter/Runestone/books/BHSawesome2/pretext/generated/datafile/
> turtleClasses2.xml
>
> Any idea what I'm doing wrong here?
>
> --
> 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/3d3fc29f-249c-420c-be54-eb47f73c1d41n%40googlegroups.com <https://
> groups.google.com/d/msgid/pretext-support/3d3fc29f-249c-420c-be54-
> eb47f73c1d41n%40googlegroups.com?utm_medium=email&utm_source=footer>.

Peter Seibel

unread,
Jul 19, 2025, 2:36:18 PM7/19/25
to PreTeXt support
Turns out the issue is when the turtleClasses2.xml file was generated it just plops the contents of the file as is inside a <pi:text-file xmlns:pi="http://pretextbook.org/2020/pretext/internal"> with no escaping. If I add <![CDATA[ ...]]> in the file itself it works. Though it seems like maybe the generator should do that for me.

Peter Seibel

unread,
Jul 19, 2025, 2:55:36 PM7/19/25
to PreTeXt support
https://github.com/PreTeXtBook/pretext/pull/2615 proposes a fix though it could be construed as a breaking change.

Rob Beezer

unread,
Jul 21, 2025, 3:14:40 PM7/21/25
to pretext...@googlegroups.com
Dear Peter,

Andrew S and I discussed this today at Drop-In. Do you think you could try the
following experiment?

<datafile label="turtleClasses" filename="turtleClasses.jar"
editable="no" hide="yes">
<pre>
<xi:include parse="text" href="code/turtleClasses.java"/>
</pre>
</datafile>

The @href will need adjustment - likely you will really need to move the file
itself to a location relative to where the rest of your PreTeXt source lives.

Thanks,
Rob

On 7/19/25 11:55, Peter Seibel wrote:
> https://github.com/PreTeXtBook/pretext/pull/2615 proposes a fix though it could
> be construed as a breaking change.
>
> On Saturday, July 19, 2025 at 11:36:18 AM UTC-7 Peter Seibel wrote:
>
> Turns out the issue is when the turtleClasses2.xml file was generated it
> just plops the contents of the file as is inside a <pi:text-file
> xmlns:pi="http://pretextbook.org/2020/pretext/internal <http://
> pretextbook.org/2020/pretext/internal>"> with no escaping. If I add <!
> [CDATA[ ...]]> in the file itself it works. Though it seems like maybe the
> generator should do that for me.
>
> On Saturday, July 19, 2025 at 11:08:09 AM UTC-7 Peter Seibel wrote:
>
> Given this markup:
>
>   <datafile label="turtleClasses" filename="turtleClasses.jar"
> editable="no" hide="yes">
>     <pre source="_static/code/turtleClasses.java" />
>   </datafile>
>
>   <datafile label="turtleClasses2" filename="turtleClasses2.jar"
> editable="no" hide="yes">
>     <pre source="_static/code/turtleClasses2.java" />
>   </datafile>
>
> My build complains about:
>
> error: processing with /Users/peter/.ptx/2.23.0/core/xsl/pretext-
> html.xsl has failed
>
> critical: Cannot resolve URI /Users/peter/Runestone/books/BHSawesome2/
> pretext/generated/datafile/turtleClasses2.xml
>
> critical: Failed to build.  Exiting...
>
> ----------------------------------------------------
>
> And yet:
>
> BHSawesome2(bhsawesome2-reorg) $ ls /Users/peter/Runestone/books/
> BHSawesome2/pretext/generated/datafile/turtleClasses2.xml
>
> /Users/peter/Runestone/books/BHSawesome2/pretext/generated/datafile/
> turtleClasses2.xml
>
> Any idea what I'm doing wrong here?
>
> --
> 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/8878352c-6a76-44ac-a82f-aa7a082fdbdcn%40googlegroups.com <https://
> groups.google.com/d/msgid/pretext-support/8878352c-6a76-44ac-a82f-
> aa7a082fdbdcn%40googlegroups.com?utm_medium=email&utm_source=footer>.

Peter Seibel

unread,
Jul 21, 2025, 4:29:22 PM7/21/25
to pretext...@googlegroups.com
That works. Is the theory that we should just rely on this rather the pre/@source? That makes some sense to me since XML already has this functionality. I did have to adjust the href since _static is actually under my assets directory. So now i have this which works fine:

      <datafile label="turtleClasses" filename="turtleClasses.jar" editable="no" hide="yes">
        <pre>
          <xi:include parse="text" href="assets/_static/code/turtleClasses.java" />
        </pre>

      </datafile>

      <datafile label="turtleClasses2" filename="turtleClasses2.jar" editable="no" hide="yes">
        <pre>
          <xi:include parse="text" href="assets/_static/code/turtleClasses2.java" />
        </pre>
      </datafile>


You received this message because you are subscribed to a topic in the Google Groups "PreTeXt support" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/pretext-support/WYqYAiOfKiA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to pretext-suppo...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/pretext-support/MTAwMDA0OC5iZWV6ZXI.1753125278%40pnsh.


--
BHS Bell Schedule app: https://gigamonkeys.com/misc/bhs/


Rob Beezer

unread,
Jul 21, 2025, 6:13:57 PM7/21/25
to pretext...@googlegroups.com
Thanks, Peter.

You, and your source, should have no idea about _static, nor assets. It is on
the order of a coincidence that your @href works out and it wouldn't be
guaranteed to stay that way. (Or we have some work to do.)

You want the file in question to live like this:

my-great-book/
main.ptx
chapter-intro.ptx
chapter-exciting.ptx
code/
turtleClasses.java

This is what I meant by "location relative to where the rest of your PreTeXt
source lives". Can you try that? (The "code" directory is just a convenience.)

Rob
> > https://github.com/PreTeXtBook/pretext/pull/2615 <https://github.com/
> PreTeXtBook/pretext/pull/2615> proposes a fix though it could
> > be construed as a breaking change.
> >
> > On Saturday, July 19, 2025 at 11:36:18 AM UTC-7 Peter Seibel wrote:
> >
> >     Turns out the issue is when the turtleClasses2.xml file was generated it
> >     just plops the contents of the file as is inside a <pi:text-file
> >     xmlns:pi="http://pretextbook.org/2020/pretext/internal <http://
> pretextbook.org/2020/pretext/internal> <http://
> support%2Bunsu...@googlegroups.com> <mailto:pretext- <mailto:pretext->
> > support+u...@googlegroups.com
> <mailto:support%2Bunsu...@googlegroups.com>>.
> > To view this discussion visit https://groups.google.com/d/msgid/pretext-
> <https://groups.google.com/d/msgid/pretext->
> > support/8878352c-6a76-44ac-a82f-aa7a082fdbdcn%40googlegroups.com
> <http://40googlegroups.com> <https://
> > groups.google.com/d/msgid/pretext-support/8878352c-6a76-44ac-a82f-
> <http://groups.google.com/d/msgid/pretext-support/8878352c-6a76-44ac-a82f->
> > aa7a082fdbdcn%40googlegroups.com?utm_medium=email&utm_source=footer
> <http://40googlegroups.com?utm_medium=email&utm_source=footer>>.
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "PreTeXt support" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/topic/
> pretext-support/WYqYAiOfKiA/unsubscribe <https://groups.google.com/d/topic/
> pretext-support/WYqYAiOfKiA/unsubscribe>.
> To unsubscribe from this group and all its topics, send an email to pretext-
> support+u...@googlegroups.com <mailto:pretext-
> support%2Bunsu...@googlegroups.com>.
> To view this discussion visit https://groups.google.com/d/msgid/pretext-
> support/MTAwMDA0OC5iZWV6ZXI.1753125278%40pnsh <https://groups.google.com/d/
> msgid/pretext-support/MTAwMDA0OC5iZWV6ZXI.1753125278%40pnsh>.
>
>
>
> --
> BHS Bell Schedule app: https://gigamonkeys.com/misc/bhs/ <https://
> gigamonkeys.com/misc/bhs/>
>
>
> --
> 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/
> CAMiqbmnZU1%3DKjoiuXytW1OAMA%2BrGc99kE4r_t4wubFYSkyoSpw%40mail.gmail.com
> <https://groups.google.com/d/msgid/pretext-support/
> CAMiqbmnZU1%3DKjoiuXytW1OAMA%2BrGc99kE4r_t4wubFYSkyoSpw%40mail.gmail.com?
> utm_medium=email&utm_source=footer>.

Peter Seibel

unread,
Jul 21, 2025, 9:10:05 PM7/21/25
to PreTeXt support
Who is supposed to know about _static or assets? I see this in both the html.xml and runestone.xml publication files I have:

  <source>
    <directories external="assets" generated="generated"/>
  </source>


I assume that "assets" is taken as the name of a directory under pretext/ whose contents are copied to external/ directory when the book is built. At least they seem to be identical. I think I put the files I wanted to use as the source of my datafiles in there because the docs for @source say: "supply a @source attribute whose value is the name of an external text file you provide," (emphasis mine) and I interpreted "external text file" as "a text file that will end up in the external directory".

But the reason the xi:include works doesn't seem to have anything to do with pretext. The file is relative to the main.ptx where the xi:include lives. Here's the relevant part of the directory hierarchy:

pretext
├── assets
│   ├── _static
│   │   ├── code
│   │   │   ├── turtleClasses.java
│   │   │   └── turtleClasses2.java
├── main.ptx

As I mentioned before (maybe just to you), I'm pretty sure assets/_static is a remnant of the rst -> PreTeXt conversion which I'll probably clean up some day. And it makes sense to move these .java files out from under pretext/assets since I don't need them copied to the external directory in the built output. When I get around to cleaning up this directory structure I'll probably rename pretext/assets to pretext/external so it matches the external directory in the built book. (And will change the config to <directories external="external" generated="generated" /> .) Then I'll get rid of _static, moving its contents up a level into the new pretext/external directory. And then I'll move anything currently under pretext/external that's only needed at build time somewhere outside of pretext/external but still under pretext.

Does that satisfy your sense of how things should be?

Rob Beezer

unread,
Jul 21, 2025, 9:31:51 PM7/21/25
to pretext...@googlegroups.com
OK, directory management gives me a headache. You should have seen it in the
old days when it was the Wild West. ;-)

> is a remnant

I think that is the disconnect. The CLI loves the word "assets" and Runestone
loves its "_static" directory. I thought maybe you were getting lucky with some
leftover output laying around. And the repo has a pretext/pretext/pretext file.

I didn't read every word of your message (sorry! but its no time for a headache,
but what I skimmed sounds right).

> get around to cleaning up this directory structure

Until you do, keep reminding us what you inherited!

Holler if you really need more from me and I can re-read in the morning.

Rob

On 7/21/25 18:10, Peter Seibel wrote:
> Who is supposed to know about _static or assets? I see this in both the html.xml
> and runestone.xml publication files I have:
>
>   <source>
>     <directories external="assets" generated="generated"/>
>   </source>
>
> I assume that "assets" is taken as the name of a directory under pretext/ whose
> contents are copied to external/ directory when the book is built. At least they
> seem to be identical. I think I put the files I wanted to use as the source of
> my datafiles in there because the docs for @source say: "supply a @source
> attribute whose value is the name of an /external text file /you
> PreTeXtBook/pretext/pull/2615> <https://github.com/ <https://github.com/>
> > PreTeXtBook/pretext/pull/2615> proposes a fix though it could
> > > be construed as a breaking change.
> > >
> > > On Saturday, July 19, 2025 at 11:36:18 AM UTC-7 Peter Seibel wrote:
> > >
> > >     Turns out the issue is when the turtleClasses2.xml file was
> generated it
> > >     just plops the contents of the file as is inside a <pi:text-file
> > >     xmlns:pi="http://pretextbook.org/2020/pretext/internal <http://
> pretextbook.org/2020/pretext/internal> <http://
> > pretextbook.org/2020/pretext/internal <http://pretextbook.org/2020/
> pretext/internal>> <http://
> > > pretextbook.org/2020/pretext/internal <http://pretextbook.org/2020/
> pretext/internal> <http://pretextbook.org/2020/ <http://pretextbook.org/2020/>
> > <https://groups.google.com/d/msgid/pretext- <https://groups.google.com/d/
> msgid/pretext->>
> > > support/8878352c-6a76-44ac-a82f-aa7a082fdbdcn%40googlegroups.com
> <http://40googlegroups.com>
> > <http://40googlegroups.com <http://40googlegroups.com>> <https://
> > > groups.google.com/d/msgid/pretext-support/8878352c-6a76-44ac-a82f-
> <http://groups.google.com/d/msgid/pretext-support/8878352c-6a76-44ac-a82f->
> > <http://groups.google.com/d/msgid/pretext-support/8878352c-6a76-44ac-
> a82f- <http://groups.google.com/d/msgid/pretext-support/8878352c-6a76-44ac-
> a82f->>
> > > aa7a082fdbdcn%40googlegroups.com?utm_medium=email&utm_source=footer
> <http://40googlegroups.com?utm_medium=email&utm_source=footer>
> > <http://40googlegroups.com?utm_medium=email&utm_source=footer
> <http://40googlegroups.com?utm_medium=email&utm_source=footer>>>.
> >
> > --
> > You received this message because you are subscribed to a topic in the
> > Google Groups "PreTeXt support" group.
> > To unsubscribe from this topic, visit https://groups.google.com/d/topic/
> <https://groups.google.com/d/topic/>
> > pretext-support/WYqYAiOfKiA/unsubscribe <https://groups.google.com/d/
> topic/ <https://groups.google.com/d/topic/>
> > pretext-support/WYqYAiOfKiA/unsubscribe>.
> > To unsubscribe from this group and all its topics, send an email to pretext-
> > support+u...@googlegroups.com <mailto:pretext-
> > support%2Bunsu...@googlegroups.com>.
> > To view this discussion visit https://groups.google.com/d/msgid/pretext-
> <https://groups.google.com/d/msgid/pretext->
> > support/MTAwMDA0OC5iZWV6ZXI.1753125278%40pnsh <https://groups.google.com/
> d/ <https://groups.google.com/d/>
> > msgid/pretext-support/MTAwMDA0OC5iZWV6ZXI.1753125278%40pnsh>.
> >
> >
> >
> > --
> > BHS Bell Schedule app: https://gigamonkeys.com/misc/bhs/ <https://
> gigamonkeys.com/misc/bhs/> <https://
> > gigamonkeys.com/misc/bhs/ <http://gigamonkeys.com/misc/bhs/>>
> >
> >
> > --
> > 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/ <https://groups.google.com/d/msgid/pretext-support/>
> > CAMiqbmnZU1%3DKjoiuXytW1OAMA%2BrGc99kE4r_t4wubFYSkyoSpw%40mail.gmail.com
> <http://40mail.gmail.com>
> > <https://groups.google.com/d/msgid/pretext-support/ <https://
> groups.google.com/d/msgid/pretext-support/>
> > CAMiqbmnZU1%3DKjoiuXytW1OAMA%2BrGc99kE4r_t4wubFYSkyoSpw%40mail.gmail.com
> <http://40mail.gmail.com>?
> > utm_medium=email&utm_source=footer>.
>
> --
> 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/01b9167d-d15f-4c33-a3f3-72ecba6602f3n%40googlegroups.com <https://
> groups.google.com/d/msgid/pretext-support/01b9167d-d15f-4c33-
> a3f3-72ecba6602f3n%40googlegroups.com?utm_medium=email&utm_source=footer>.

Reply all
Reply to author
Forward
0 new messages