Search code examples
adobeadobe-indesign

Apply bold italic character style to tag when importing xml to adobe indesign


Is it possible to apply a bold italic character style to a tag in adobe indesign. Currently you can create a character style e.g. 'strong' and map this style to a tag, so when you import an xml, the 'strong' character style will apply to any 'strong' tags.

However, if you were to create a new character style e.g. bold italic, how could you apply it to a tag? At the moment, if you were to import the following

<strong><em>I like cake!</em></strong>

and you had character styles defined for strong and em, only the em character style will be applied as the xml tree node looks like:

enter image description here

Is it possible to apply a bold italic character style to <strong><em> so it doesnt come out in just italics?


Solution

  • The following will give you an "emstrong" tag for em nested inside strong or vice versa.

    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
        version="1.0">
    
        <xsl:template match="@*|node()">
            <xsl:copy>
                <xsl:apply-templates select="@*|node()"/>        
            </xsl:copy>
        </xsl:template>
    
        <xsl:template match="em[../../strong]|strong[../../em]">
            <xsl:element name="emstrong">
                <xsl:apply-templates/>
            </xsl:element>
        </xsl:template>
    
    </xsl:stylesheet>