luap Posted November 16, 2012 Share Posted November 16, 2012 I am trying to create an xref and cannot get the correct step number in the reference. I am pointing at the cmd tag because when I point at the step tag, it does not link to a page number. The below code (second set) counts all the preceding cmd tags in the whole document. Is there a way to count only the cmd tags in the current task/topic? I have tried creating variables (shown directly below), and this gets me to the correct task number in the document. From there, I could not get it to count the preceding cmd tags in the task in the CurrTask position. Any help on this is greatly appreciated. <xsl:variable name="Tasks" select="count(preceding::*[contains(@class, ' task/steps ')])" /> <xsl:variable name="CurrTask" select="$Tasks +1" /> <xsl:template match="*[contains(@class, ' task/cmd ')]" mode="retrieveReferenceTitle"><xsl:call-template name="insertVariable"> <xsl:with-param name="theVariableID" select="'Step'"/> <xsl:with-param name="theParameters"> <number> <xsl:value-of select="count(preceding::*[contains(@class, ' task/cmd ')]) + 1"/></number></xsl:with-param> </xsl:call-template> </xsl:template> Alternatively, when I point the xref at the step, and insert <fo:inline id="{@id}"/> and <xsl:call-template name="insertPageNumberCitation"/> at the end of the template, it gives me the page number of the actual xref, not the page number of the step it is pointing at. Thank you. Link to comment Share on other sites More sharing options...
DVezina Posted November 17, 2012 Share Posted November 17, 2012 DITA eh? All the element ids are stored in a key called "key_anchor". This is defined in links.xsl. Make sure your step actually has an id attribute in the MERGED XML. This sounds silly but if this is running through the DITA toolkit, strange things can happen.You want to put the <fo:inline> in your step template. task-elements.xsl [size="1"]<xsl:template match="*[contains(@class, ' task/steps ')]/*[contains(@class, ' task/step ')]">[/size][size="1"]<fo:inline id="{@id}"/>[/size] Then in your xref template, you should find the matching id in the key_anchor. Now you are truly pointing at the step and you get the page number or get it's count from the element "steps". Something like this: [size="1"]<fo:inline color="blue">[/size][size="1"]<xsl:for-each select="key('key_anchor',@href)">[/size][size="1"]<!-- Found the step with the matching id -->[/size][size="1"]<fo:basic-link internal-destination="{@id}">[/size][size="1"]<!-- Or count step from steps -->[/size][size="1"]<xsl:text>See page </xsl:text><fo:page-number-citation ref-id="{$destination}"/>[/size][size="1"]</fo:basic-link>[/size][size="1"]</xsl:for-each>[/size][size="1"]</fo:inline>[/size] Hope this helps! Link to comment Share on other sites More sharing options...
DVezina Posted November 17, 2012 Share Posted November 17, 2012 Well that posted incorrectly.Here it is again. --DITA eh? All the element ids are stored in a key called "key_anchor". This is defined in links.xsl. Make sure your step actually has an id attribute in the MERGED XML. This sounds silly but if this is running through the DITA toolkit, strange things can happen.You want to put the <fo:inline> in your step template. task-elements.xsl<xsl:template match="*[contains(@class, ' task/steps ')]/*[contains(@class, ' task/step ')]"><fo:inline id="{@id}"/>Then in your xref template, you should find the matching id in the key_anchor. Now you are truly pointing at the step and you get the page number or get it's count from the element "steps". Something like this:<fo:inline color="blue"><xsl:for-each select="key('key_anchor',@href)"><!-- Found the step with the matching id --><fo:basic-link internal-destination="{@id}"><!-- Or count step from steps --><xsl:text>See page </xsl:text><fo:page-number-citation ref-id="{$destination}"/></fo:basic-link></xsl:for-each></fo:inline>Hope this helps! Link to comment Share on other sites More sharing options...
DVezina Posted November 17, 2012 Share Posted November 17, 2012 OK one more try ...DITA eh?All the element ids are stored in a key called "key_anchor". This is defined in links.xsl.Make sure your step actually has an id attribute in the MERGED XML. This sounds silly but if this is running through the DITA toolkit, strange things can happen.You want to put the <fo:inline> in your step template. task-elements.xsl<xsl:template match="*[contains(@class, ' task/steps ')]/*[contains(@class, ' task/step ')]"><fo:inline id="{@id}"/>Then in your xref template, you should find the matching id in the key_anchor.Now you are truly pointing at the step and you get the page number or get it's count from the element "steps".Something like this:<fo:inline color="blue"><xsl:for-each select="key('key_anchor',@href)"><!-- Found the step with the matching id --><fo:basic-link internal-destination="{@id}"><!-- Or count step from steps --><xsl:text>See page </xsl:text><fo:page-number-citation ref-id="{$destination}"/></fo:basic-link></xsl:for-each></fo:inline>Hope this helps! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now