提问人:Daniel Pinho 提问时间:11/13/2023 更新时间:11/15/2023 访问量:39
使用 XSLT for Adobe Indesign 对 XML 子节点进行分组
Grouping XML child nodes with XSLT for Adobe Indesign
问:
尝试使用 XSLT 按类别分组,但我是一名编程技能非常令人沮丧的平面设计师。 所需的输出应省略节点“Category” 谁能帮我解决这个问题?我真的很感激任何建议。
提前致谢。
输入
<Root>
<row>
<Cat>Cocktails</Cat>
<Title>Virgin Berry Mojito</Title>
<Description>Schweppes Russian Wild Berry, Beerenmix, Limette, Minze, Rohrzucker</Description>
<Price>7,90</Price>
</row>
<row>
<Cat>Cocktails</Cat>
<Title>Sportsman</Title>
<Description>Ananas, Orange, Zitrone, Grenadine</Description>
<Price>7,90</Price>
</row>
<row>
<Cat>Aperitifs</Cat>
<Title>Lillet Wild Berry</Title>
<Description>Lillet Blanc, Schweppes Russian Wild Berry</Description>
<Price>7,90</Price>
</row>
<row>
<Cat>Aperitifs</Cat>
<Title>Aperol Spritz</Title>
<Description>Prosecco, Aperol, Sodawasser</Description>
<Price>7,90</Price>
</row>
</Root>
所需输出
<Root>
<row>
<Cat>Cocktails</Cat>
<Title>Virgin Berry Mojito</Title>
<Description>Schweppes Russian Wild Berry, Beerenmix, Limette, Minze, Rohrzucker</Description>
<Price>7,90</Price>
</row>
<row>
<Title>Sportsman</Title>
<Description>Ananas, Orange, Zitrone, Grenadine</Description>
<Price>7,90</Price>
</row>
<row>
<Cat>Aperitifs</Cat>
<Title>Lillet Wild Berry</Title>
<Description>Lillet Blanc, Schweppes Russian Wild Berry</Description>
<Price>7,90</Price>
</row>
<row>
<Title>Aperol Spritz</Title>
<Description>Prosecco, Aperol, Sodawasser</Description>
<Price>7,90</Price>
</row>
</Root>
答:
0赞
Michael Kay
11/13/2023
#1
您需要一个标识模板,该模板可以原封不动地复制所有内容:在 XSLT 3.0 中,这是
<xsl:mode on-no-match="shallow-copy"/>
在早期版本中,它是
<xsl:template match="*">
<xsl:copy><xsl:apply-templates/></xsl:copy>
</xsl:template>
然后是一条规则,如果 Cat 元素与其前身相同,则删除该元素:
<xsl:template match="Cat[.=../preceding-sibling::row[1]/Cat]"/>
评论