I have an XML file that looks like this:
<?xml version="1.0" encoding="utf-8"?>
<MailItem attribute1="value1" attribute2="and so on...">
<AndOtherElementsToo>Which are not important right now</AndOtherElementsToo>
It's important to note that this document will only ever have ONE <MailItem> (gauranteed), which makes it a root element. I've tried wrapping this in ANOTHER root element called <MailJob> but that caused problems too. More on that in a minute.
I have an InDesign Template that is very straightforward. No tables, nothing. I import my XML file into my TAGS panel and I go to town tagging various text placeholders with things like Mail_ID, and Sale_Date. I perform a test IMPORT XML and things look great. A minor annoyance is if the elements are not in the correct order in the STRUCTURE pane, they won't import correctly, but I can engineer around this by ensuring the elements are produced in a static order. So far so good.
The problem comes when I go to the "letter" part of my template. It begins, "Dear So And So," (literally). Since I want "So And So" to be the actual name from my data, I need to tag this. I open this up in the Story Editor (since I only want PART of the text replaced) and I select "So And So" and I select the CustomerName tag from my Tag panel.
What happens next is where the wheels come off the wagon and I am in desperate need of help. As SOON as I tag it, three things happen:
- The tag appears in the Story Editor. Looks nice. No problem here
- A new TAG appear in my TAG pane called "Story"
- My Structure pane creates a new element called Story and nests a new element, CustomerName underneath it
When I perform a test import now, the greeting on the letter doesn't get replaced (the data doesn't import) because, duh, the structure doesn't match the data coming in. It's looking for <MailJob><Story><CustomerName>Mr. Bray</CustomerName></Story></MailJob> which I do not have in my XML file.
I learn that setting the Tag Preset Options allows me to change the "Story" default to any pre-existing tag. Great! This solves problem #2 above (the "Story" tag no longer gets created in my TAGS panel). But problem #3 still happens; My structure now looks like this:
- MailItem "Dear So And So,"
Arg! All manners of attempting to drag and drop the new, nested CustomerName element to higher in the Structure results in the text being UNTAGGED in the placeholder and the process begins again when I try to fix it.
I thought for a moment that maybe tags embedded within the story editor need to live within a second-level element instead of right under the root element, so I wrapped the whole XML file in <MailJob> </MailJob> elements. This only proceeded to make it impossible to have normal one-to-one text placeholders import/replace correctly (even after I reloaded the tags in the TAGS panel from the newly wrapped file). I didn't even bother testing the within-Story-Editor tags since this is a deal breaker right off the bat.
I can't simply reformat the XML to match what InDesign is expecting because we have ONE xml format (and exporter) for hundreds of document layouts. I *really* don't want to applying XSLT for every quirky change the design group wants to make (e.g. "We want to suddenly start using the state name in the text of the letter, can you update the XSLT file?"), and besides, we run GIANT jobs (thousands of individual documents) and XSLT processing EACH XML file will slow things down more than I want (I've already got a slow process upstream I'm dealing with, I don't want to make it any slower)
I'm going crazy, the pressure is on, and I'm desperate for help. Why can't I get existing XML elements to import INSIDE of a placeholder (along with static text or other elements) the same way they do when I tag an entire placeholder? What am I doing wrong?