Wow, InDesign is picky! After exporting a sample from InDesign as you suggested, I trimmed down the definitions at the beginning to only what InDesign actually needed, which turned out to be just the first line "<UNICODE-WIN>" (I have Japanese in my content, so I can't just use ASCII): <UNICODE-WIN>
<pstyle:Org heading>AnOrgName
<pstyle:Org listing name>Person
<pstyle:Org heading>AnotherOrg
<pstyle:Org listing name>Person... But that wasn't enough for InDesign to accept a file generated by my code. Upon closer inspection, I first noticed that the line endings were different - I was just providing LF (simple style, standard in Unix-based OSs), but InDesign's exported file contained CRLF (Windows style, no surprise, since I'm using Windows). I tried changing the "WIN" in the first line to "UNIX", but that had no effect, so I changed my code to use CRLF everywhere. But that still wasn't enough! The last stubborn problem wasn't obvious until I compared the files with more powerful tools, which revealed that the character encoding was different - my database (and therefore the resulting text file by default) is UTF-8, but apparently InDesign won't consider a placed file as Tagged Text unless the encoding is UTF-16 LE with BOM. I had to do a lot of tricky things in my export code (written in PHP, in case anyone reading this is curious) to get it all to play together nicely, but I finally got there.
... View more