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

Report Card using XML in InDesign

Enthusiast ,
Feb 27, 2024 Feb 27, 2024

Copy link to clipboard

Copied

Hi,

I am preparing a report card for my client. Its their requirement that I do that using XML.

I have created a schema.xml file and students.xml file. The structure for both the files are same. Only difference is that students.xml file is loaded with data and schema.xml file is empty.

 

I created Indesign file and imported schema.xml file. Then I mapped the structure with the appropriate text frames. None of the textframes are linked. Then I mapped the styles with tags. So far all is fine.

 

Now I import the actual students.xml file. The problem starts here. First page popluates with the data perfectly but its not adding more pages. As per the students.xml there are 14 students data in it.

Data gets loaded in the structure pane but all that Indesign shows is Page 1 only.

 

I have attached sample idml file and both the schema file. What am I doing wrong ?

Plz help. 

 

Thanks

TOPICS
How to

Views

430

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

correct answers 1 Correct answer

Advocate , Feb 29, 2024 Feb 29, 2024

Hello,
InDesign and XML have not been best friends for years.
Take a look at the problem of whitespace. You can solve it with a script or you can use XSL. This ensures that the data comes in cleanly.
Here is an example of an XSL:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"
  xmlns:aid5="http://ns.adobe.com/AdobeInDesign/5.0/">
  <xsl:output method="xml" version="1.0" encod
...

Votes

Translate

Translate
Enthusiast ,
Feb 29, 2024 Feb 29, 2024

Copy link to clipboard

Copied

Any suggestions ? Anyone?

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 ,
Feb 29, 2024 Feb 29, 2024

Copy link to clipboard

Copied

Hello,
InDesign and XML have not been best friends for years.
Take a look at the problem of whitespace. You can solve it with a script or you can use XSL. This ensures that the data comes in cleanly.
Here is an example of an XSL:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"
  xmlns:aid5="http://ns.adobe.com/AdobeInDesign/5.0/">
  <xsl:output method="xml" version="1.0" encoding="UTF-8" standalone="no" media-type="test/>xml"/>
  <xsl:template match="/">
    <root>
      <xsl:apply-templates />
    </root>
  </xsl:template>
  <xsl:key name="groupKey" match="//students/record" use="student-name" />

  <xsl:template match="/students">
    <students>
      <xsl:for-each select="//students/record[count(. | key('groupKey', student-name)[1]) = 1]">
        <record>
          <student-name>
            <xsl:apply-templates select="student-name" />
            <xsl:text>&#13;</xsl:text>
          </student-name>
          <fathers-name>
            <xsl:apply-templates select="fathers-name" />
            <xsl:text>&#13;</xsl:text>
          </fathers-name>
          <class>
            <xsl:apply-templates select="class" />
            <xsl:text>&#13;</xsl:text>
          </class>
          <jan>
            <xsl:apply-templates select="jan" />
            <xsl:text>&#13;</xsl:text>
          </jan>
          <feb>
            <xsl:apply-templates select="feb" />
            <xsl:text>&#13;</xsl:text>
          </feb>
          <mar>
            <xsl:apply-templates select="mar" />
            <xsl:text>&#13;</xsl:text>
          </mar>
          <apr>
            <xsl:apply-templates select="apr" />
            <xsl:text>&#13;</xsl:text>
          </apr>
          <may>
            <xsl:apply-templates select="may" />
            <xsl:text>&#13;</xsl:text>
          </may>
          <jun>
            <xsl:apply-templates select="jun" />
            <xsl:text>&#13;</xsl:text>
          </jun>
          <jul>
            <xsl:apply-templates select="jul" />
            <xsl:text>&#13;</xsl:text>
          </jul>
          <aug>
            <xsl:apply-templates select="aug" />
            <xsl:text>&#13;</xsl:text>
          </aug>
          <sep>
            <xsl:apply-templates select="sep" />
            <xsl:text>&#13;</xsl:text>
          </sep>
          <oct>
            <xsl:apply-templates select="oct" />
            <xsl:text>&#13;</xsl:text>
          </oct>
          <nov>
            <xsl:apply-templates select="nov" />
            <xsl:text>&#13;</xsl:text>
          </nov>
          <dec>
            <xsl:apply-templates select="dec" />
            <xsl:choose>
              <xsl:when test="not(position()=last())">
                <xsl:text>&#13;</xsl:text>
              </xsl:when>
            </xsl:choose>
          </dec>
        </record>
      </xsl:for-each>
    </students>
  </xsl:template>
</xsl:stylesheet>


But first you have to adapt your InDesign. The text frames must be concatenated, otherwise everything is in the first text frame.

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
Enthusiast ,
Feb 29, 2024 Feb 29, 2024

Copy link to clipboard

Copied

@Mario Fritsche Thanks for the reply.

Where do I apply this XSL and how ?

By concatenation you mean threading ?

Suppose I 100 records in XML, do I have to add 100 pages first and link all of them ? I am trying this XML thing since 2 weeks and its all going above my head. 

Thanks for your help. I have to learn his XML Indesign thing. Maybe its difficult for me now but eventually it will become easier.

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 ,
Feb 29, 2024 Feb 29, 2024

Copy link to clipboard

Copied

Yes, threading.

Download the XSLT file here and your example InDesign file: https://www.dropbox.com/scl/fo/jyvel0enc3caqh7bx4g8v/h?rlkey=i8u487ee1n1shxe4utrjlottd&dl=0
Then import the XML (select the option "Show XML import options" in the window). Then select the downloaded XSLT in the Apply SXLT dialog.

https://helpx.adobe.com/indesign/using/importing-xml.html

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
Enthusiast ,
Feb 29, 2024 Feb 29, 2024

Copy link to clipboard

Copied

@Mario Fritsche First of all I would like to thank you so much for the help. 

I think so that it has started to come in a shape but I still have doubts.

 

Here is the process which I followed

In the Master Page
-----------------
I threaded all the text frames and made them primary.
(Can it be done without making it primary ?)

I then loaded the student.xml file with following option:
----------------------------------------------------------
Apply XLST : pointing to the file supplied by you.
All options unchecked

Image attached (structurepanel.jpg)

Deleted all the records except the first one. Image attached (afterdelete.jpg)

Mapped Tags to Style.

Then I went to Page 1
----------------------

Loaded the XML again with following option:

Apply XLST : pointing to the file supplied by you.
Mode : Merge Content
Create Linked - Checked
Clone repeating text elements - Checked
Do not import contents of whitespace-only elements
Rest options were unchecked

Dragged and dropped the students element again on the Names text frame.

It showed all the records but for some reason it did not show the graph.

I am attaching the idml file. I am not sure whether the process which I have done above is correct or not.

 

Thank you so much once again.

 

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 ,
Feb 29, 2024 Feb 29, 2024

Copy link to clipboard

Copied

It doesn't work the way you do it. No matter whether you are on the sample page or on page 1.... Just load the XML once and don't throw anything out. Does the video help?

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
Enthusiast ,
Feb 29, 2024 Feb 29, 2024

Copy link to clipboard

Copied

@Mario Fritsche Thanks for the video. It helped. But my image is now showing. I cannot even the element named "chart" in the structure panel.

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 ,
Feb 29, 2024 Feb 29, 2024

Copy link to clipboard

Copied

You have to adapt the XSLT. All data that must be entered from the XML into the document must also be entered in the XSLT. (There is certainly an easier way to define the XLST, but that's a job for the professionals)
Open the XSLT in an editor and write after the last </dec>

<chart>
<xsl:attribute name="href">
<xsl:value-of select="chart/@href" />
</xsl:attribute>
</chart>

Or download the new XSLT again https://www.dropbox.com/scl/fo/jyvel0enc3caqh7bx4g8v/h?rlkey=i8u487ee1n1shxe4utrjlottd&dl=0

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
Enthusiast ,
Feb 29, 2024 Feb 29, 2024

Copy link to clipboard

Copied

@Mario Fritsche Thank you so much for all your efforts and help. I will try this today and update. 

It seems that to be able to work with InDesign and XML, I have to learn XSLT first because every scenario will be different and according I have to write XSLT for that. What about DTD, does it function the same way as XSLT ?

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
Enthusiast ,
Mar 01, 2024 Mar 01, 2024

Copy link to clipboard

Copied

LATEST

@Mario Fritsche Hi.

 

The xslt works with the image but the image is showing at the wrong place. I have attached the screenshot.

It should show at the image box marked with green rectangle at the lower left side.

 

I could not understand the meaning of this :

<xsl:for-each select="//students/record[count(. | key('groupKey', student-name)[1]) = 1]">

Well I dont know xsl at all but I was trying to understand your code.

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