wplate Posted June 3, 2009 Posted June 3, 2009 I'm trying to build a quick "simple" database that will allow me to write several XML files based on a template. The template has "smart quotes" that need to be preserved, and so far NOT escaping them has led to AppleScript errors (used to write the XML back out to a file) but escaping them actually puts "regular" quotes into the text file. I tried replacing the smart quotes with decimal numeric character references but that doesn't work for the application that needs to parse the XML I'm writing. Anyone have a suggestion?
comment Posted June 3, 2009 Posted June 3, 2009 Have you tried something like: character id 8220 & "abc" & character id 8221 BTW, why aren't you using Filemaker's XML exporting?
wplate Posted June 3, 2009 Author Posted June 3, 2009 I assumed that FileMaker's XML exporting makes a FileMaker XML file, is that true? If so that's no useful to me, I am making a file that isn't FileMaker XML. I found out that the application that I'm writing these files for needs the smart quotes to actually be in the XML file, I can't use entities. I was told, however, that maybe I could "output a raw byte in the text stream", how would I do that? BTW, here is an example of what I'm doing, my goal is to put smart quotes around the replaced "song title" but do it in such a way that the calculated AppleScript script step doesn't choke. My example takes an XML template and uses a calculation to replace some tokens with text entered into a couple text fields.
comment Posted June 3, 2009 Posted June 3, 2009 XML exporting makes a FileMaker XML file, is that true? Yes and no. The default format is one of Filemaker's own XML grammars, but Filemaker has a built in XSLT engine that can transform the exported file using a custom stylesheet. the application that I'm writing these files for needs the smart quotes to actually be in the XML file I am looking at your example, and the only quotes I see are those surrounding the attribute values of the styleRun element. These quotes MUST be regular quotes (single or double), or the document will NOT be a valid XML document. You could still make those quotes smart, by transforming the export to a text file (instead of to XML). But I would suggest you check this requirement again, because it is a VERY irregular one.
wplate Posted June 3, 2009 Author Posted June 3, 2009 Sorry about that. The example I put out doesn't have the smart quotes, because I wanted to put up the example in a "working" state. To see where I want the smart quotes to go change the calculation in the field definition for CalculatedMotionProject to: Substitute ( Substitute ( Substitute ( Substitute ( MotionTemplateText ; "SONGTITLECHARCOUNT" ; SongTitleCharCount ) ; "PERFORMINGGROUPCHARCOUNT" ; PerformingGroupCharCount ) ; "SONGTITLE" ; "“" & SongTitle & "”" ) ; "PERFORMINGGROUP" ; PerformingGroup ) Now run the script and AppleScript fails because now the calculated AppleScript is busted due to the addition of the quote. Next escape the smart quotes by again changing the calculation definition, this time to: Substitute ( Substitute ( Substitute ( Substitute ( MotionTemplateText ; "SONGTITLECHARCOUNT" ; SongTitleCharCount ) ; "PERFORMINGGROUPCHARCOUNT" ; PerformingGroupCharCount ) ; "SONGTITLE" ; "“" & SongTitle & "”" ) ; "PERFORMINGGROUP" ; PerformingGroup ) Now my "Run!" script works and a file is written to the Desktop. But view that file in a text editor and you'll see that my smart quotes are now regular. All I'm doing is essentially writing out a text file, so I'm not sure what you're saying about writing text instead of XML. Does this further explanation help with what I'm trying to achieve?
wplate Posted June 3, 2009 Author Posted June 3, 2009 Thank you, but I can't go the XSL route, the XML template I'm using is pretty big, I just provided I tiny snippet in my example. Trying to transform the entire template would just be very time consuming for someone. If it isn't possible to do it the way I have been describing I guess I go an indirect route and write out some temporary string that I can then batch replace using an AppleScript or something. Thanks for your thoughts.
comment Posted June 3, 2009 Posted June 3, 2009 I don't see why it would be more time consuming to produce the same output in a XSLT stylesheet than in an Applescript. I prefer using XML to produce XML, because the tools are already there and one does not have reinvent the wheel. I am not an expert on Applescript, but I believe the problem here is trying to pass the smart quotes to Applescript as text. You should construct this in the Applescript itself, rather than pass it a complete calculated string.
wplate Posted June 3, 2009 Author Posted June 3, 2009 Reason why the XLS thing would never happen is that I don't understand XLS, at least I understand AppleScript. -) I have a workable solution now, I inserted "LEFTQUOTE" and "RIGHTQUOTE" around the "song title" and then after all of my files are written by FileMaker I run an AppleScript that replaces these temporary text items with “ and ”. Clunky, but for my purposes it is better than where I was 12 hours ago and it works.
Recommended Posts
This topic is 5653 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now