Re: Xpath for validating if href in xref element is pointing to <fn> element #XSLT

Chris Papademetrious

If you are using Oxygen as your editor, there is a setting to always set @type in new <xref> elements:

<xref href="test.dita#test_overview/fn_5fc" type="fn"/>

You can find this setting in Preferences > DITA > Topics, then enable Type in the Always set values for the following attributes list. We use this setting, and it makes this sort of processing and validation much easier.

Otherwise, maybe you could (1) write a function to extract the ID from an @href, (2) put all <fn> ID values in the current document in a variable, and (3) write something like

<xsl:variable name="fnXCount" select="count($prmElement/descendant::*[contains(@class,' topic/xref ')][get_ID(@href) = $all_fn_IDs])"/>

When the '=' operator is given lists, it returns true if there are common items between the lists. In this case, the ID returned by get_ID() would be a list of one string value.

(Disclaimer: I am not an XSLT expert myself.)

 - Chris

Join to automatically receive all group messages.