I've looking for solution on how to create cross-reference using InDesign Tagged Text but I can't find any good suggestion.
Here is my scenario I was task to create a round tripping workflow for XML to InDesign and InDesign to XML or vice versa. I also need to cross-reference for URL and End Notes links.
So first, I have to create and XSLT script that would transform XML to InDesign Tagged Text (I used tagged text because most of our operators still using InDesign CS3). Then after page composition is done we'll have to export InDesign file to XHTML (export for dreamweaver). Create another XSLT script to transform back XHTML to XML to be use for ePub conversion (why not export directly InDesign to ePub? the answer is there's a lot of customization needed).
Below is my XSLT codes to create cross-ref for Tagged Text:
Adding Cross-ref to InDesign:
<xsl:template match="/">
<--! End Notes -->
<xsl:text><XRefFmtDefn:=<FmtNm:ntf><CharStyleRef:ntf><BldBlkLen:1><BldBlk:=<BlkTyp:ParagraphNumber><CstmTxt:><CharStyleRef:><InclDlm:0>>></xsl:text>
<xsl:for-each select="descendant::apnf">
<xsl:variable name="num" select="count(preceding::apnf) + 1"/>
<xsl:text><HplDestDfn:=<HplDestName:Anchor </xsl:text><xsl:value-of select="$num"/><xsl:text>><DestKey:</xsl:text><xsl:value-of select="$num"/><xsl:text>><HplDestIdx:1</xsl:text><xsl:text>><IsPara:1><Hid:0>></xsl:text>
</xsl:for-each>
<--! URL -->
<xsl:text disable-output-escaping="yes"><HplDestDfn:=</xsl:text>
<xsl:for-each select="descendant::libelle[generate-id()=generate-id(key('urlDistinct', @cible)[1])]">
<xsl:value-of select="concat('<HplDestName:', replace(@cible,'/', '\\/'),'><DestKey:1><HplDestUrl:http\:\/\/', replace(@cible,'/', '\\/'), '>')"/>
</xsl:for-each>
<xsl:text disable-output-escaping="yes"><Hid:0>></xsl:text>
<xsl:apply-templates/>
</xsl:template>
Create cross-ref links for End Notes:
<xsl:template match="apnf">
<xsl:variable name="num" select="count(preceding::apnf) + 1"/>
<xsl:text><cstyle:ntf></xsl:text>
<xsl:text><Hpl:=<HplName:</xsl:text><xsl:value-of select="@id"/> <xsl:text>><HplDest:Anchor </xsl:text><xsl:value-of select="$num"/><xsl:text>><DestKey:</xsl:text><xsl:value-of select="$num"/><xsl:text>><XRefFmt:ntf><CharStyleRef:><HplLen:1><HplOff:0><Hid:0><Brdrv:0><Brdrw:Thin><Brdrh:None><Brdrs:Solid><Brdrc:0\,0\,0>></xsl:text>
<xsl:value-of select="$num"/>
<xsl:text><cstyle:></xsl:text>
</xsl:template>
Create cross-ref URLs
<xsl:template match="url">
<xsl:text><cstyle:url></xsl:text>
<xsl:choose>
<xsl:when test="exists(libelle)">
<xsl:text><Hpl:=<HplName:</xsl:text><xsl:value-of select="replace(libelle/@cible,'/', '\\/')"/><xsl:text>><HplDest:http\:\/\/</xsl:text><xsl:value-of select="replace(libelle/@cible,'/', '\\/')"/><xsl:text>><DestKey:1><CharStyleRef:><HplLen:3><HplOff:0><Hid:0><Brdrv:0><Brdrw:Thin><Brdrh:None><Brdrs:Solid><Brdrc:0\,0\,0>></xsl:text>
<xsl:sequence select="libelle/text()"/>
</xsl:when>
<xsl:otherwise>
<xsl:sequence select="./text()"/>
</xsl:otherwise>
</xsl:choose>
<xsl:text><cstyle:></xsl:text>
</xsl:template>
Here is my problem, when I imported the tagged text to InDesign URL and endnotes has dead links. I suspect it is the destination key, because when I tried to export sample InDesign with working links the destination key is targeting the position of the character where it should be cross-ref.
My questions are:
- Cross-Reference is supported in InDesign Tagged Text like ICML does?
- Is there's a way I can get position() of character in XML using XSLT (meaning position of character within the whole XML not position within single node)? If is possible maybe I could get destination key correctly.
Any suggestions or recommendations is highly appreciated.
Thanks!
P.S. This link http://forums.adobe.com/message/3978432#3978432 also discussed InDesign Tagged Text for Cross-reference Entries but there is no complete solution is given.