xml import - whitespace and linebreaks

Ask a Question related to Adobe Indesign Windows, Design and Development.

  1. #1

    Default xml import - whitespace and linebreaks

    I am trying to import XML files into InDesign and use tag-to-style mapping. The mapping works well, but the hangup is with whitespace and linebreaks. Basically InDesign seems to pick up, verbatim, whatever whitespace and linebreaks are found in the XML files. (Which are meaningless to XML and HTML. So why does InDesign treat an XML file as if it were a formatted document?)

    For example we have the following:
    <instructions> (container tag - not mapped in InDesign)
    <instruction> (mapped to the InDesign style "Numbered List")

    InDesign gives <instructions> a line feed/paragraph mark, even though this tag is not mapped and should be ignored. That seems to be because it is on a separate line in the XML file.

    So, the INDD files are full of empty paragraph marks representing unmapped container tags.

    I have experimented with going into the XML file beforehand and removing all paragraph marks. Then, InDesign will import the entire file as one long paragraph - no paragraph marks at all - even though many of the tags are mapped to various paragraph styles. (Of course, only the first paragraph style takes effect, since the rest of the file runs in to that paragraph.)

    I have tried changing the xml:space attribute in our DTD from preserve to default, with no effect. Do I need to send the files through a transform to strip whitespace first? Any other ideas?

    I appreciate any help; we are serious about developing an XML-to-PDF solution for Print, and InDesign seemed to offer hope, but this has effectively stymied our efforts. The files require so much cleanup that it doesn't save any time over styling Plain Text from scratch.

    Thanks,
    Theano
    S&T Consulting/Microsoft HRXUA Production Lead
    theano_mouratides@adobeforums.com Guest

  2. Similar Questions and Discussions

    1. How to create linebreaks in cftextarea, format = flash
      I'm using <cfform format="flash">, and I can't figure out how to create a linebreak in the cftextarea form control. For example, in the following...
    2. cannot get rid of whitespace
      The following code writes a file to the server, however when I check the file that it writes it starts the written code on line 2 and leaves a...
    3. cfformitem linebreaks
      This is frustrating. I have the following code: <cfformgroup type='page' label='Terms of Use'> <cfformitem type='text'> TERMS OF USE and...
    4. Linebreaks and fread
      Hello I'm writing a PHP-script to send mail with attachments. It works fine except for one thing: it removes the linebreaks from the text. The...
    5. linebreaks in VBScript variables
      I'm trying to format an email message. The message has line breaks in it. How do I do this in VBScript? Is there anything like a heredoc? $msg...
  3. #2

    Default Re: xml import - whitespace and linebreaks

    theano,

    There is a processing instruction that you can put in your xml file that will prevent white space preservation. Here's the information I recived from Adobe on this:

    In InDesign CS there is a processing instruction that gives the users
    two different methods for handling whitespace, i.e. tabs and newlines.
    This is controlled by the "whitespace-handling" processing instruction.
    The first methods, the default, is to interpret newlines and tabs paragrpah
    breaks and tabs in the content. In other words, don't ignore newlines
    and tabs. This is the same behavior that InDesign 2.0 used and the default
    in InDesign CS.





    To set whitespace-handling to the default described above, use the following
    processing instruction:





    <?whitespace-handling use-characters?>






    The second method treats newlines and tabs in the content as whitespace,
    they are completely ignored. To get "tabs" and "paragrph breaks" in the
    content you have to use the <br/> and <tab/> tags. These live in the XML
    namespace: "http://ns.adobe.com/AdobeInDesign/CS/".





    To set whitespacep-handling to this method, use the following processing
    instruction:





    <?whitespace-handling use-tags?>





    To include a paragraph break in the content use the empty tag <br/>, to
    include a tab in the content use the empty tag <tab/> as in the following
    example:





    <?whitespace-handling use-tags?> <content xmlns:aid="http://ns.adobe.com/AdobeInDesign/CS/">
    This is some content, here is a paragraph break<aid:br/> Perhaps
    you want a tab here<aid:tab/>So that this is indented to the next tabstop.
    </content>




    I hope this helps,

    Phil Redman
    pjredman@adobeforums.com Guest

  4. #3

    Default Re: xml import - whitespace and linebreaks

    Phil,

    I just wanted to thank you for this. So far all I have succeeded in doing with it is breaking everything completely, but at least it's something new to chew on. I haven't worked with namespaces much, so I'll have to go back to my classwork and try to figure it all out from scratch. I'll let you know how it goes.

    Thanks again for the help,
    Theano
    theano_mouratides@adobeforums.com Guest

  5. #4

    Default Re: xml import - whitespace and linebreaks

    Along those same thoughts (I think), I'm trying to pull in XML content from another source. I find that FM does not recognize tabs or sometimes carriage returns.

    Can this be corrected by writing some read-write rules in the application that will account for the handling of these conditions in the source content? If so, what are they?

    Shaun
    Patrick O.(Shaun) Young
    Patrick_O_Young@adobeforums.com Guest

  6. #5

    Default Re: xml import - whitespace and linebreaks

    The problem with the Adobe namespace is that we validate against a DTD, and so I can't use namespaces. Any other ideas?

    Thanks,
    Theano
    theano_mouratides@adobeforums.com Guest

  7. #6

    Default Re: xml import - whitespace and linebreaks

    Theano,

    The solution I sent from Adobe uses a processing instruction--not a namespace. This should present no problem for validation.

    Phil
    pjredman@adobeforums.com Guest

  8. #7

    Default Re: xml import - whitespace and linebreaks

    Hi Phil,

    I've gotten nowhere; obviously I don't understand what I'm doing, so I'm wondering if you would be able to help me.

    I finally dropped trying to make this work with our XML files and DTD, and just created a small XML file using the whitespace-handling PI you gave me, as follows (pretty much just copied and pasted your example):

    <?xml version="1.0" encoding="utf-8" ?>
    <?whitespace-handling use-tags?>
    <content xmlns:aid="http://ns.adobe.com/AdobeInDesign/CS/">

    This is some content, here is a paragraph break<aid:br/>Perhaps you

    want a tab here<aid:tab/>So that this is indented to the next tabstop.</content>

    After "Perhaps you," I typed several returns, and after "next," I typed a tab.

    Then I imported the file into InDesign and mapped the "content" tag to a style I created, and dragged it into a text box.

    The tag-to-style mapping worked, but the file came in same as it always has. The <aid:br/> and <aid:tab/> tags were ignored, and the linebreaks and tab that I had typed showed up in the content.

    Then I tried it the other way, using <?whitespace-handling use-characters?>; the results were identical.

    Can you explain to me in words of less than one syllable, how to do this?

    Thanks very much for your help,
    Theano
    theano_mouratides@adobeforums.com Guest

  9. #8

    Default Re: xml import - whitespace and linebreaks

    Theano,

    The processing instruction works for me as indicated by Adobe but the namespaced tab and break characters don't. They show up as XML elements in the structure view but have no other effect on the file.

    Sorry I can't be more helpful but I haven't spent much time with this myself.

    Phil Redman
    pjredman@adobeforums.com Guest

  10. #9

    Default Re: xml import - whitespace and linebreaks

    Since you are in the midst of setting up an xml tag map system, may I ask you a couple questions?

    1. How difficult was it to set up your the xml tag map system?

    2. Does one need InDesign CS to do an xml tag map, or can you use InDesign 2.03 to do an xml tag map?

    I'm looking at updating to CS and attempting the XML mapping, but have no idea how complicated it is. The closest thing I've done is setting up a style pallette that accomplished the same end, via Pagemaker (which was a huge time saver for our publication).

    Thanks in advance for your insights and response.

    Robert Frank
    Washington State University
    robert_frank@adobeforums.com Guest

  11. #10

    Default Re: xml import - whitespace and linebreaks

    Robert,

    InDesign 2.0.2 supports mapping of paragraph styles to/from XML tags but has no support for character style mapping (although some folks have attempted this with scripting). InDesign CS adds support for character style mapping.

    Setting up the mapping is a simple matter of selected the appropriate mapped elements in the Tags palette menu. These mappings can be saved and loaded from other documents. Also note that the tags themselves can be saved and loaded in a similar manner.

    Phil Redman
    pjredman@adobeforums.com Guest

  12. #11

    Default Re: xml import - whitespace and linebreaks

    Teano,

    The url for namespace should be
    "http://ns.adobe.com/AdobeInDesign/3.0/"

    NOT "http://ns.adobe.com/AdobeInDesign/CS/"

    in this way namespaced "tab" and "break" work well.

    Alexey Gays
    Alexey_Gays@adobeforums.com Guest

  13. #12

    Default Re: xml import - whitespace and linebreaks

    [email]Alexey_Gays@adobeforums.com[/email] wrote in message news:<3bb48604.9@webx.la2eafNXanI>...
    > "http://ns.adobe.com/AdobeInDesign/3.0/"
    Hi, are there any other declarations in the namespace? In other words,
    ist it possible to set a link to a url in an XML-file, that will be
    "translated" to a link to a url in InDesign?
    Detlef Guest

  14. #13

    Default Re: xml import - whitespace and linebreaks

    Alexey, pjerdman,

    I`ve got the same problems with whitespaces, linebreaks and tables I tried to solve them by inserting the aid:tags via xslt. But where can I find a complete overview of the Adobe-namespaces? I couldn't find them on adobe.com.

    Thanks
    Chris
    Chris_Ullrich@adobeforums.com Guest

  15. #14

    Default Re: xml import - whitespace and linebreaks

    To all contributors,

    Finally! Thank you all. This thread solved a couple of the problems I've been having with importing XML.

    Now I'm curious... Is there more to this "http://ns.adobe.com/AdobeInDesign/3.0/" than just <br/> and <tab/>? Could there also be instruction for page breaks and column breaks?

    Does anybody knows where we can find any documentation on this?

    Also, after I've imported the external XML-file, made some changes (breaks and tabs) in ID and export the XML again. ID doesn't convert the breaks and tabs to tags. When I import it again it still looks correct, but if I make changes in an external text-editor the breaks and tabs that was inserted in ID vanishes again.
    Is there a special control-character that InDesign uses when exporting that my text-editor can not handle? If so, does anybody know which?

    Thanks
    Måns
    Måns_Gustafsson@adobeforums.com Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139