7 Replies Latest reply on May 7, 2012 7:05 AM by BobLevine

    Can a DTD map custom styles to standard HTML tags?

    geekbelief

      Hi,

       

      Every week the publishing house I work for has to manually copy the entire content of a weekly magazine on an article-by-article basis into an online database, the web version of the magazine. This means copying the styled InDesign content and inserting it into the database as plain text, re-finding all those italics (and any other styling) and putting it all back manually.

       

      I already know that I can create tags with all the basic HTML styles needed in the 'Tags' palette in InDesign, and then export that.

       

      tags.jpg

       

      The trouble is that when I re-import the XML file, I have to laboriously map the custom house-styles (there are many of them and they're boiler-plate, i.e. consistent, across all the magazine's InDesign styles) to the imported HTML styles.

       

      tags2.jpg

       

      So here's my question:

       

      Am I wrong to believe that it's possible to create a DTD that would import not only the HTML tags but their relationship to the existing, custom-named InDesign tags that are common to all the magazine's documents?

       

      As an InDesign wish-feature, what's missing from the 'Tags' corner-menu is 'Export DTD' - if that was available, I could map the whole relationship between Indesign Styles/HTML styles just one time and later import the DTD on other articles; which would tell the Structure View how to convert our custom house-styles (both Paragraph Styles and Character Styles) into HTML tags and cut this time-consuming task in half.

       

      Thanks!

      __________________________________

       

      EDIT: I perhaps should have mentioned that obviously the final stage after this 'dream conversion' is to export the XML from the Structure View. Then I can just open the saved XML file and paste it into the CMS with formatting intact.

       

      tags5.jpg

       

      Added extra explanation of the workflow.

        • 1. Re: Can a DTD map custom styles to standard HTML tags?
          [Jongware] Most Valuable Participant

          A DTD does not 'map' or 're-map' tags, it defines them (and their allowed attributes and content as well). The term you are looking for is "XSLT".

           

          A custom XSLT Stylesheet can re-map tags to other tags; in this case, I think it would be possible to re-map them to names matching your paragraph styles, so you can use the "Map by Name" button.

           

          Writing an XSLT Stylesheet is ... well, for me it's easy. (Uh. Grasping for words. If you are familiar with programming in general, well, it's nothing like programming in general. That seems to describe it pretty good.) After you created an XSLT stylesheet, all it takes is selecting it on importing the XML.

           

          Here is a small example to get you started with the general idea. My input contains 'article' tags, with 'atl' indicating the article title, 'au' for authors, and 'affil' for their affiliations. These I want to map to "Title", "Author", and "Address" paragraph styles, so I have my XSLT change the tags for these only and then use Map Tags To Styles.

           

          <?xml version="1.0" encoding="utf-8" ?>
          <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
          <xsl:template match="atl">
          <Title><xsl:apply-templates /></Title>
          </xsl:template>
          <xsl:template match="au">
          <Author><xsl:apply-templates /></Author>
          </xsl:template>
          <xsl:template match="affil">
          <Address><xsl:apply-templates /></Address>
          </xsl:template>
          <xsl:template match="@* | node()"> 
          <xsl:copy> 
            <xsl:apply-templates select="@* | node()" /> 
          </xsl:copy> 
          </xsl:template> 
          </xsl:stylesheet>
          
          1 person found this helpful
          • 2. Re: Can a DTD map custom styles to standard HTML tags?
            geekbelief Level 1

            Thanks for this. It's good to know at least that I was barking up the wrong tree.

             

            Googling XSLT and InDesign, it seems that such a stylesheet, if I were to create it, possibly couldn't handle spaces in the original InDesign style-names..? If anyone knows that for a fact, I'd be glad to be aware of it before starting down a long path to a roadblock.

             

            Jongware, I've been looking at your code (thanks for that) - though I'm not bad with LAMP and CSS, XML in general is a new area for me, obviously. But I'm guessing that if I wanted to change the InDesign style 'Subheader' into 'h2', that snippet of the XSLT would be like this...?

             

            <xsl:template match="Subheader">

            <h2><xsl:apply-templates /></h2>

            </xsl:template>

             

            I don't expect anyone to write this for me, but any hints or links to tutes that I haven't yet found would be appreciated!

            • 3. Re: Can a DTD map custom styles to standard HTML tags?
              [Jongware] Most Valuable Participant

              geekbelief wrote:

               

              Googling XSLT and InDesign, it seems that such a stylesheet, if I were to create it, possibly couldn't handle spaces in the original InDesign style-names..? If anyone knows that for a fact, I'd be glad to be aware of it before starting down a long path to a roadblock.

               

              That's a good question. Let's find out together, shall we. I just created a text frame with Lorem Ipsum text, and created "a style" (with space) and "bstyle" (without). Now ... Map Style to Tag doesn't work, presumably because the tags don't exist and I assumed this would *create* them. And if you create one, ID complains "tags cannot contain tabs or spaces". (So can you have a Tab in your paragraph style name then? Gosh.)

               

              ... Forcing in a Non-breaking Space (#160) also doesn't work, this time ID simply says "A tag name cannot contain the character ' '."

               

              I think that's one you have to do manually.

               

               

              geekbelief wrote:

               

              I'm guessing that if I wanted to change the InDesign style 'Subheader' into 'h2', that snippet of the XSLT would be like this...?

               

              <xsl:template match="Subheader">

              <h2><xsl:apply-templates /></h2>

              </xsl:template>

               

              Yeah, that's the correct syntax. But you cannot use an XSLT for mapping InDesign styles to tags. The process as I described works when importing your XML into InDesign, and changes the tags in the XML file to match InDesign styles. That's the other way around.

               

              I don't expect anyone to write this for me, but any hints or links to tutes that I haven't yet found would be appreciated!

               

              For a simple one-to-one translation of tag names, you can use this all the way. You only need any other XSL command if you want to do more than simple translation, such as filtering, moving, combining, or separating tags or their contents.

               

              There are lots of good tutes on the 'web for XSLT, although it seems interest has diminished lately. Half a decade ago XSLT was "hot"; nowadays the iPad is. Is there any news on improvements for ID's native XSLT support in CS6? I dare bet there are none at all -- it's already been deemed "yesterday's technology" by Adobe's Dev Team, just as Flash was discarded per CS5.5. I'm sure next year DPS will follow; and the year after that EPubs will be gone for good as well, replaced by holograms, transmitted live from your local library.

              • 4. Re: Can a DTD map custom styles to standard HTML tags?
                geekbelief Level 1

                Well, thanks again, Jongware. I was barking up a second wrong tree, it seems, in thinking that I could map InDesign styles to Tags with XSLT (rather than the other way around) - disappointing, but it's better to know now.

                 

                I don't know if ExtendScript can provide an answer, since I only began studying it this week. However  in the past I have occasionally spent more time on time-saving solutions than I was destined to save by their implementation! I think I'll need to give myself a 'time budget' on automating this process and then just accept that it all has to be done manually if I can't find the solution within that time-limit.

                 

                I'm sorry (and amazed) to hear that InDesign is so laggard in providing the kind of functionality that I'm seeking, as this is surely the 'transitional' age of print>web. Perhaps that's exactly the reason why - though since Adobe has such a wide grip on the informational gamut (print, web etc), it seems self-defeating not to help us out a little more in this respect.

                 

                But then I too know that it's hard to persuade The Boss to expend money - otherwise I could just get this problem scripted with a quick outsource!

                 

                Anyway, I'll look into it a while longer.

                • 5. Re: Can a DTD map custom styles to standard HTML tags?
                  BobLevine MVP & Adobe Community Professional

                  You are apparently trying to squeeze a square peg into a round hole.

                   

                   

                   

                  The map styles to tags feature in paragraph styles which was added in CS5.5 is for HTML tags. Could you not simply export to HTML with proper tags and get your system to work with that?

                   

                   

                   

                  Bob

                  • 6. Re: Can a DTD map custom styles to standard HTML tags?
                    geekbelief Level 1

                    Hi Bob - Sadly no; we are forced to work with IDCS3, due to a proprietary plug-in. We have later InDesign versions available, but they can't be used for this task.

                    • 7. Re: Can a DTD map custom styles to standard HTML tags?
                      BobLevine MVP & Adobe Community Professional

                      That is a shame. At some point you’re going to need to explore other options anyway.

                       

                       

                       

                      Bob