我正在寻找有关如何使用InDesign标记文字创建交叉引用的解决方案,但我找不到任何好的建议。
这是我的方案我的任务是创建XML到InDesign的圆形跳闸工作流程和InDesign到XML,反之亦然。我还需要对URL和End Notes链接进行交叉引用。
首先,我必须创建和XSLT脚本,将XML转换为InDesign标记文本(我使用标记文本,因为我们的大多数操作员仍在使用InDesign CS3)。然后在页面组合完成后,我们必须将InDesign文件导出到XHTML(导出为Dreamweaver)。创建另一个XSLT脚本以将XHTML转换回XML以用于ePub转换(为什么不直接将InDesign导出到ePub?答案是需要进行大量自定义)。
以下是我为标记文本创建交叉引用的XSLT代码:
将交叉引用添加到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>
为结束备注创建交叉引用链接:
<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>
创建交叉引用网址
<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>
这是我的问题,当我将标记文本导入InDesign URL并且endnotes具有死链接时。我怀疑它是目标密钥,因为当我尝试使用工作链接导出示例InDesign时,目标密钥的目标是字符的位置,它应该交叉引用。
我的问题是:
非常感谢任何建议或建议。
谢谢!
P.S。此链接http://forums.adobe.com/message/3978432#3978432还讨论了针对交叉引用条目的InDesign标记文本,但没有给出完整的解决方案。
答案 0 :(得分:1)
刚为自己测试了这个。可以在导入之前添加对标记文本的交叉引用,但是如您所述,您必须找到交叉引用目标与整个文档相比的字符位置。这听起来很难并且容易出错,尤其是当您考虑特殊字符的可能性时。虽然,但这是可能的。
此外,我认为这不是<HyperlinkDestKey:5>
标记定位字符的位置,我认为它是<HyperlinkDestIndex:55555>
标记。
这可能不太理想,但您可以在导入标记文本后应用Javascript,而不是尝试在InDesign标记文本中添加交叉引用。对于交叉引用,Javascript API将更容易使用,但它也会更慢。
以下是使用Javascript API的超链接的示例:
// Get the currently active document
var doc = app.activeDocument;
// Get the hyperlink source and destinations by feeding them
// an InDesign text object.
var linkSource = doc.hyperlinkTextSources.add(sourceText);
var linkDest = doc.textDestinations.add(destText);
// Add the hyperlink to the document
doc.hyperlinks.add(linkSource, linkDest);
您可以在文档中找到sourceText
和destText
。找到您想要制作超链接的文本对象的一种方法是使用InDesign的查找更改功能来查找它们,这些功能可以从DOM访问。