Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
是否在XML CALS表中添加indesign单元格样式?_Xml_Xslt_Html Table_Adobe Indesign - Fatal编程技术网

是否在XML CALS表中添加indesign单元格样式?

是否在XML CALS表中添加indesign单元格样式?,xml,xslt,html-table,adobe-indesign,Xml,Xslt,Html Table,Adobe Indesign,我有一个包含CALS表的XML文件,我想将其导入indesign。 问题是,indesign中的实际表格定义了一些单元格样式,indesign不允许向CALS表格(仅indesign表格)添加标记(以及其他样式) 我的xml看起来像这样 <table> <tgroup cols="6"> <colspec colname="c1" colwidth="29pt"/> <colspec colname="c2" colwidth="172pt"/>

我有一个包含CALS表的XML文件,我想将其导入indesign。 问题是,indesign中的实际表格定义了一些单元格样式,indesign不允许向CALS表格(仅indesign表格)添加标记(以及其他样式)

我的xml看起来像这样

<table>
<tgroup cols="6">
<colspec colname="c1" colwidth="29pt"/>
<colspec colname="c2" colwidth="172pt"/>
<colspec colname="c3" colwidth="71pt"/>
<colspec colname="c4" colwidth="69pt"/>
<colspec colname="c5" colwidth="113pt"/>
<colspec colname="c6" colwidth="69pt"/>
<thead>
<row>
<entry align="left" colsep="0" valign="bottom">Tag</entry>
<entry align="left" colsep="0" valign="bottom">Datum</entry>
<entry align="left" colsep="0" valign="bottom">Zeit</entry>
<entry align="left" colsep="0" valign="bottom">Ort</entry>
<entry align="left" colsep="0" valign="bottom">Leitung</entry>
<entry align="left" colsep="0" valign="bottom">Kursnummer</entry>
</row>
</thead>
<tbody>
<row>
<entry colsep="0">Mi</entry>
<entry colsep="0" valign="bottom">15.03.2012, 16.03.2012, 17.03.2012</entry>
<entry colsep="0" valign="bottom">10:15 - 11:45</entry>
<entry colsep="0" valign="bottom">someplace</entry>
<entry colsep="0" valign="bottom">some Name</entry>
<entry colsep="0" valign="bottom">ABC-DE-12</entry>
</row>
<row>
<entry colsep="0">Mi</entry>
<entry colsep="0" valign="bottom">15.06.2012, 16.06.2012, 17.06.2012</entry>
<entry colsep="0" valign="bottom">09:15 - 10:45</entry>
<entry colsep="0" valign="bottom">otherplace</entry>
<entry colsep="0" valign="bottom">other Name</entry>
<entry colsep="0" valign="bottom">XYZ-U-K-13</entry>
</row>
</tbody>
</tgroup>
</table>

标签
资料
泽特
奥特
雷东
库斯努默
惯性矩
15.03.2012, 16.03.2012, 17.03.2012
10:15 - 11:45
某处
某个名字
ABC-DE-12
惯性矩
15.06.2012, 16.06.2012, 17.06.2012
09:15 - 10:45
别处
其他名称
XYZ-U-K-13
当我导入这个时,我得到一个标准表格,周围有一些黑色边框,字体大小是错误的。我还在cellstyles中添加了更多细节(即彩色边框底部0.5pt)。如果我能在indesign中做所有的造型就太好了。我真的不喜欢在xml中设置
colwidth
,但我明白为什么我必须这样做

我听说那里有使用xslt或idml的解决方案,但我对两者都不熟悉。。。 是否有一个简单的解决方案来添加单元格样式(一个用于
,另一个用于

同样的问题也适用于表格样式(现在还不需要,但也许我以后需要它…)

  • 您必须使用一些示例数据在InDesign中设计表的外观
  • 标记示例表的内容
  • 使用XML导出函数导出示例表
  • 基于示例xml数据,您可以为cals表编写转换
  • 应用indesign xslt选项导入Cals数据
  • 如果您没有这样的经验,那么最棘手的部分可能是为表标记及其属性提供正确的名称空间:

    xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"
    

    下面是一个示例XSLT样式表,用于将数据转换为具有cellstyles的indesign表:

    <xsl:stylesheet 
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
    xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"
    xmlns:aid5="http://ns.adobe.com/AdobeInDesign/5.0/"
    exclude-result-prefixes="xs">
    
    <xsl:output indent="yes" encoding="UTF-8" standalone="yes" />
    <xsl:strip-space elements="table thead tbody row entry" />
    
    <xsl:variable name="tcols"><xsl:value-of select="table/tgroup/@cols" /></xsl:variable>
    <xsl:variable name="trows"><xsl:value-of select="ceiling ( ( count(table/tgroup/thead/row/entry) + count(table/tgroup/tbody/row/entry) ) div $tcols )" /></xsl:variable>
    
    <xsl:template match="/">
        <xsl:processing-instruction name="whitespace-handling">
            <xsl:text>use-tags</xsl:text>
        </xsl:processing-instruction>
        <table aid:table="table" aid:trows="{$trows}" aid:tcols="{$tcols}">
            <xsl:apply-templates select="table/tgroup/thead/row" />
            <xsl:apply-templates select="table/tgroup/tbody/row" />    
        </table>
    </xsl:template>
    
    <xsl:template match="thead/row/entry | tbody/row/entry">
        <cell aid:table="cell" aid:crows="1" aid:ccols="1">
            <xsl:if test="ancestor::thead">
                <xsl:attribute name="aid:theader" />
            </xsl:if>
            <!-- Here your style-definition based on something  -->
            <xsl:attribute name="aid5:cellstyle"><xsl:text>mycellstyle</xsl:text></xsl:attribute>
            <xsl:attribute name="aid:ccolwidth">
                <xsl:call-template name="getcolwidth">
                    <xsl:with-param name="position">
                        <xsl:value-of select="position()" />
                    </xsl:with-param>
                </xsl:call-template>
            </xsl:attribute>
            <xsl:value-of select="." />
        </cell>
    </xsl:template>
    
    <xsl:template name="getcolwidth">
        <xsl:param name="position" />
        <xsl:for-each select="/table/tgroup/colspec">
            <xsl:if test="position() = $position">
                <xsl:value-of select="substring-before(@colwidth, 'pt')" />
            </xsl:if>
        </xsl:for-each>
    </xsl:template>
    
    
    使用标签
    菌丝体
    

    对于仍在寻找的人,有一个单独的aid5:名称空间允许cellstyles。您可以在下例所示的表标记属性中组合2个名称空间,以利用aid:和aid5:属性。。。此外,要使用表格样式,只需“命名”表格标签,并使用该名称将标签映射到Indesign文件中的样式。命名表标记和杂项。命名标记必须手动映射(表的表格样式或其他格式的字符样式),而标记中的cellstyle、pstyle(段落样式)和cstyle(字符样式)属性,只要段落、单元格或字符样式具有完全相同的区分大小写的名称,就必须映射它们自己。如果可以在Indesign模板中使用占位符表(带有标题行和正文行),则可以放弃使用宽度。可以使用如下所示的自动关闭标记跳过任何预填充的单元格(如标题行)。最后,如果您不知道将有多少行,只需使用一行将每个重复行设置为自己的完整表。这并不理想,在我的例子中,我们使用了一个变量来填充aid:trows属性。输入数据的前端为我们计算了行数(进行了编辑,修复了错误的列数并添加了缩进)

    
    第一列标题
    第二列标题
    第1行第1列
    第一排第二列我们赢了!
    第2行第1列
    第2行第2列
    第1行第1列
    第1行第2列
    第2行第1列
    第2行第2列
    
    能否添加原始XML的示例和输出的示例?XSLT应该很简单,我添加了xml,并描述了我的一些需求。希望您能给我一些XSLT示例代码。如果我导出带有标记数据的表,我会得到一个InDesign表,而不是CALS表。但是我需要一张桌子。当我只是标记元素时,我得到一个CALS表,但没有xmlns!您发布的属性不是引用到InDesign表而不是CALS表(我不知道CALS表中的
    :aid
    )吗?没错,aid是Adobe命名空间。CALS表格没有cellstyle属性。有一个tabstyle和tgroupstyle属性,但据我所知,InDesign不支持这些属性。为什么需要CALS表,您的工作流程是什么?我需要CALS表,因为我使用Coldfusion和
    生成XML。我在使用
    :aid
    属性时出错,因此我认为ColdFusion不支持此功能。我不知道这是不是一个可以解决的问题。。。无论如何,还是要感谢xslt示例。也许我以后可以用这个。
        <!-- table with widths declared -->
        <myTableStyleName xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/" xmlns:aid5="http://ns.adobe.com/AdobeInDesign/5.0/" aid:table="table" aid:trows="3" aid:tcols="2">
            <Cell aid:table="cell" aid:ccolwidth="200" aid:theader="" aid:crows="1" aid:ccols="1" aid5:cellstyle="headerCell" aid:pstyle="headerCellP">column one header</Cell>
            <Cell aid:table="cell" aid:ccolwidth="200" aid:theader="" aid:crows="1" aid:ccols="1" aid5:cellstyle="headerCell" aid:pstyle="headerCellP">column two header</Cell>
            <Cell aid:table="cell" aid:ccolwidth="200" aid:crows="1" aid:ccols="1" aid5:cellstyle="bodyCellA" aid:pstyle="paragraphAwayGame">row 1 col 1</Cell>
            <Cell aid:table="cell" aid:ccolwidth="200" aid:crows="1" aid:ccols="1" aid5:cellstyle="bodyCellA" aid:pstyle="paragraphHomeGame">row 1 col 2 <myCharStyle>WE WON!</myCharStyle></Cell>
            <Cell aid:table="cell" aid:ccolwidth="200" aid:crows="1" aid:ccols="1" aid5:cellstyle="bodyCellA" aid:pstyle="paragraphAwayGame">row 2 col 1</Cell>
            <Cell aid:table="cell" aid:ccolwidth="200" aid:crows="1" aid:ccols="1" aid5:cellstyle="bodyCellA" aid:pstyle="paragraphHomeGame">row 2 col 2</Cell>
        </myTableStyleName>
    
        <!-- table data populating starter rows in Indesign, no widths needed -->
        <Table xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/" xmlns:aid5="http://ns.adobe.com/AdobeInDesign/5.0/" aid:table="table" aid:trows="3" aid:tcols="2">
            <Cell aid:table="cell" aid:theader="" aid:crows="1" aid:ccols="1" aid5:cellstyle="headerCell" aid:pstyle="headerCellP"/>
            <Cell aid:table="cell" aid:theader="" aid:crows="1" aid:ccols="1" aid5:cellstyle="headerCell" aid:pstyle="headerCellP"/>
            <Cell aid:table="cell" aid:crows="1" aid:ccols="1" aid5:cellstyle="bodyCellA" aid:pstyle="paragraphAwayGame">row 1 col 1</Cell>
            <Cell aid:table="cell" aid:crows="1" aid:ccols="1" aid5:cellstyle="bodyCellA" aid:pstyle="paragraphHomeGame">row 1 col 2</Cell>
            <Cell aid:table="cell" aid:crows="1" aid:ccols="1" aid5:cellstyle="bodyCellA" aid:pstyle="paragraphAwayGame">row 2 col 1</Cell>
            <Cell aid:table="cell" aid:crows="1" aid:ccols="1" aid5:cellstyle="bodyCellA" aid:pstyle="paragraphHomeGame">row 2 col 2</Cell>
        </Table>