I’m creating a book catalog using XML in InDesign CS. I need to be able to search for content by it’s tag, and replace the text in that tag with an inline text box of the book’s cover. The tag structure to what I’m getting to is this:
This holds the book's ISBN. It's always in it's own paragraph, but the number of paragraphs in between these tags varies
My problem lies in getting the tag names to verify that I have the correct tag. I’d show you what I have so far, but it’s not even remotely correct. My sample data parses and imports correctly. My plan is to get the content of the tag, parse the info I need, and then go the appropriate image. I’m absolutely stumped by this, but there has to be a way. I’ve Googled with no results, and now I’m hitting the forums.
So I cooked up this script to try and explain better what it is that I’m trying to do. Thsi is far as I can get now without coming across errors:
property theList : {}
tell application "InDesign CS"
set thePara to object reference of selection --gets the insertion point
set thePrnt to parent of thePara --gets the text flow
set paraCount to (get count of paragraphs in thePrnt) --count the paragraphs
repeat with p from 1 to paraCount --get the properties, and then the applied XML tag
set paraProp to properties of paragraph p of thePrnt
set paraXML to associated XML elements of paraProp
set end of theList to paraXML
end repeat
return theList
end tell
As expected, the script returns this:
{{XML element id 2 of XML item id 1 of document “IC2K6_template_0_1_2.indd” of application “InDesign CS”}, {XML element id 413 of XML element id 2 of XML item id 1 of document “IC2K6_template_0_1_2.indd” of application “InDesign CS”}, {XML element id 413 of XML element id 2 of XML item id 1 of document “IC2K6_template_0_1_2.indd” of application “InDesign CS”},…[snip]}
My idea is to use these paths, because that’s all there is to work with, to get the name of the tag to see if it’s the one I want. But the problem is that these paths…
–can’t be used to make an object reference
–can’t be used to get properties
–and can’t even be converted into a simple string
and that’s all ANY page item gives to reference the tags. Maybe I’m looking in the wrong direction here, but it seems what should be a simple thing to do is just impossible.