Charlie Butterworth Posted October 18, 2005 Posted October 18, 2005 I am trying to download data to a simple text file using XML. For two fields, I would like to be able to refer to the field names in the XSL stylesheet and arrange them as follows: Record01_Field01 Record01_Field02 Record02_Field01 Record02_Field02 etc. Eventually, I'll want to make a text header for the file that includes total number of records, etc., as well as text headers for each record, but for now, I simply want to be able to download basic data. As you can imagine, I am very, very new to XML. Thak-you, Charlie
Fenton Posted October 18, 2005 Posted October 18, 2005 In xml/xsl there is no default line ending really, everything just runs together. Which is good in a way because it lets you decide what to put, explicitly. In your case you want a return after each field, with 2 returns between records. I added a "header" above the records, with a found count. I also added a row header, with its number. And comments. <?xml version="1.0" encoding="utf-8"?> xmlns:fmp="http://www.filemaker.com/fmpxmlresult" exclude-result-prefixes="fmp" > Total Records: Record:
Fenton Posted October 18, 2005 Posted October 18, 2005 Oops. I wrote the above as if you wanted to "export" such from FileMaker. I don't know exactly what you mean by arranging the data and making headers if you're "downloading."
Charlie Butterworth Posted October 19, 2005 Author Posted October 19, 2005 Fenton, Thank-you for the input. I am beginning to get a grip on the intricacies of XML. My database is a plant DNA research database from which I want to make a single text file that contains header text, and various totals. For example, I can get FM to calculate the length of the longest DNA sequence in a found-set and store it in a global field. That number needs to be incorporated in the header as something like "Matrix length = 844" where the 844 comes from the global field. So, the header in the text file includes data from the part of the XML file, but it only requires it for the first . The body of the text file contains some fields, but not all (does not need the global field) from the the XML export, so these need to be selected (proably with the COL[position()...] command). Maybe this is simply too complicated for a stylesheet. Any further comments would be greatly appreciated. Charlie
Fenton Posted October 19, 2005 Posted October 19, 2005 This would (hopefully) be just a small addition to what we had. I added a Summary field (Price_SUM). You also could use a global field (as you said), or an unstored calculation field; it doesn't matter what type of field. But, since you only want it once, then you'd want to get it from the 1st record; which is written in XSL as: fmp:ROW[1]. It is the 4th field in my export, so I'll specify it by number. This is the easiest way; you have control of the export fields and order within FileMaker. In our "header" area (which is within "fmp:FMPXMLRESULT/fmp:RESULTSET" Also, since it's a field, hence exported by FileMaker for every record, you'd want to exclude it from the regular multiple rows. This can be done with a simple test. != is "does not equal" Within "fmp:ROW" This allows us to use our generic "for-each" for the other fields. Otherwise you could specify each field by name. But this is somewhat awkward with FMPXMLRESULT syntax, because the field names are not right next to the data; they're up in the METADATA. (Do an xml export from FileMaker without specifying an xsl stylesheet to see what it really looks like.) It's easier to specify by the column position: fmp:COL[2]. Related fields are specified by the data position: fmp:DATA[2], as you get the (possible) multiple values as multiple data (fmp:DATA) of the same field (fmp:COL). Easier to see than explain. <?xml version="1.0" encoding="utf-8"?> Total Records: Total Price: Record:
Charlie Butterworth Posted October 21, 2005 Author Posted October 21, 2005 Fenton, I got your code to work, and modified it to show the fields that I wanted to download. I much appreciate your input. Of course, after all that I have found an annoying problem - the software the I want to use this file in (SeAl) does not recognize the FM exported file format - the last carriage return of the FM downloaded text file is different to the last carriage return of the files saved in the SeAl format, even though they are text files. I suppose that it could also be some kind of eof marker. Right now I am stuck on exactly how to proceed. Thanks, Charlie
Recommended Posts
This topic is 6971 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