• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Script or XSLT to remove line break between XML elements

New Here ,
Oct 23, 2020 Oct 23, 2020

Copy link to clipboard

Copied

I have some XML in this format:


<ROOT><DOCUMENT>

<CHAPTER>Chapter One</CHAPTER>
<CONTENT>This is what happened in Chapter 1.</CONTENT>
<CHAPTER>Chapter Two</CHAPTER>
<CONTENT>This is what happened in Chapter 2.</CONTENT>
</DOCUMENT></ROOT>

 

I have a pre-tagged template where the <CHAPTER> tag maps to a paragraph style with Keep Options, start paragraph=Next page (i.e., every new chapter should start on a new page). The <CONTENT> tag maps to a basic paragraph style, and <ROOT> and <DOCUMENT> are not mapped.

 

Notice there is a line break in the XML after <DOCUMENT>. After importing, the result is that page 1 appears blank (because of the line break) and Chapter One starts on page 2. If I go into the story editor and remove the line break so it looks like <DOCUMENT><CHAPTER>, it fixes the display so Chapter One starts on page 1.

 

Is there a way for me to automate the removal of the line break, either with XSLT or a script in InDesign? Unfortunately we can't change the original XML output, and I'm trying to avoid any manual fixes.

TOPICS
Print , Scripting

Views

2.1K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 25, 2020 Oct 25, 2020

Copy link to clipboard

Copied

Hi,

 

Are you able to share the template?

 

Regards

 

Malcolm

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 26, 2020 Oct 26, 2020

Copy link to clipboard

Copied

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Oct 26, 2020 Oct 26, 2020

Copy link to clipboard

Copied

Edit: Error

Viele Grüße
Mario

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 28, 2020 Oct 28, 2020

Copy link to clipboard

Copied

HI,

 

Many thanks for sharing the link, I have been able to replicate and will see if I can work around the issue, but I think it might be worth logging a bug against InDesign as that is not how I would expect and XML import to behave with a return that is outside of the content that it should be placing.

 

log the issue here - https://www.adobe.com/products/wishform.html

 

Regards

 

Malcolm

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 10, 2020 Dec 10, 2020

Copy link to clipboard

Copied

LATEST

We've solved this issue:

 

1. In Indesign, created a new tag, TOC_CHAPTER1.

 

2. Created a new paragraph style, TOC_CHAPTER1. This new style is exactly like TOC_CHAPTER except start paragraph=Anywhere.

 

3. Mapped the tag to the paragraph style.

 

3. Created an .xsl file to change just the first instance of TOC_CHAPTER to TOC_CHAPTER1:

 

<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output indent="no"/>

<xsl:template match="DOCUMENT/TOC_CHAPTER[1]">
<TOC_CHAPTER1><xsl:apply-templates/></TOC_CHAPTER1>
</xsl:template>

</xsl:stylesheet>

 

4. On importing the XML, selected Apply XSLT and chose the .xsl file.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines