I'm trying to generate some content in InDesign by importing XML data, but I can't figure out how to do it. Here's what I have:
<stuff>
<person>
<name>John</name><age>42</age>
<name>Oscar</name><age>39</age>
</person>
</stuff>
And here's what I want the result to look like:
Person: John, 42
Person: Oscar, 39
How do I go about doing this? Is this the right site to post a question like this?
The easiest way to do this is to import your XML source into InDesign. Drag one data node into the layout. Add the repetitive text elements in front of your data, such as "Person:" Format all your placeholders (keep them in the order appearing in the xml) and then delete all nodes from the structure panel that aren't part of the main placeholders.
Re-import the XML source and in the Import xml dialog check the boxes: clone repeating elements..., only import elements that match..., and "ignore whitespace..."
This will being in the XML data and format it in the manner you want. Your layout may be structured only for one data node. To flow the rest, just drag the appropriate parent element from the structure panel to the layout.
InDesign has limited XSLT capabilities, mostly the options in the XML import options dialog. If you need anything more elaborate you'll have to use an external XSLT during import.
InDesign only supports XSLT version 1.0