2 Replies Latest reply on Dec 27, 2013 12:54 PM by elhoyos

    How to apply multiple styles for nested tags in XML?

    elhoyos

      Say you import this XML into InDesign:

       

      <Root>
        <strong>
          <em>Bolded and Italicized</em>
        </strong>
      </Root>
      

       

      And you have two character styles, bold and italics, to map to strong and em tags respectively.

       

      You will see that the text appears italicized not bolded and italicized as expected. Generally, only the innermost tag will get the style and will overwrite its parent styles.

       

      Notice the XML is generated dynamically and tags order is not enforced. Also, there's an additional underline tag that can be nested with these two.

       

      So far I have tried to use GREP styles (with paragraph styles), but these do not have effect in the XML tags.

       

      Other possible options not tried yet:

       

      • Create new tags for every formatting combination. Not what I really want because I could en up with a lot of tags each one with a corresponding styles.
      • Create InDesign XML rules to apply character styles automatically based on the tags
      • Use character styles in the XML with the aid namespace referencing InDesign styles. Will this really work?

       

      What do you suggest to go for? See any other option?

       

      Thank you in advance.

       

      Juan

        • 1. Re: How to apply multiple styles for nested tags in XML?
          Joel Cherney Adobe Community Professional & MVP

          I'd say that you should create tags not for appearances, but for semantic content. Specifying formatting styles in your XML betrays your lack of familiarity with the format, because the last thing you'd want to do would be to use HTML markup in the middle of your XML. If you have content that's supposed to be both bolface and oblique - say, a warning - then it's marked up as

           

          <warning>Never refer directly to formatting in your XML markup, only to content types!</warning>
          

           

          If I had a document that was written in the style you suggest - one with lots of overlapping local formatting - I'd look at developing a better style guide that told the writers that doing so would be bad form. Because, you know, many of the writers I deal with are addicted to forms of emphasis that do nothing useful whatsover for their readership - they only serve to overemphasize the authorial voice of the writers.

           

          Maybe you could tell us why you need these overlapping forms of styling, and we could suggest other InDesign formatting tools (like line styles or nested styles) that would help you get the appearance you want without crowding styling markup into your XML - where, strictly speaking, it doesn't really belong.

          1 person found this helpful
          • 2. Re: How to apply multiple styles for nested tags in XML?
            elhoyos Level 1

            You're totally right. Formatting styles should be separated from the content itself.

             

            Our writers use an external CMS to do their stuff and they're allowed to use bold, italics and underline at their whishes. This CMS then generates an XML as resembled in the original post.

             

            As per your suggestion, I will checkout with them about their style guide and see if we can adjust it and provide semantic tags instead.