11 Replies Latest reply: May 3, 2012 10:26 AM by mdean215 RSS

    Importing CALS XML tables with oasis namespace

    mdean215

      Hi all,

       

      I'm trying to import XML into InDesign and am running into problems with the tables.  The tables are Oasis CALS tables, and I have the "import CALS tables as InDesign tables" box checked at import.  But, the tables aren't rendering as InDesign tables when they're placed.  Each element is placed in its own paragraph.

       

      As a test, I removed the oasis: namespace from the table elements. When I imported the modified XML, the table rendered as an InDesign table.  Does InDesign have trouble with namespaces?  The namespace is declared and the XML parses against the DTD.

       

      It would be much easier/faster if I could get this to import correctly without having to worry about XSLT or other major changes to the XML.  Any ideas?

       

      Here's some of my XML:

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

      <!DOCTYPE book SYSTEM "book-oasis3.dtd">

      <book dtd-version="3.0" xml:lang="EN" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:oasis="http://docs.oasis-open.org/ns/oasis-exchange/table">

      <body>

      <book-part>

      <table-wrap>

      <label>Table 1 </label><caption><title>Assumed Expected Returns, Variances, and Correlation: Two-Asset Case</title></caption>

      <oasis:table frame="none"><oasis:tgroup cols="3">

      <oasis:colspec colnum="1" colname="col1" colwidth="33.34%"/>

      <oasis:colspec colnum="2" colname="col2" colwidth="33.33%"/>

      <oasis:colspec colnum="3" colname="col3" colwidth="33.33%"/>

      <oasis:thead>

      <oasis:row>

      <oasis:entry rowsep="1" valign="top" align="left" colsep="0"></oasis:entry>

      <oasis:entry valign="bottom" rowsep="1" align="center" colsep="0"><bold>Asset 1</bold><break/><bold>Large-Cap Stocks</bold></oasis:entry>

      <oasis:entry valign="bottom" rowsep="1" align="center" colsep="0"><bold>Asset 2</bold><break/><bold>Government Bonds</bold></oasis:entry></oasis:row></oasis:thead>

      <oasis:tbody>

      <oasis:row>

      <oasis:entry valign="top" align="left" colsep="0" rowsep="0">Expected return</oasis:entry>

      <oasis:entry valign="middle" align="char" char="%" colsep="0" rowsep="0">15%</oasis:entry>

      <oasis:entry valign="middle" align="char" char="%" colsep="0" rowsep="0">5%</oasis:entry></oasis:row>

      <oasis:row>

      <oasis:entry valign="top" align="left" colsep="0" rowsep="0">Variance</oasis:entry>

      <oasis:entry valign="middle" align="char" char="." colsep="0" rowsep="0">225</oasis:entry>

      <oasis:entry valign="middle" align="char" char="." colsep="0" rowsep="0">100</oasis:entry></oasis:row>

      <oasis:row>

      <oasis:entry valign="top" align="left" colsep="0" rowsep="0">Standard deviation</oasis:entry>

      <oasis:entry valign="middle" align="char" char="%" colsep="0" rowsep="0">15%</oasis:entry>

      <oasis:entry valign="middle" align="char" char="%" colsep="0" rowsep="0">10%</oasis:entry></oasis:row>

      <oasis:row>

      <oasis:entry valign="top" align="left" colsep="0" rowsep="0">Correlation</oasis:entry>

      <oasis:entry valign="middle" align="char" char="." colsep="0" rowsep="0">0.5</oasis:entry>

      <oasis:entry valign="middle" align="left" colsep="0" rowsep="0"></oasis:entry></oasis:row></oasis:tbody></oasis:tgroup></oasis:table>

      </table-wrap>

        </book-part>

      </body>

      </book>

       

       

      Thanks!

        • 1. Re: Importing CALS XML tables with oasis namespace
          John Hawkinson Community Member

          As a test, I removed the oasis: namespace from the table elements. When I imported the modified XML, the table rendered as an InDesign table.  Does InDesign have trouble with namespaces?  The namespace is declared and the XML parses against the DTD.

          Yes, it has trouble with namespaces.

          I myself have trouble with namespaces so I'm never sure what is a bug, what is some confusion on my part, and what is proper behavior. But yeah....

           

          It would be much easier/faster if I could get this to import correctly without having to worry about XSLT or other major changes to the XML.  Any ideas?

          Well, this is pretty trivial XSLT, right?

          What's the concern?

          • 2. Re: Importing CALS XML tables with oasis namespace
            mdean215 Community Member

            You're right, that was trivial XSLT (I'm only just starting to learn it).  Between what little I know about XSLT and Google, I came up with a transform to remove the namespaces from tables. 

             

            There's one more thing I need to deal with - we have some local formatting in our XML (<bold>, <italic>, etc.) that's being dropped completely.  I'm not sure how I'll deal with that because the XML tags are removed.  But, overall, the tables look pretty good on import.

            • 3. Re: Importing CALS XML tables with oasis namespace
              John Hawkinson Community Member

              There's one more thing I need to deal with - we have some local formatting in our XML (<bold>, <italic>, etc.) that's being dropped completely.  I'm not sure how I'll deal with that because the XML tags are removed.

              Have you set up XML Tag to Style mapping?

              • 4. Re: Importing CALS XML tables with oasis namespace
                mdean215 Community Member

                Yeah, I set up mapping for italic and bold tags.  The formatting appears for text that's outside tables when I import the XML, but it's still not appearing in the tables.

                • 5. Re: Importing CALS XML tables with oasis namespace
                  Gejaraja

                  As per InDesign, CALS table should be looks like below:

                   

                  <table>

                  <tgroup>

                  <thead>

                  <row>

                  <entry>...</entry>

                  <entry>...</entry>

                  </row>

                  </thead>

                  <tbody>

                  <row>

                  <entry>...</entry>

                  <entry>...</entry>

                  </row>

                  </tbody>

                  </tgroup>

                  </table>

                   

                  And InDesign will remove any sub tags inside the <entry>...</entry> tags. Hope this helps. So to achieve table handling, you need to completely use other pattern like using of InDesign's table namespaces.

                   

                  Thanks,

                   

                  Praveen

                  • 6. Re: Importing CALS XML tables with oasis namespace
                    John Hawkinson Community Member

                    I was afraid you'd say that.

                    I haven't tried to do this, but I kind of fear it might be a serious limitation of ID's XML import.

                    Or at least the CALS tables.

                     

                    I assume the tags don't show up either, in the structure pane or elsewhere?

                     

                    I guess I would try them in a non-CALS table and see if they worked, and if so, consider transforming the cals table into a regular ID table. This is nontrivial.

                     

                    It might be easier to try InDesign Tagged Text, if that works for you? But it has some of the same problems...

                    • 7. Re: Importing CALS XML tables with oasis namespace
                      John Hawkinson Community Member

                      So to achieve table handling, you need to completely use other pattern like using of InDesign's table namespaces.

                      namespaces? XML namespaces? What?

                      • 8. Re: Importing CALS XML tables with oasis namespace
                        Gejaraja Community Member

                        It's InDesign namespaces like <entry aid:table="cell" aid:crows="1" aid:ccols="1" aid:pstyle="T col hd" aid:theader="" colname="col1" align="left">.

                        • 9. Re: Importing CALS XML tables with oasis namespace
                          mdean215 Community Member

                          No, the tags don't appear in the structure pane or in the story editor.

                           

                          I can see if I can get the tables in another format, but I think I might be stuck with CALS.  Also, I've done some scripting and I'm thinking I could turn off the "import CALS tables as InDesign tables" option and then build the tables from the XML tagging with a script.  But, that seems like a lot of work considering the tables are almost perfect on import except for the local formatting.

                           

                          Thanks for your help!

                          • 10. Re: Importing CALS XML tables with oasis namespace
                            John Hawkinson Community Member

                            OK, Gejaraja, I think I see what you're saying:

                            It's InDesign namespaces like <entry aid:table="cell" aid:crows="1" aid:ccols="1" aid:pstyle="T col hd" aid:theader="" colname="col1" align="left">.

                            You don't mean to use namespaces, you mean to use the InDesign attributes (which happen to fall in the aid: and aid5: namespaces) of the entry tag.

                             

                            I'm not sure that works in CALS tables, but it's sure worth a try. mdean, does specifying <entry aid:cstyle="xxx"> where xxx is a character style for boldface or italic work? If so, then it's again an easy XSL transformation, asusming that an entire cell is formatted the same.

                            • 11. Re: Importing CALS XML tables with oasis namespace
                              mdean215 Community Member

                              I finally had a chance to take another look at this.  Unfortunately, it looks like the InDesign attirbutes don't come through in the CALS table.  I add aid:cstyle="Italic" to several elements. It applies that character style to text when it's used outside the table but doesn't seem to work on text within the table.