TOC breaks when making external changes to hmxp

Discussions about Help+Manual 9

Moderators: Alexander Halser, Tim Green

Post Reply
ManualHelper
Posts: 3
Joined: Thu Mar 30, 2023 11:21 am

TOC breaks when making external changes to hmxp

Unread post by ManualHelper »

Hi,

We are trying to automate changing variable values by directly changing them in the .hmxp file.
After parsing hmxp, changing stuff and writing it back to file, the project still opens, but the TOC is empty.
(Using ElementTree in Python to change the relevant XML entries and writing back to file).

I'm not sure what XML code got damaged in the process and further, what code would even be relevant for the TOC in the first place.

The only obvious thing I found was the big block of HTML code getting escaped by parsing it.

Code: Select all

      <config-group name="TOPICTEMPLATES">
        <config-value name="Default" translate="true"><![CDATA[<%DOCTYPE%>
<html>
<head>
   <title><%TOPIC_TITLE%></title>
   <meta name="generator" content="Help &amp; Manual" />
   <meta name="keywords" content="<%TOPIC_KEYWORDS%>" />
   <meta http-equiv="Content-Type" content="text/html; charset=<%DOCCHARSET%>" />
   <meta http-equiv="X-UA-Compatible" content="IE=edge" />
   <meta name="description" content="<%TOPIC_DESCRIPTION%>"
   (...) />
turns to

Code: Select all

      <config-group name="TOPICTEMPLATES">
        <config-value name="Default" translate="true">&lt;%DOCTYPE%&gt;
&lt;html&gt;
&lt;head&gt;
   &lt;title&gt;&lt;%TOPIC_TITLE%&gt;&lt;/title&gt;
   &lt;meta name="generator" content="Help &amp;amp; Manual" /&gt;
   &lt;meta name="keywords" content="&lt;%TOPIC_KEYWORDS%&gt;" /&gt;
   &lt;meta http-equiv="Content-Type" content="text/html; charset=&lt;%DOCCHARSET%&gt;" /&gt;
   &lt;meta http-equiv="X-UA-Compatible" content="IE=edge" /&gt;
   &lt;meta name="description" content="&lt;%TOPIC_DESCRIPTION%&gt;" /&gt;
This is not optimal, but manually changing it back to the original text did not help bringing back the TOC, so not sure if it even matters.
Other parts of the code are not affected by this since they are already escaped "properly"
For example:

Code: Select all

<config-value name="title" translate="true">&lt;%TITLE%&gt;</config-value>
All the other code seems identical to the functioning version.
The other files (topics, baggage, maps, .xsd, .xsl) were not altered.

Can someone shed light on this behaviour?
ManualHelper
Posts: 3
Joined: Thu Mar 30, 2023 11:21 am

Re: TOC breaks when making external changes to hmxp

Unread post by ManualHelper »

Found the problem:

The namespace was changed in 3 places:

<helpproject xmlns:ns1="http://www.w3.org/2001/XInclude"
(...)
<ns1:include parse="xml" href="Maps/table_of_contents.xml" />
<ns1:include parse="xml" href="Maps/table_of_contents_1.xml" />

"ns1" needs to be "xi"

Sorry for the quickshot posting :typing:
Maybe this is still interesting to others.
Post Reply