Skip to main content
borise78101190
Participant
September 7, 2016
Question

XML-Import and constant number of lines

  • September 7, 2016
  • 2 replies
  • 286 views

Hello community,

I can't figure out a  solution for my problem.

I import some XML containing addresses with XML-rule (JS):

  function addressStyling(){

        this.name = "addressStyling";

        this.xpath = "//address";

        this.apply = function(myElement, myRuleProcessor){

            with(myElement){

                var myAttribute = myElement.xmlContent;

                myElement.xmlContent.applyCharacterStyle(app.activeDocument.characterStyles.item("bold"), true);

                insertTextAsContent('\r', XMLElementPosition.ELEMENT_END);

            }

            return false;

        }

    }

The XML looks like this and unfortunately it is not structured well.

<addresses>

     <address>

     street1&#x2029;street2&#x2029;zipcode&#x2029;place

     </address>

     <address>

     street1&#x2029;zipcode&#x2029;place

     </address>

<addresses>

My problem is, that the layout is planned for exactly 4 rows (or lines) for this address.

Is there a InDesign-way of solving this problem or is it better to use some XSL and separate the string (e.g. by &#x2029;) into 4 separate children?

Thank you for your help!

This topic has been closed for replies.

2 replies

Jongware
Community Expert
Community Expert
September 8, 2016

Does that code <2029> appear in your InDesign document, or doesn't it import?

If it does, you can add a find/change to the end of your import script and replace it with a proper hard return.

borise78101190
Participant
September 10, 2016

Hello,

I use the string &#x2029; for line breaks within InDesign. It seems it works best.

I replaced <br> within CDATA of my XML to &#x2029; in separate XSLT routine.

Loic.Aigon
Legend
September 8, 2016

If you can act on the xml generation, you could replace the &#x2029;entity to &#xA; which will be read as a carriage return as long as it's not in a leading nor a trailing location (or it might be removed during the import if remove white space option is enabled).

Otherwise you can of course choose to modify it trough XSL or scripting. I am not sure if there is a "better than the other" option. Probably a matter of "as you feel the most with".