Skip navigation
I_just_want_an_answer
Currently Being Moderated

Is there a way for preventing the placeholder from appearing if there is not content for it?

Dec 3, 2012 12:32 PM

I am creating a structure with tags and place holders.  However, not all my entries have all the same information. For example, my first entry has a 3 line address (123 West Street, Suit 23, Lincoln NE 68521) but my second entry only has 2 line address (456 North Street, Lincoln NE 68521).  When imported into my structure, the second address reads 456 North Street, <address2>, Lincoln NE 68521. My question for you is, is there a way for preventing the placeholder from appearing if there is not content for it?

 
Replies
  • Currently Being Moderated
    Dec 3, 2012 12:46 PM   in reply to I_just_want_an_answer

    Yes, if I understand you correctly, you are looking for the  "Content Placement Options"; you can check the box for "Remove blank lines for empty fields."

     
    |
    Mark as:
  • Currently Being Moderated
    Dec 3, 2012 12:50 PM   in reply to Joel Cherney

    Does that exist for XML?

     
    |
    Mark as:
  • Currently Being Moderated
    Dec 3, 2012 1:35 PM   in reply to Peter Spier

    My eyes went directly to <address2> and I missed the (obvious) reference to tagged structure, thought it was a Data Merge.

     
    |
    Mark as:
  • Currently Being Moderated
    Dec 3, 2012 1:45 PM   in reply to Joel Cherney

    Join the club.

     

    I thought that might have been the case, which is why I asked, but I was hoping you were going to say "of course it is."

     
    |
    Mark as:
  • Currently Being Moderated
    Dec 3, 2012 2:15 PM   in reply to Peter Spier

    For XML to ignore empty fields, you'd have to use a custom XSLT stylesheet. It can be a pretty standard one, though. Google for "identity.xsl", which copies items verbatim; then add a single template to omit an empty tag, either a single one, or one from a list of candidates, or even any and all empty tags.

     
    |
    Mark as:
  • Currently Being Moderated
    Dec 4, 2012 2:27 PM   in reply to I_just_want_an_answer

    Whatever you like. It depends on what you add to "this".

     
    |
    Mark as:
  • Currently Being Moderated
    Dec 7, 2012 10:11 PM   in reply to I_just_want_an_answer

    IJWAA,

    A work-around if you don't already use XSLT (to avoid having to) is to not have placeholder text, just use empty tags in your text layout that correspond to your incoming XML structure (any unused by the incoming structure IN ORDER, will be skipped). So long as you don't mind the blank line (rather than left over placeholder copy).

     

    If you had placeholder copy in your text box (<address2> for example) look at it using the story editor window (edit > edit in story editor, or command-y/control-y) so you can see the surrounding tags... style the surrounding tags by selecting them with the cursor and applying character or paragraph styles (with text in between the tags at the time) and then delete only the placeholder text from the middle of the sandwich, leaving the tags in tact. Trying to do this without being in the story editor will not work.

     

    Also, when importing the XML, I believe you'll still need to use "merge content" and "don't import empty white space" as you have been in order to replace placeholder text in any areas you had it.

     

    For situations when you have a mixture of dynamic and static text in the same text block and you are merging data (more so when the placeholder text has been deleted as I've suggested above but the dynamic tags for the possible incoming text are still there), you can use a tag you've created (I call mine "staticText") in your layout to wrap ANY bits of text you don't want to accidentally delete when the surrounding tags get populated or not, using the merge option upon importing your XML. Just be sure never to use "staticText" as an actual tag in your structure or surrounding incoming data. The text contained within staticText tags in your layout will be ignored by incoming data, and won't accidentally get deleted when it's sandwiched between two sets of tags that are dynamically populated when merge content is the import option.

     

    In my example below I'm using brackets/carats with the tag name instead of the color coded tag icon you see in the story editor, also I've used LB here to indicate a regular line break in Indesign and SP a regular space character in indesign:

     

    [staticText>Name:<staticText][firstName>Abc<firstName][staticText>SP<staticText][lastName>Xyz<firstName][staticText>LB<staticText]

    [staticText>Address:<staticText][address1><address1][staticText>LB<staticText]

    [address2><address2][staticText>LB<staticText]

    all other tags on following lines...

     

    This should just leave a blank line for address2 when no data comes in for it. I'm assuming you have line breaks, if not, all the better.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points