Page 1 of 1

Using XPath with reusable content

Posted: Thu Sep 24, 2020 12:46 am
by mdslup
I am developing a set of procedures that all have unique names and ID codes.

I want to create a "master list" of procedure names and ID codes. My first thought was to use raw XML, like this:

Code: Select all

<master-list>
	<entry>
		<procedure-name>Remove Component 1</procedure-name>
		<unique-id>1234</unique-id>
	</entry>
	<entry>
		<procedure-name>Remove Component 2</procedure-name>
		<unique-id>5678</unique-id>
	</entry>
<master-list>	
Now, when I create each task file, I want the title of each task to pull from this XML document. I would use XPath to do this.

But I don't understand where I tell Oxygen to use XPath to pull content from another reference.

Am I thinking about this correctly? Is there a better way to do this, like is this what a "key map" is?

Re: Using XPath with reusable content

Posted: Thu Sep 24, 2020 12:13 pm
by alex_jitianu
Hello,

You can create Document Templates that use the ${xpath_eval(expression)} editor variable to extract the data from the file and further process it as needed. To access the "master list" file you ca:
- use the ${pdu} editor variable, if you are using Oxygen project files and the master file is somewhere in the project directory.
- add a mapping in a catalog file (perhaps the catalog from a framework) between a generic URL and the location of the file. In the XPath expression you use the generic URL.

To avoid duplicating that ${xpath_eval(expression)} in every document template, you can create a custom editor variable that maps to that long ${xpath_eval(expression)}, like an alias. Afterwards, in the document templates, you can use the custom editor variable which is shorter.

By the way, which XML vocabulary are you using? Is it DITA or a proprietary one?

Best regards,
Alex