【发布时间】:2016-01-17 06:57:39
【问题描述】:
InDesign 支持特殊的格式属性,让我可以在 XML 文件中嵌入对段落、字符、表格或单元格样式的引用。导入和布局 XML 文件时,InDesign 使用引用的样式来设置该元素的格式。但是如何将< 和> 等转换为辅助命名空间。
这是我的输入:
<article>
<para><em>Eheniendel il <strong>evel</strong></em>mos illanit atatur <strong>reptatiat</strong></para>
<para>Os veles qui ne voluptaquam, quid qui <strong>rehendi</strong>.</para>
<para>Berchicide <strong>reperumet</strong> ilicitatin <em>cus</em></para>
<para>Dellabores ant. <em>Arte</em> Dandae si <strong>rectur</strong>?</para>
<para>Am, voloribus doluptatem aut, <em>cor</em> aut <em>conse</em></para>
我需要这样的输出:
<article>
<para>
<em aid:cstyle="italic">Eheniendel il <em aid:cstyle="bold-italic">evel</em>
</em>mos illanit atatur <em aid:cstyle="bold">reptatiat</em>
</para>
<para>Os veles qui ne voluptaquam, quid qui <em aid:cstyle="bold">rehendi</em>.</para>
<para>Berchicide <em aid:cstyle="bold">reperumet</em> ilicitatin <em aid:cstyle="italic">cus</em>
</para>
<para>Dellabores ant. <em aid:cstyle="italic">Arte</em> Dandae si <em aid:cstyle="bold">rectur</em>?</para>
<para>Am, voloribus doluptatem aut, <em aid:cstyle="italic">cor</em> aut <em aid:cstyle="italic">conse</em>
</para>
</article>
我需要转换:
<em> to <em aid:csytle = "italic">
<strong> to <em aid:csytle = "bold">
<strong><em> or <em><strong> to <em aid:csytle = "bold-italic">
我制作了我的 xslt 1.0 样式表,它适用于普通的 xml 元素,如 <em> end <strong>。如何根据我的输入改进它?
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"
xmlns:aid5="http://ns.adobe.com/AdobeInDesign/5.0/">
<xsl:output method="xml" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()" />
</xsl:copy>
</xsl:template>
<xsl:template match="/root">
<root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"
xmlns:aid5="http://ns.adobe.com/AdobeInDesign/5.0/">
<xsl:apply-templates select="@* | node()"/>
</root>
</xsl:template>
<xsl:template match="strong">
<xsl:element name="em">
<xsl:attribute name="aid:cstyle">
<xsl:value-of select="'bold'"/>
</xsl:attribute>
<xsl:apply-templates/>
</xsl:element>
</xsl:template>
<xsl:template match="em">
<xsl:element name="em">
<xsl:attribute name="aid:cstyle">
<xsl:value-of select="'italic'"/>
</xsl:attribute>
<xsl:apply-templates/>
</xsl:element>
</xsl:template>
<xsl:template match="em[../../strong]|strong[../../em]">
<xsl:element name="em">
<xsl:attribute name="aid:cstyle">
<xsl:value-of select="'bold-italic'"/>
</xsl:attribute>
<xsl:apply-templates/>
</xsl:element>
</xsl:template>
【问题讨论】:
标签: xml xslt-1.0 adobe-indesign