InDesign supports special formatting attributes, which let me embed a reference to a paragraph, character, table, or cell style in an XML file. When the XML file is imported and laid out, InDesign uses the referenced style to format that element. But how to convert < and > etc. to aid namespace.
This is my input:
<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> I need such output:
<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> I need to convert:
<em> to <en aid:csytle = "italic"> <strong> to <en aid:csytle = "bold"> <strong><em> or <em><strong> to <en aid:csytle = "bold-italic"> I made my xslt 1.0 stylesheet which works with normal xml elements like <em> end <strong>. How to improve it to my input?
<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>
No comments:
Post a Comment