When creating a page that describes a menu, it is often handy to use <embed> elements to include sections of content. The template for including headings in embedded mode shifts heading levels with a "+ 1", so multiple h1 elements would be avoided. However, sometimes this results in a rendered menu item list mixing h2 and h3, when the desired result would be all h2 headings. I figured it would be nice to be able to force a certain heading level for all of the embedded headings. With something like <embed href="blabla" overrideheadings="h2"/> I ran into a wall, when trying to tunnel the parameter value to the final apply-templates. A hardcoded solution by creating a mode="overrideheadings" is possible (I tried it and it worked), but it would be nice to be able to pass values to the override. I am able to pass the value up to this point, <xsl:template name="insertembed">: https://opengrok.libreoffice.org/xref/help/help3xsl/online_transform.xsl#1069 As the template is applied to the headings indirectly - the direct applying concerns <section> - I am not able to pass the parameter value to them. I mean I tried an xsl:with-param inside the xsl:apply-templates in insertembed, but the parameter is missing in action when it comes to the headings. Heading templates are here, <xsl:template match="h1 | h2 | h3 | h4 | h5 | h6">: https://opengrok.libreoffice.org/xref/help/help3xsl/online_transform.xsl#752 After doing some reading, apparently XSLT 2.0 would have a thing called tunnel parameters, which would apparently be the Holy Grail for me: https://www.w3.org/TR/xslt20/#tunnel-params To be clear, this will not deliver the parameter value to the heading code path: <xsl:apply-templates select="$doc//section[@id=$anchor]" mode="embedded"> <xsl:with-param name="overrideheading" select="$overrideheading" /> </xsl:apply-templates> To start the journey, I use this: <!-- EMBED --> <xsl:template match="embed"> <xsl:param name="overrideheading"/> <xsl:call-template name="resolveembed"> <xsl:with-param name="overrideheading" select="@overrideheading" /> </xsl:call-template> </xsl:template> Then hand the param over from resolveembed to insertembed.
There is a alternate solution to set the desired heading level in embedded headings: use <variable> and <embedvar> https://wiki.documentfoundation.org/Documentation/Understanding,_Authoring_and_Editing_Openoffice.org_Help/3#embedvar https://wiki.documentfoundation.org/Documentation/Understanding,_Authoring_and_Editing_Openoffice.org_Help/3#variable Take the case of https://help.libreoffice.org/7.0/en-US/text/swriter/main0102.html the source of the heading "Undo" is <embed href="text/shared/01/02010000.xhp#undo"/> Looking at the href= contents, we have <section id="undo"> <section id="rueckgaengig"><comment>Can this removed?</comment> <bookmark xml-lang="en-US" branch="index" id="bm_id3155069"><bookmark_value>undoing;editing</bookmark_value> <bookmark_value>editing;undoing</bookmark_value> </bookmark> <bookmark xml-lang="en-US" branch="hid/.uno:Undo" id="bm_id87410" localize="false"/> <bookmark xml-lang="en-US" branch="hid/svx/ui/imapdialog/TBI_UNDO" id="bm_id3148983" localize="false"/> <paragraph role="heading" id="hd_id3155069" xml-lang="en-US" level="1"><link href="text/shared/01/02010000.xhp" name="Undo">Undo</link></paragraph> <paragraph role="paragraph" id="par_id3149205" xml-lang="en-US"><ahelp hid=".">Reverses the last command or the last entry you typed. To select the command that you want to reverse, click the arrow next to the <emph>Undo</emph> icon on the <emph>Standard</emph> bar.</ahelp></paragraph> </section> </section> We are interested in <link href="text/shared/01/02010000.xhp" name="Undo">Undo</link> which we wrap in a <variable> <variable id="myheading"><link href="text/shared/01/02010000.xhp" name="Undo">Undo</link></variable> In the Menu help page, replace <embed .../> by <h2 id="231212312" localize="false"><embedvar href="text/shared/01/02010000.xhp#myheading"/></h2> The paragraph that follows the heading shall also be wraped in the same scheme. There will be a significant rework for the menus description, though.
It is also perfectly possible to add a new (optional) attribute to the <embed> tag in the DTD and set the desired heading level of the target, and adapt in the XSLT. Fact is that headings can come in either <h1> format or <paragraph role="heading" level="1">. Proper handling of the new attribute in XLST is not too complex. It will be written in the pieces where mode="emnbedded".
Your solution with embedvar is something I wanted to specifically avoid, ie. creating lots more markup both in the source content and referring content. No need to worry about paragraph role="heading", I would convert those in the source to h* elements. Concrete example: Creating help for submenu "Text", getting menu help for single and double underline: <embed href="text/shared/01/05110300.xhp#untersingle" overrideheading="h2"/> <embed href="text/shared/01/05110300.xhp#unterdouble" overrideheading="h2"/> Source markup: <section id="untersingle"> <h2 id="hd_id949353401761432" xml-lang="en-US"><link href="text/shared/01/05110300.xhp" name="SingleUnderline">Single Underline</link></h2> <bookmark branch="hid/.uno:Underline" xml-lang="en-US" id="bm_id3144750" localize="false"/> <paragraph role="paragraph" id="par_id212197604765254" xml-lang="en-US"><ahelp hid=".uno:Underline">Underlines the selected text with a single line.</ahelp></paragraph> </section> <section id="unterdouble"> <h2 id="hd_id949353401761432" xml-lang="en-US"><link href="text/shared/01/05110300.xhp" name="DoubleUnderline">Double Underline</link></h2> <bookmark branch="hid/.uno:UnderlineDouble" xml-lang="en-US" id="bm_id3147143" localize="false"/> <paragraph role="paragraph" id="par_id3154894" xml-lang="en-US"><ahelp hid=".uno:UnderlineDouble">Underlines the selected text with two lines.</ahelp></paragraph> </section>