0

I have to export a lot of InDesign documents to HTML. I need to have total control over exported tags, attributes etc., so I've decided to use XML features (HTML export is just too "weak" for this task). After mapping the styles, everything looks quite good. But two major problems appear:

  1. Some of the elements (like paragraphs) have to be wrapped in tags like DIV. It can be done manually in structure panel, but is there a way to do it automatically? It would save me a lot of time since the documents are quite long. As far as I see, only character styles are automatically nested.
  2. Some of my tags have to have attributes. Is there any way to tell InDesign to set them automatically? And unfortunately I'm not talking only about "class" attribute.
1

You can use XSLT on XML export.

Save this as an XSL file and pick it up on the XML export process…

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    exclude-result-prefixes="xs"
    version="1.0">
    <xsl:output method="xml" encoding="UTF-8" indent="yes"/>

    <xsl:template match="/">
        <xsl:apply-templates/>
    </xsl:template>

    <xsl:template match="@*|node()">
        <xsl:copy>
            <xsl:apply-templates select="@*|node()"/>
        </xsl:copy>
    </xsl:template>


    <xsl:template match="p">
        <div>
            <xsl:copy-of select="."/>
        </div>
    </xsl:template>

    <xsl:template match="attributes">
        <xsl:copy>
            <xsl:attribute name="toto">tutu</xsl:attribute>
            <xsl:apply-templates select="@*|node()"/>
        </xsl:copy>
    </xsl:template>
</xsl:stylesheet>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.