Page 1 of 1

Reference to topic of topic

Posted: Wed Oct 23, 2024 4:49 pm
by dhollis
Hi,

I'm reading this: The @keyref attribute, and specifically: For elements that can refer to elements within maps or topics, the value of the @keyref attribute is a key name, a slash ("/"), and the ID of the target element, where the key name must be bound to either the map or topic that contains the target element.

I've created this topic of topics, and the <keyword/> doesn't resolve, see attached,

Many thanks,
David

<map>
<title>Information Architecture Examples</title>
<topicref keys="sysvars" href="system-variables.dita" />
</map>

<topic id="system-variables">
<title>System variables</title>
<shortdesc>An approach to system variables.</shortdesc>
<body>
<p>Blurb</p>
</body>
<topic id="activate_all_roles_on_login">
<title>activate_all_roles_on_login</title>
<body>
<p><keyword keyref="sysvars/activate_all_roles_on_login"/></p>
</body>
</topic>
</topic>

Re: Reference to topic of topic

Posted: Thu Oct 24, 2024 7:44 am
by Radu
Hi David,
You should probably read this part here "Effective text content is determined using the following set of rules:":
https://www.oxygenxml.com/dita/1.3/spec ... -text.html

Your case matches the situation in the specs:
For elements that also exist as a child of <topicmeta> in the key definition, effective content is taken from the first matching direct child of <topicmeta>. For example, given the following key definition, an empty <author> element with the attribute keyref="justMe" would result in the matching content "Just M. Name":

Code: Select all

<keydef keys="justMe" href="http://www.example.com/my-profile" format="html" scope="external">
  <topicmeta>
    <author>Just M. Name</author>
  </topicmeta>
</keydef>
Regards,
Radu

Re: Reference to topic of topic

Posted: Thu Oct 24, 2024 12:36 pm
by dhollis
Ah, right, thanks Radu.

An xref would pull from the title, that's the difference.

Re: Reference to topic of topic

Posted: Thu Oct 24, 2024 12:43 pm
by Radu
Hi David,
Right, for xref with keyref to a key which does not have any topicmeta this part of the specs should apply:
https://www.oxygenxml.com/dita/1.3/spec ... -text.html
Otherwise, if the element with the key reference results in a link, normal link text determination rules apply as they would for <xref> (for example, using the <navtitle> or falling back to the URI of the link target).
Regards,
Radu

Re: Reference to topic of topic

Posted: Thu Oct 24, 2024 12:50 pm
by dhollis
Hmm, I've got about 1,000 of these! I was hoping to avoid putting all of them into a map.
I guess there's no way around it?
Thanks.

Re: Reference to topic of topic

Posted: Thu Oct 24, 2024 2:48 pm
by Radu
Hi,
So in a way you are attempting to reuse topic titles using keyrefs but without generating a link, I do not see a way to do this with the current standard, maybe you could add some outputclass attribute on the xref and then process it further in the publishing customization and get rid of the link...
Regards,
Radu

Re: Reference to topic of topic

Posted: Thu Oct 24, 2024 4:23 pm
by dhollis
Curious?
This works: href="system-variables.dita#activate_all_roles_on_login"
This doesn't: keyref="sysvars#activate_all_roles_on_login"
I'd expect that a reference to a child topic could use a keyref based on a keydef to the parent topic.
Anyway, I'll just have to live with it.
Thanks for your assistance, Radu.

Re: Reference to topic of topic

Posted: Thu Oct 24, 2024 4:57 pm
by Radu
Hi David,
I'd expect that a reference to a child topic could use a keyref based on a keydef to the parent topic.
All topics inside a DITA XML file behave as top level topics. The keyref "keyName/elementID" can only refer to a non-topic "elementID".
Otherwise you need to create a key for each inner topic like:

Code: Select all

<keyref href="topic.dita#innerTopicID" keys="innerTopicKey"/>
Regards,
Radu

Re: Reference to topic of topic

Posted: Thu Oct 24, 2024 6:06 pm
by dhollis
OK, so I'm going to have to set up keydefs to all these child topics, and I'll put them in their own map.
I need cross document links to this content, which would normally be with keyscopes.
But, surely I could just incorporate the keydef map in any other document that needs to link to it? Making sure that it is all resource-only.
That would define the necessary keys, but not pull the content in.
Why bother with keyscopes? One way or another, it is necessary to tell the second document where to go to resolve the keys.
Am I missing something?
Thanks once again.