Copy link to clipboard
Copied
Hi,
Let say i have this simple xml file:
<root>
<p align="right">
</root>How can i map the align="right" with 'align right' in indesign? Is there any example script that i can refer to?
Copy link to clipboard
Copied
Why not define this in the Paragraph Style (at the bottom of that dialog box is a pane for Export Tagging)?
Copy link to clipboard
Copied
Hi @Mana5D15 ,
Example as follows
<root>
<p aid:pstyle="alignRight">Example text that will be aligned right</p>
<root>You need to change you "align" attribute name to "aid:pstyle" as that is an attribute name that is fixed for InDesign to pick up. Once you import that xml into your Indesign document, it should be styled with the "alignRight" paragraph style. I use this xml attribute assignment method for Indesign tables, especially cascading ones.
Some documentation on this is here Adobe InDesign CS3 and XML: A Technical Reference
Any questions (no matter how silly! I know documentation isn't great for Adobe) fire away, happy to help.
Jake
Copy link to clipboard
Copied
I assume that you want to achieve this by script. Here's an example and a test file attached:
main();
function main() {
var xmlEl, xmlContent, xmlAttr, alignment,
doc = app.activeDocument,
root = doc.xmlElements[0],
xPath = "//p[@align]",
xmlElements = root.evaluateXPathExpression(xPath);
for (var i = 0; i < xmlElements.length; i++) {
xmlEl = xmlElements[i];
xmlContent = xmlEl.xmlContent;
xmlAttr = xmlEl.xmlAttributes.itemByName("align");
alignment = xmlAttr.value.toUpperCase();
xmlContent.justification = eval("Justification." + alignment + "_ALIGN");
}
}
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more