2

When exporting XML from InDesign, I'd like assignments to show up as parent elements without manual intervention.

What I get now for a page that has three stories in two assignments:

<Root>
   <Story>
      <Headline>Foo</Headline>
      <Body>Bar</Body>
   </Story>
   <Story>
      <Headline>Foo2</Headline>
      <Body>Bar2</Body>
   </Story>
   <Story>
      <Headline>Foo3</Headline>
      <Body>Bar3</Body>
   </Story>
</Root>

What I'd like to get:

<Root>
   <Assignment>
      <Story>
         <Headline>Foo</Headline>
         <Body>Bar</Body>
      </Story>
      <Story>
         <Headline>Foo2</Headline>
         <Body>Bar2</Body>
      </Story>
   </Assignment>
   <Assignment>
      <Story>
         <Headline>Foo3</Headline>
         <Body>Bar3</Body>
      </Story>
   </Assignment>
</Root>

1 Answer 1

1

Use this xsl on export

<?xml version="1.0" encoding="UTF-8"?>

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

<xsl:template match="Story">
    <Assignment>
        <xsl:copy-of select="."></xsl:copy-of>
    </Assignment>
</xsl:template>

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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